Blender V5.3
filelist_intern.hh
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2007 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
8
9#pragma once
10
11#include <cstdint>
12#include <memory>
13
14#include "BLI_fileops.hh"
15#include "BLI_map.hh"
16
17#include "DNA_listBase.h"
18#include "DNA_space_enums.h"
19#include "DNA_space_types.h"
20
21#include "IMB_thumbs.hh"
22
23struct BlendHandle;
24namespace blender {
25
26#define FILEDIR_NBR_ENTRIES_UNSET -1
27
28using FileUID = uint32_t;
29
30struct AssetLibraryReference;
31struct FileDirEntry;
32struct FileIndexerType;
33struct ID;
34struct PreviewImage;
35struct ThreadQueue;
36struct TaskPool;
37
38namespace asset_system {
39class AssetLibrary;
40class AssetRepresentation;
41} // namespace asset_system
42namespace ed::asset_browser {
44}
45
46/* ------------------FILELIST------------------------ */
47
49 FileListInternEntry *next = nullptr, *prev = nullptr;
50
52
55 int blentype = 0;
56
57 char *relpath = nullptr;
59 char *redirection_path = nullptr;
61 const char *name = nullptr;
62 bool free_name = false;
63
69 struct {
71 ID *id = nullptr;
72
73 /* For the few file types that have the preview already in memory. For others, there's delayed
74 * preview reading from disk. Non-owning pointer. */
75 PreviewImage *preview_image = nullptr;
77
85 std::weak_ptr<asset_system::AssetRepresentation> asset;
86
87 /* See #FILE_ENTRY_BLENDERLIB_NO_PREVIEW. */
89
93
99 {
100 if (std::shared_ptr<asset_system::AssetRepresentation> asset_ptr = asset.lock()) {
101 /* Returning a raw pointer from a shared pointer and destructing the shared pointer
102 * immediately afterwards isn't entirely clean. But it's just a way to get the raw pointer
103 * from the weak pointer. Nothing should free the asset in the asset library meanwhile, so
104 * this should be fine really. */
105 BLI_assert(asset_ptr.use_count() > 1);
106 return asset_ptr.get();
107 }
108 return nullptr;
109 }
110};
111
114 ListBaseT<FileListInternEntry> entries;
116
117 FileUID curr_uid; /* Used to generate UID during internal listing. */
118};
119
120#define FILELIST_ENTRYCACHESIZE_DEFAULT 1024 /* Keep it a power of two! */
122 size_t size = 0; /* The size of the cache... */
123
124 int flags = 0;
125
126 /* This one gathers all entries from both block and misc caches. Used for easy bulk-freeing. */
127 ListBaseT<FileDirEntry> cached_entries = {};
128
129 /* Block cache: all entries between start and end index.
130 * used for part of the list on display. */
136
137 /* Misc cache: random indices, FIFO behavior.
138 * NOTE: Not 100% sure we actually need that, time will say. */
139 int misc_cursor = 0;
140 int *misc_entries_indices = nullptr;
142
143 /* Allows to quickly get a cached entry from its UID. */
145
146 /* Previews handling. */
154
157};
158
160enum {
162};
163
171
172/* Dummy wrapper around FileListEntryPreview to ensure we do not access freed memory when freeing
173 * tasks' data (see #74609). */
177
181 char filter_search[66]; /* + 2 for heading/trailing implicit '*' wildcards. */
182 short flags;
183
185};
186
188enum {
190 FLF_HIDE_DOT = 1 << 1,
196};
197
198struct FileListReadJob;
199struct FileList {
201
203 /* The library this list was created for. Stored here so we know when to re-read. */
206
207 short flags;
208
209 short sort;
210
212
217
219
221
233
236
239
240 BlendHandle *libfiledata;
241
249 char dirpath[FILE_MAX_LIBEXTRA],
250 const bool do_change);
251
253 void (*start_job_fn)(FileListReadJob *job_params);
255 void (*timer_step_fn)(FileListReadJob *job_params);
257 void (*read_job_fn)(FileListReadJob *job_params, bool *stop, bool *do_update, float *progress);
258
260 bool (*filter_fn)(FileListInternEntry *file, const char *root, FileListFilter *filter);
263
265 short tags;
266};
267
269enum {
271 /* Don't do a full reset (unless #FL_FORCE_RESET is also set), only reset files representing main
272 * data (assets from the current file/#Main). */
274 FL_IS_READY = 1 << 2,
285};
286
301
306 /* Keep this last. */
308};
309
310void filelist_cache_clear(FileListEntryCache *cache, size_t new_size);
311
312FileUID filelist_uid_generate(FileList *filelist);
313
314const char *fileentry_uiname(const char *root, FileListInternEntry *entry, char *buff);
315
316bool filelist_intern_entry_is_main_file(const FileListInternEntry *intern_entry);
317
318void prepare_filter_asset_library(const FileList *filelist, FileListFilter *filter);
319
321bool is_filtered_file(FileListInternEntry *file, const char * /*root*/, FileListFilter *filter);
322bool is_filtered_asset(FileListInternEntry *file, FileListFilter *filter);
323bool is_filtered_lib(FileListInternEntry *file, const char *root, FileListFilter *filter);
324bool is_filtered_main_assets(FileListInternEntry *file,
325 const char * /*dir*/,
326 FileListFilter *filter);
327bool is_filtered_asset_library(FileListInternEntry *file,
328 const char *root,
329 FileListFilter *filter);
330
331bool filelist_checkdir_dir(const FileList * /*filelist*/,
332 char dirpath[FILE_MAX_LIBEXTRA],
333 const bool do_change);
334bool filelist_checkdir_lib(const FileList * /*filelist*/,
335 char dirpath[FILE_MAX_LIBEXTRA],
336 const bool do_change);
337
339void filelist_entry_glob_tag(FileListInternEntry *entry, const char *filter_glob);
341void filelist_reset_glob(FileList *filelist);
342
343void filelist_set_readjob_directories(FileList *filelist);
344void filelist_set_readjob_library(FileList *filelist);
345void filelist_set_readjob_on_disk_asset_library(FileList *filelist);
346void filelist_set_readjob_remote_asset_library(FileList *filelist);
348void filelist_set_readjob_essentials_asset_library(FileList *filelist);
349void filelist_set_readjob_all_asset_library(FileList *filelist);
350
351} // namespace blender
File and directory operations.
#define FILE_MAXFILE
These structs are the foundation for all linked lists in the library system.
#define FILE_MAX_LIBEXTRA
BMesh Iterators.
BLI_assert(slot->slot_subtype.map==BMO_OP_SLOT_SUBTYPE_MAP_FLT)
void filelist_set_readjob_all_asset_library(FileList *filelist)
unsigned __int64 uint64_t
Definition BKE_text.h:91
bool filelist_intern_entry_is_main_file(const FileListInternEntry *intern_entry)
Definition filelist.cc:452
unsigned int uint
Definition BKE_text.h:55
@ FL_ASSETS_INCLUDE_ONLINE
@ FL_RELOAD_ASSET_LIBRARY
@ FL_FORCE_RESET_MAIN_FILES
void filelist_set_readjob_current_file_asset_library(FileList *filelist)
@ FLF_ASSETS_HIDE_OFFLINE
bool filelist_checkdir_dir(const FileList *, char dirpath[FILE_MAX_LIBEXTRA], const bool do_change)
void filelist_reset_glob(FileList *filelist)
Definition filelist.cc:1176
bool is_filtered_asset_library(FileListInternEntry *file, const char *root, FileListFilter *filter)
void prepare_filter_asset_library(const FileList *filelist, FileListFilter *filter)
void filelist_set_readjob_essentials_asset_library(FileList *filelist)
void filelist_cache_clear(FileListEntryCache *cache, size_t new_size)
Definition filelist.cc:846
bool is_filtered_main_assets(FileListInternEntry *file, const char *, FileListFilter *filter)
uint32_t FileUID
Definition filelist.hh:34
void filelist_set_readjob_library(FileList *filelist)
unsigned int uint32_t
Definition BKE_text.h:81
void filelist_set_readjob_remote_asset_library(FileList *filelist)
void filelist_set_readjob_directories(FileList *filelist)
void filelist_entry_glob_tag(FileListInternEntry *entry, const char *filter_glob)
Definition filelist.cc:1158
bool filelist_checkdir_lib(const FileList *, char dirpath[FILE_MAX_LIBEXTRA], const bool do_change)
void filelist_set_readjob_on_disk_asset_library(FileList *filelist)
const char * fileentry_uiname(const char *root, FileListInternEntry *entry, char *buff)
Definition filelist.cc:1073
@ FILELIST_TAGS_USES_MAIN_DATA
@ FILELIST_TAGS_FROM_GLOBAL_ASSET_LIST
@ FILELIST_TAGS_APPLY_FUZZY_SEARCH
@ FILELIST_TAGS_NO_THREADS
bool is_filtered_asset(FileListInternEntry *file, FileListFilter *filter)
FileUID filelist_uid_generate(FileList *filelist)
Definition filelist.cc:1422
bool is_filtered_file(FileListInternEntry *file, const char *, FileListFilter *filter)
struct stat BLI_stat_t
bool is_filtered_lib(FileListInternEntry *file, const char *root, FileListFilter *filter)
ListBaseT< FileDirEntry > cached_entries
ThumbCancellationToken previews_cancel_token
Map< int, FileDirEntry * > uids
Map< int, FileDirEntry * > misc_entries
char filepath[FILE_MAX_LIBEXTRA]
ed::asset_browser::AssetCatalogFilterSettings * asset_catalog_filter
std::weak_ptr< asset_system::AssetRepresentation > asset
FileListInternEntry * next
struct blender::FileListInternEntry::@000065073311321332173152260127375002005026343052 local_data
asset_system::AssetRepresentation * get_asset() const
FileListInternEntry * prev
ListBaseT< FileListInternEntry > entries
FileListInternEntry ** filtered
void(*) prepare_filter_fn(const FileList *filelist, FileListFilter *filter)
void(*) timer_step_fn(FileListReadJob *job_params)
bool(*) check_dir_fn(const FileList *filelist, char dirpath[FILE_MAX_LIBEXTRA], const bool do_change)
void(*) start_job_fn(FileListReadJob *job_params)
AssetLibraryReference * asset_library_ref
void(*) read_job_fn(FileListReadJob *job_params, bool *stop, bool *do_update, float *progress)
FileListEntryCache * filelist_cache
FileDirEntryArr filelist
FileListFilter filter_data
bool(*) filter_fn(FileListInternEntry *file, const char *root, FileListFilter *filter)
BlendHandle * libfiledata
eFileSelectType type
const FileIndexerType * indexer
char filter_glob[FILE_MAXFILE]
FileListIntern filelist_intern
asset_system::AssetLibrary * asset_library