class
ProjectLibraryDatabase
Maintains a database for all entries in the project library.
This allows for quick access to the project library structure, as well as meta-data for resources. Note this class does not deal with actual resources, folders or packages - instead it is just a reflection of the actual data present in the packages, and as such this database can always be rebuilt from the package data.
Public
Constructors
ProjectLibraryDatabase
Methods
BuildFromFiles
Rebuilds the database from files found in the provided folder.
Note packages must already be loaded by the package manager or they will be ignored.
- rootFolderPath
- Absolute path to the folder containing packages which to visit to create the database from. All entries in the database will be stored relative to this folder. Package file-names are not included in database paths. For example: A package 'C:/Resources/Imported/Textures/MyPackage.b3d' containing 'MyTexture' resource will have the resulting entry relative path be '/Textures/MyTexture/', provided is 'C:/Resources/Imported/'.
BuildEntriesForPackage
Attempts to create project library entries from an existing package.
- rootFolderPath
- Absolute path to the folder containing packages. See BuildFromFiles().
- packagePath
- Absolute path to the package. Must be a child of .
MoveEntry
Moves an entry from one location to another.
If the entry is a folder, all the children will be moved as well. If destination already contains an entry with the same name, the move operation will be skipped for that source entry - except if both source and destination is a folder, in which case their contents will be merged.
- sourceRelativePath
- Path to the file or folder to move. Relative to the package folder path the database was built from.
- destinationRelativePath
- Path to which to move the file or folder. Relative to the package folder path the database was built from.
Returns: Operation result and optional error message if failed. If successful returns a list of all entries that were affected by the operation.
CopyEntry
Copies an entry from one location to another.
If the entry is a folder, all the children will be copied as well. If destination already contains an entry with the same name, the copy operation will be skipped for that source entry - except if both source and destination is a folder, in which case their contents will be merged.
- sourceRelativePath
- Path to the file or folder to move. Relative to the package folder path the database was built from.
- destinationRelativePath
- Path to which to move the file or folder. Relative to the package folder path the database was built from.
Returns: Operation result and optional error message if failed. If successful returns a list of all entries that were affected by the operation.
FindEntry
Attempts to a find a library entry at the specified path.
- relativePath
- Path to the entry to search. Relative to the package folder path the database was built from.
Returns: Found entry, or null if not found.
FindEntry
Attempts to find a library resource entry from the resource ID.
- resourceId
- ID of the resource to find.
Returns: Found entry, or null if not found.
FindFirstValidEntry
Attempts to find an entry at the provided path.
If one doesn't exist, it searches for the parent of that path. And so on until the path root is reached.
- relativePath
- Path to the entry to search for. Relative to the package folder path the database was built from.
Returns: First existing parent folder. Returns null if invalid path is provided (e.g. absolute path).
Search
Searches the library for a pattern and returns all entries matching it.
- pattern
- Pattern to search for. Use wildcard * to match any character(s).
Returns: A list of entries matching the pattern.
Search
Searches the library for a pattern, but only among specific resource types.
- pattern
- Pattern to search for. Use wildcard * to match any character(s).
- typeIds
- RTTI type IDs of the resource types to limit the search for.
Returns: A list of entries matching the pattern.
Search
Searches a particular folder or package for a pattern, but only among specific resource types.
- relativePath
- Path to the folder or package to search.
- pattern
- Pattern to search for. Use wildcard * to match any character(s).
- typeIds
- RTTI type IDs of the resource types to limit the search for.
- recurse
- If true, child folders or packages of the current folder will also be searched.
Returns: A list of entries matching the pattern.
Iterate
Iterates over all entries at the provided path, and triggers the callback for each entry.
Iteration is depth first.
- relativePath
- Path to iterate. Callback will be triggered for this path (if valid), and any children if is true. Relative to the package folder path the database was built from.
- callback
- Callback to trigger for each found entry. Return false to stop iterating.
- recursive
- If true, children of child container entries will be iterated.
FindOrCreateParentFolderHierarchy
Creates a full hierarchy of folder entries up to the provided path, if any are needed.
Or returns existing container entry if it is already present.
- relativePath
- Path to the entry we're creating the parent hierarchy for. Relative to the package folder path the database was built from.
Returns: Operation result and optional error message if failed.
TryCreateResourceEntry
Creates a new resource entry at the provided path.
Operation will fail if the entry already exists.
- relativePath
- Path at which to create the entry. Relative to the package folder path the database was built from.
- allowCreateInReadOnly
- Allows creation of entries with read-only parents.
- resourceMetaData
- Meta-data of the resource.
Returns: Operation result and optional error message if failed.
TryCreateFolderEntry
Creates a new folder entry at the provided path.
Operation will fail if the entry already exists.
- relativePath
- Path at which to create the entry. Relative to the package folder path the database was built from.
- allowCreateInReadOnly
- Allows creation of entries with read-only parents.
Returns: Operation result and optional error message if failed.
TryCreateSynchronizedPackageEntry
Creates a new synchronized package entry at the provided path.
Operation will fail if the entry already exists.
- relativePath
- Path at which to create the entry. Relative to the package folder path the database was built from.
- synchronizedPackageMetaData
- Meta-data about the source resource the synchronized package was created from.
Returns: Operation result and optional error message if failed.
DeleteEntry
Deletes an new entry at the provided path.
- relativePath
- Path at which to delete the entry. Relative to the package folder path the database was built from.
ReloadPackageMetaDataForEntry
Reloads the resource meta-data for the resource entry at the provided path.
Does nothing if the path is not found, or is not a resource.
- rootFolderPath
- Absolute path to which is relative to.
- relativePath
- Path to the entry whose meta-data to reload. Relative to the package folder path the database was built from.
ReloadPackageMetaDataForEntry
Reloads the resource meta-data for the provided resource entry.
- rootFolderPath
- Absolute path to which relative path of the provided entry is relative to.
ReloadMetaDataForSynchronizedPackageEntry
Reloads the package meta-data for the provided synchronized package entry.
- rootFolderPath
- Absolute path to which relative path of the provided entry is relative to.
- entry
- Entry for which to reload the meta-data for.
staticGetRttiStatic
Private
Methods
FindOrCreateParentFolderHierarchy
Creates a full hierarchy of folder entries up to the provided path, if any are needed.
Or returns existing container entry if it is already present.
- relativePath
- Path to the entry we're creating the parent hierarchy for. Relative to the package folder path the database was built from.
- allowCreateInReadOnly
- Allows creation of entries with read-only parents.
Returns: Operation result and optional error message if failed.
CreatePackageHierarchyRecursive
Iterates the provided package hierarchy and creates entries for each file or folder in the package.