Blender V5.0
blender::ed::asset::index::AssetLibraryIndex Struct Reference

References the asset library directory. More...

Classes

struct  PreexistingFileIndexInfo

Public Member Functions

 AssetLibraryIndex (const StringRef library_path)
uint64_t hash () const
StringRefNull get_library_file_path () const
void init_indices_base_path ()
 Initializes #AssetLibraryIndex.indices_base_path.
std::string index_file_path (const BlendFile &asset_file) const
void collect_preexisting_file_indices ()
void mark_as_used (const std::string &filename)
bool delete_file_index (const std::string &filename)
int remove_broken_index_files ()
int remove_unused_index_files ()

Public Attributes

Map< std::string, PreexistingFileIndexInfopreexisting_file_indices
std::string indices_base_path
 Absolute path where the indices of library are stored.
std::string library_path

Detailed Description

References the asset library directory.

The AssetLibraryIndex instance collects file indices that are existing before the actual reading/updating starts. This way, the reading/updating can tag pre-existing files as used when they are still needed. Remaining ones (indices that are not tagged as used) can be removed once reading finishes.

Definition at line 287 of file asset_indexer.cc.

Constructor & Destructor Documentation

◆ AssetLibraryIndex()

blender::ed::asset::index::AssetLibraryIndex::AssetLibraryIndex ( const StringRef library_path)
inline

Definition at line 310 of file asset_indexer.cc.

References init_indices_base_path(), and library_path.

Member Function Documentation

◆ collect_preexisting_file_indices()

void blender::ed::asset::index::AssetLibraryIndex::collect_preexisting_file_indices ( )
inline

Check for pre-existing index files to be able to track what is still used and what can be removed. See #AssetLibraryIndex::preexisting_file_indices.

Definition at line 362 of file asset_indexer.cc.

References BLI_filelist_dir_contents(), BLI_filelist_free(), BLI_is_dir(), BLI_str_endswith(), i, direntry::path, and direntry::relname.

Referenced by blender::ed::asset::index::init_user_data().

◆ delete_file_index()

bool blender::ed::asset::index::AssetLibraryIndex::delete_file_index ( const std::string & filename)
inline

Removes the file index from disk and preexisting_file_indices (invalidating its iterators, so don't call while iterating).

Returns
true if deletion was successful.

Definition at line 393 of file asset_indexer.cc.

References BLI_delete().

Referenced by remove_broken_index_files(), and remove_unused_index_files().

◆ get_library_file_path()

StringRefNull blender::ed::asset::index::AssetLibraryIndex::get_library_file_path ( ) const
inline

Definition at line 320 of file asset_indexer.cc.

◆ hash()

uint64_t blender::ed::asset::index::AssetLibraryIndex::hash ( ) const
inline

Definition at line 315 of file asset_indexer.cc.

References blender::get_default_hash().

Referenced by init_indices_base_path().

◆ index_file_path()

std::string blender::ed::asset::index::AssetLibraryIndex::index_file_path ( const BlendFile & asset_file) const
inline
Returns
absolute path to the index file of the given asset_file.

{indices_base_path}/{asset-file_hash}_{asset-file-filename}.index.json.

Definition at line 349 of file asset_indexer.cc.

References blender::ed::asset::index::BlendFile::get_filename(), and blender::ed::asset::index::BlendFile::hash().

◆ init_indices_base_path()

void blender::ed::asset::index::AssetLibraryIndex::init_indices_base_path ( )
inline

Initializes #AssetLibraryIndex.indices_base_path.

BKE_appdir_folder_caches/asset-library-indices/<asset-library-name-hash>/

Definition at line 330 of file asset_indexer.cc.

References BKE_appdir_folder_caches(), BLI_path_append(), FILE_MAX, hash(), and SEP_STR.

Referenced by AssetLibraryIndex().

◆ mark_as_used()

void blender::ed::asset::index::AssetLibraryIndex::mark_as_used ( const std::string & filename)
inline

◆ remove_broken_index_files()

int blender::ed::asset::index::AssetLibraryIndex::remove_broken_index_files ( )

◆ remove_unused_index_files()

int blender::ed::asset::index::AssetLibraryIndex::remove_unused_index_files ( )
inline

Member Data Documentation

◆ indices_base_path

std::string blender::ed::asset::index::AssetLibraryIndex::indices_base_path

Absolute path where the indices of library are stored.

Note
includes trailing directory separator.

Definition at line 306 of file asset_indexer.cc.

◆ library_path

std::string blender::ed::asset::index::AssetLibraryIndex::library_path

Definition at line 308 of file asset_indexer.cc.

Referenced by AssetLibraryIndex().

◆ preexisting_file_indices

Map<std::string , PreexistingFileIndexInfo> blender::ed::asset::index::AssetLibraryIndex::preexisting_file_indices

File indices that are existing already before reading/updating performs changes. The key is the absolute path. The value can store information like if the index is known to be used.

Note that when deleting a file index (#delete_index_file()), it's also removed from here, since it doesn't exist and isn't relevant to keep track of anymore.

Definition at line 299 of file asset_indexer.cc.

Referenced by remove_broken_index_files().


The documentation for this struct was generated from the following file: