Blender V5.0
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.h"
15
16#include "DNA_listBase.h"
17#include "DNA_space_enums.h"
18#include "DNA_space_types.h"
19
20#define FILEDIR_NBR_ENTRIES_UNSET -1
21
22using FileUID = uint32_t;
23
25struct BlendHandle;
26struct FileDirEntry;
27struct FileIndexerType;
28struct GHash;
29struct ID;
30struct PreviewImage;
31struct ThreadQueue;
32struct TaskPool;
33
34namespace blender {
35namespace asset_system {
36class AssetLibrary;
37class AssetRepresentation;
38} // namespace asset_system
39namespace ed::asset_browser {
41}
42} // namespace blender
43
44/* ------------------FILELIST------------------------ */
45
47 FileListInternEntry *next = nullptr, *prev = nullptr;
48
50
53 int blentype = 0;
54
55 char *relpath = nullptr;
57 char *redirection_path = nullptr;
59 const char *name = nullptr;
60 bool free_name = false;
61
67 struct {
69 ID *id = nullptr;
70
71 /* For the few file types that have the preview already in memory. For others, there's delayed
72 * preview reading from disk. Non-owning pointer. */
75
83 std::weak_ptr<blender::asset_system::AssetRepresentation> asset;
84
85 /* See #FILE_ENTRY_BLENDERLIB_NO_PREVIEW. */
87
91
97 {
98 if (std::shared_ptr<blender::asset_system::AssetRepresentation> asset_ptr = asset.lock()) {
99 /* Returning a raw pointer from a shared pointer and destructing the shared pointer
100 * immediately afterwards isn't entirely clean. But it's just a way to get the raw pointer
101 * from the weak pointer. Nothing should free the asset in the asset library meanwhile, so
102 * this should be fine really. */
103 BLI_assert(asset_ptr.use_count() > 1);
104 return asset_ptr.get();
105 }
106 return nullptr;
107 }
108};
109
114
115 FileUID curr_uid; /* Used to generate UID during internal listing. */
116};
117
118#define FILELIST_ENTRYCACHESIZE_DEFAULT 1024 /* Keep it a power of two! */
120 size_t size = 0; /* The size of the cache... */
121
122 int flags = 0;
123
124 /* This one gathers all entries from both block and misc caches. Used for easy bulk-freeing. */
126
127 /* Block cache: all entries between start and end index.
128 * used for part of the list on display. */
134
135 /* Misc cache: random indices, FIFO behavior.
136 * NOTE: Not 100% sure we actually need that, time will say. */
137 int misc_cursor = 0;
138 int *misc_entries_indices = nullptr;
139 GHash *misc_entries = nullptr;
140
141 /* Allows to quickly get a cached entry from its UID. */
142 GHash *uids = nullptr;
143
144 /* Previews handling. */
151
154};
155
157enum {
159};
160
168
169/* Dummy wrapper around FileListEntryPreview to ensure we do not access freed memory when freeing
170 * tasks' data (see #74609). */
174
184
186enum {
188 FLF_HIDE_DOT = 1 << 1,
192};
193
194struct FileListReadJob;
195struct FileList {
197
199 /* The library this list was created for. Stored here so we know when to re-read. */
202
203 short flags;
204
205 short sort;
206
208
213
215
217
229
232
233 BlendHandle *libfiledata;
234
242 char dirpath[FILE_MAX_LIBEXTRA],
243 const bool do_change);
244
246 void (*read_job_fn)(FileListReadJob *job_params, bool *stop, bool *do_update, float *progress);
247
249 bool (*filter_fn)(FileListInternEntry *file, const char *root, FileListFilter *filter);
252
254 short tags;
255};
256
258enum {
260 /* Don't do a full reset (unless #FL_FORCE_RESET is also set), only reset files representing main
261 * data (assets from the current file/#Main). */
263 FL_IS_READY = 1 << 2,
271};
272
280
285 /* Keep this last. */
287};
288
289void filelist_cache_clear(FileListEntryCache *cache, size_t new_size);
290
292
294
296bool is_filtered_file(FileListInternEntry *file, const char * /*root*/, FileListFilter *filter);
298bool is_filtered_lib(FileListInternEntry *file, const char *root, FileListFilter *filter);
299bool is_filtered_main(FileListInternEntry *file, const char * /*dir*/, FileListFilter *filter);
301 const char * /*dir*/,
304 const char *root,
#define BLI_assert(a)
Definition BLI_assert.h:46
File and directory operations.
struct stat BLI_stat_t
eFileAttributes
#define FILE_MAXFILE
unsigned int uint
These structs are the foundation for all linked lists in the library system.
eFileSelectType
eFileSel_File_Types
#define FILE_MAX_LIBEXTRA
unsigned long long int uint64_t
uint32_t FileUID
Definition filelist.hh:33
void filelist_cache_clear(FileListEntryCache *cache, size_t new_size)
Definition filelist.cc:817
bool is_filtered_asset_library(FileListInternEntry *file, const char *root, FileListFilter *filter)
FileListTags
@ FILELIST_TAGS_USES_MAIN_DATA
@ FILELIST_TAGS_NO_THREADS
bool is_filtered_asset(FileListInternEntry *file, FileListFilter *filter)
bool is_filtered_main_assets(FileListInternEntry *file, const char *, FileListFilter *filter)
bool is_filtered_file(FileListInternEntry *file, const char *, FileListFilter *filter)
bool is_filtered_lib(FileListInternEntry *file, const char *root, FileListFilter *filter)
@ FLF_DO_FILTER
@ FLF_HIDE_LIB_DIR
@ FLF_HIDE_PARENT
@ FLF_ASSETS_ONLY
@ FLF_HIDE_DOT
void prepare_filter_asset_library(const FileList *filelist, FileListFilter *filter)
@ FL_NEED_SORTING
@ FL_IS_PENDING
@ FL_SORT_INVERT
@ FL_IS_READY
@ FL_FORCE_RESET_MAIN_FILES
@ FL_NEED_FILTERING
@ FL_FORCE_RESET
@ FL_RELOAD_ASSET_LIBRARY
bool is_filtered_main(FileListInternEntry *file, const char *, FileListFilter *filter)
SpecialFileImages
@ FLC_PREVIEWS_ACTIVE
bool filelist_intern_entry_is_main_file(const FileListInternEntry *intern_entry)
Definition filelist.cc:403
#define filter
ThreadQueue * previews_done
FileDirEntry ** block_entries
FileListEntryPreview * preview
char filepath[FILE_MAX_LIBEXTRA]
char filter_glob[FILE_MAXFILE]
blender::ed::asset_browser::AssetCatalogFilterSettings * asset_catalog_filter
struct FileListInternEntry::@364374371172256277004264162343271025307331240316 local_data
PreviewImage * preview_image
eFileAttributes attributes
eFileSel_File_Types typeflag
FileListInternEntry * next
FileListInternEntry * prev
std::weak_ptr< blender::asset_system::AssetRepresentation > asset
blender::asset_system::AssetRepresentation * get_asset() const
FileListInternEntry ** filtered
void(* prepare_filter_fn)(const FileList *filelist, FileListFilter *filter)
bool(* filter_fn)(FileListInternEntry *file, const char *root, FileListFilter *filter)
FileDirEntryArr filelist
bool(* check_dir_fn)(const FileList *filelist, char dirpath[FILE_MAX_LIBEXTRA], const bool do_change)
FileListEntryCache * filelist_cache
AssetLibraryReference * asset_library_ref
void(* read_job_fn)(FileListReadJob *job_params, bool *stop, bool *do_update, float *progress)
GHash * selection_state
short max_recursion
FileListIntern filelist_intern
eFileSelectType type
short recursion_level
BlendHandle * libfiledata
FileListFilter filter_data
const FileIndexerType * indexer
blender::asset_system::AssetLibrary * asset_library
Definition DNA_ID.h:414