Kanzi Graphics Engine
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros
kzu_binary_directory.h File Reference

Binary directory for .kzb format. More...

Macros

#define KZU_BINARY_FORMAT_VERSION
 Current binary format version. More...
 
#define KZU_BINARY_FILE_INFO_FLAG_LOAD_ON_DEMAND
 This flag is no longer used. More...
 
#define KZU_BINARY_FILE_INFO_FLAG_CACHED_RESOURCE
 If the flag is true, the object will not be released when calling kzuProjectClear. More...
 
#define KZU_BINARY_FILE_INFO_FLAG_IMAGE_USED_IN_CUBE_MAPS
 This flag is only available in images. More...
 
#define KZU_BINARY_FILE_INFO_FLAG_IMAGE_PREMULTIPLIED_ALPHA
 This flag is only available in images. More...
 
#define KZU_BINARY_DIRECTORY_DEFAULT_FILE_FLAG_MASK
 Default mask to pass all flags. More...
 

Enumerations

enum  KzuBinaryLicenseRestriction { KZU_BINARY_LICENSE_RESTRICTION_SHOW_SPLASH_SCREEN, KZU_BINARY_LICENSE_RESTRICTION_SHOW_WATERMARK }
 License type restrictions. More...
 

Functions

kzString kzuBinarySourceGetReferencedFilePath (const struct KzuBinarySource *source, kzUint index)
 Gets a full file path for the given reference index from the binary source. More...
 
kzsError kzuBinarySourceInvalidate (struct KzuBinarySource *source)
 Invalidates the given binary source. More...
 
kzString kzuBinaryFileInfoGetName (const struct KzuBinaryFileInfo *file)
 Gets the name of a file. More...
 
struct KzuBinaryDirectorykzuBinaryFileInfoGetDirectory (const struct KzuBinaryFileInfo *file)
 Gets a directory of the binary file info. More...
 
struct KzuBinarySourcekzuBinaryFileInfoGetSource (const struct KzuBinaryFileInfo *file)
 Gets the binary source of a file. More...
 
kzUint kzuBinaryFileInfoGetSize (const struct KzuBinaryFileInfo *file)
 Gets the size of a file. More...
 
enum KzuBinaryFileType kzuBinaryFileInfoGetType (const struct KzuBinaryFileInfo *file)
 Gets the type of a file. More...
 
kzString kzuBinaryFileInfoGetPath (const struct KzuBinaryFileInfo *file)
 Gets the path of a file. More...
 
kzU32 kzuBinaryFileInfoGetFlags (const struct KzuBinaryFileInfo *file)
 Gets flags from binary file. More...
 
kzBool kzuBinaryFileInfoIsCached (const struct KzuBinaryFileInfo *file)
 Returns true if the file should be cached. More...
 
kzBool kzuBinaryFileInfoIsImageUsedInCubemaps (const struct KzuBinaryFileInfo *file)
 Returns true if the file is an image file that is used in cubemaps. More...
 
kzBool kzuBinaryFileInfoIsImagePremultipliedAlpha (const struct KzuBinaryFileInfo *file)
 Returns true if the file is an image file that has premultiplied alpha. More...
 
kzString kzuBinaryFolderInfoGetName (const struct KzuBinaryFolderInfo *folder)
 Gets the name of a folder. More...
 
struct KzcHashMapkzuBinaryFolderInfoGetSubFolders (const struct KzuBinaryFolderInfo *folder)
 Gets the sub folders of a folder. More...
 
struct KzcHashMapkzuBinaryFolderInfoGetFiles (const struct KzuBinaryFolderInfo *folder)
 Gets the files of a folder. More...
 
kzsError kzuBinaryFolderInfoGetAllFiles (const struct KzuBinaryFolderInfo *folder, struct KzcDynamicArray *files)
 Gets all files recursively from a folder. More...
 
struct KzuBinaryFolderInfokzuBinaryFolderInfoGetSubFolder (const struct KzuBinaryFolderInfo *folder, kzString name)
 Gets a specific sub folder from a folder. More...
 
struct KzuBinaryFileInfokzuBinaryFolderInfoGetFile (const struct KzuBinaryFolderInfo *folder, kzString name)
 Gets a specific sub file from a folder. More...
 
kzsError kzuBinaryDirectoryCreateEmpty (const struct KzcMemoryManager *memoryManager, struct KzuBinaryDirectory **out_directory)
 Creates an empty directory. More...
 
kzsError kzuBinaryDirectoryCreateFromFile (const struct KzcMemoryManager *memoryManager, kzString filePath, struct KzuBinaryDirectory **out_directory, struct KzuBinarySource **out_binarySource)
 Creates a directory and fills the content from a .kzb file. More...
 
kzsError kzuBinaryDirectoryCreateFromMemoryMappedFile (const struct KzcMemoryManager *memoryManager, kzString filePath, struct KzuBinaryDirectory **out_directory, struct KzuBinarySource **out_binarySource)
 Creates a directory and fills the content from a .kzb memory mapped file. More...
 
kzsError kzuBinaryDirectoryCreateFromFileResource (const struct KzcMemoryManager *memoryManager, kzString resourcePath, struct KzuBinaryDirectory **out_directory, struct KzuBinarySource **out_binarySource)
 Creates a directory and fills the content from a .kzb resource file. More...
 
kzsException kzuBinaryDirectoryCreateFromMemory (const struct KzcMemoryManager *memoryManager, const kzByte *buffer, kzUint size, struct KzuBinaryDirectory **out_directory, struct KzuBinarySource **out_binarySource)
 Creates a directory and fills the content from memory buffer with .kzb content. More...
 
kzsError kzuBinaryDirectoryDelete (struct KzuBinaryDirectory *directory)
 Deletes a directory. More...
 
kzsError kzuBinaryDirectoryClear (struct KzuBinaryDirectory *directory)
 Clears a directory. More...
 
kzBool kzuBinaryDirectoryIsEmpty (const struct KzuBinaryDirectory *directory)
 Checks if the binary directory is empty. More...
 
kzsError kzuBinaryDirectoryMerge (struct KzuBinaryDirectory *targetDirectory, struct KzuBinaryDirectory *sourceDirectory, struct KzcDynamicArray *mergedFiles)
 Merges the content of two directories. More...
 
kzsError kzuBinaryDirectoryCopyShortcuts (const struct KzuBinaryDirectory *targetDirectory, const struct KzuBinaryDirectory *sourceDirectory)
 Copies shortcuts from one binary directory to another. More...
 
struct KzuBinaryFolderInfokzuBinaryDirectoryGetRootFolder (const struct KzuBinaryDirectory *directory)
 Gets the root folder of a directory. More...
 
kzString kzuBinaryDirectoryGetName (const struct KzuBinaryDirectory *directory)
 Gets the directory name. More...
 
struct KzcHashSetIterator kzuBinaryDirectoryGetDeletedFiles (const struct KzuBinaryDirectory *directory)
 Gets an iterator of all deleted files in a directory. More...
 
kzsException kzuBinaryDirectoryGetFile (const struct KzcMemoryManager *memoryManager, const struct KzuBinaryDirectory *directory, kzString filePath, struct KzuBinaryFileInfo **out_file)
 Gets a file with the given shortcut or full path from a binary directory. More...
 
kzU32 kzuBinaryDirectoryGetFlags (const struct KzuBinaryDirectory *directory)
 Gets flags from binary directory. More...
 
kzsException kzuBinaryDirectoryGetFolder (const struct KzuBinaryDirectory *directory, kzString folderPath, struct KzuBinaryFolderInfo **out_folder)
 Gets a folder with given path from binary directory. More...
 
kzsException kzuBinaryDirectoryOpenFile (const struct KzcMemoryManager *memoryManager, const struct KzuBinaryFileInfo *file, struct KzcInputStream **out_inputStream)
 Opens a given file for reading. More...
 
kzsException kzuBinaryDirectoryOpenFileWithEndianness (const struct KzcMemoryManager *memoryManager, const struct KzuBinaryFileInfo *file, enum KzcIOStreamEndianness endianness, struct KzcInputStream **out_inputStream)
 Opens a given file for reading with the specified endianness. More...
 
kzsError kzuBinaryDirectoryReadFile (const struct KzcMemoryManager *memoryManager, const struct KzuBinaryFileInfo *file, kzByte **out_data)
 Returns binary data from file. More...
 
kzsException kzuBinaryDirectoryOpenFileWithReferences (const struct KzcMemoryManager *memoryManager, const struct KzuBinaryFileInfo *file, kzUint **out_referencePositions, enum KzcIOStreamEndianness endianness, struct KzcInputStream **out_inputStream)
 Opens a given file for reading with reference positions returned in an array. More...
 
kzsError kzuBinaryDirectoryGetFileReferences (const struct KzcMemoryManager *memoryManager, const struct KzuBinaryFileInfo *file, kzString **out_references)
 Gets all file paths referenced by the given file. More...
 
struct KzcHashSetIterator kzuBinaryDirectoryGetBinarySources (const struct KzuBinaryDirectory *directory)
 Gets all binary sources from directory. More...
 
kzsError kzuBinaryDirectoryGetFileDebugDescription (const struct KzuBinaryFileInfo *file, kzMutableString *out_description)
 Gets a string description of a given file. More...
 
kzString kzuBinaryDirectoryGetActualPath (const struct KzuBinaryDirectory *directory, kzString filePath)
 Search for the given file path from shortcuts. More...
 
kzsException kzuBinaryDirectoryGetFileFromPropertyTypeLibrary (const struct KzuBinaryDirectory *directory, kzString name, struct KzuBinaryFileInfo **out_file)
 Gets file from property type library, using optimized search. More...
 
kzsException kzuBinaryDirectoryGetFileFromAnimationLibrary (const struct KzuBinaryDirectory *directory, kzString filePath, struct KzuBinaryFileInfo **out_file)
 Gets file from animation library, using optimized search. More...
 
kzsException kzuBinaryDirectoryGetFileFromMeshLibrary (const struct KzuBinaryDirectory *directory, kzString filePath, struct KzuBinaryFileInfo **out_file)
 Gets file from mesh library, using optimized search. More...
 
kzsError kzuBinaryDirectoryReadReference (struct KzcInputStream *inputStream, const struct KzuBinaryFileInfo *file, kzString *out_path)
 Loads reference. More...
 
void kzuBinaryDirectorySetFileFlagMask (struct KzuBinaryDirectory *binaryDirectory, kzU32 fileFlagMask)
 Sets file flag mask for binary directory files. More...
 
kzU32 kzuBinaryDirectoryGetFileFlagMask (const struct KzuBinaryDirectory *directory)
 Gets file flag mask from directory. More...
 
kzBool kzuBinaryDirectoryHasLicenseRestriction (const struct KzuBinaryDirectory *directory, enum KzuBinaryLicenseRestriction licenseRestriction)
 Checks if any of the loaded binaries have the given license restriction enabled. More...
 

Detailed Description

Binary directory for .kzb format.

Copyright 2008-2019 by Rightware. All rights reserved.

Macro Definition Documentation

#define KZU_BINARY_FORMAT_VERSION

Current binary format version.

#define KZU_BINARY_FILE_INFO_FLAG_LOAD_ON_DEMAND

This flag is no longer used.

#define KZU_BINARY_FILE_INFO_FLAG_CACHED_RESOURCE

If the flag is true, the object will not be released when calling kzuProjectClear.

#define KZU_BINARY_FILE_INFO_FLAG_IMAGE_USED_IN_CUBE_MAPS

This flag is only available in images.

If the flag is true, the image is used in a cube map and should not be flipped internally.

#define KZU_BINARY_FILE_INFO_FLAG_IMAGE_PREMULTIPLIED_ALPHA

This flag is only available in images.

If the flag is true, the image has premultiplied alpha.

#define KZU_BINARY_DIRECTORY_DEFAULT_FILE_FLAG_MASK

Default mask to pass all flags.

Enumeration Type Documentation

License type restrictions.

Enumerator
KZU_BINARY_LICENSE_RESTRICTION_SHOW_SPLASH_SCREEN 

Splash screen will be shown during startup.

KZU_BINARY_LICENSE_RESTRICTION_SHOW_WATERMARK 

Watermark will be displayed on top of everything else.

Function Documentation

kzString kzuBinarySourceGetReferencedFilePath ( const struct KzuBinarySource source,
kzUint  index 
)

Gets a full file path for the given reference index from the binary source.

Returns
Full file path of the reference with the given index or KZ_NULL if index == 0.
kzsError kzuBinarySourceInvalidate ( struct KzuBinarySource source)

Invalidates the given binary source.

After invalidating a source it will be impossible to load the files from it, but the references can be queried.

kzString kzuBinaryFileInfoGetName ( const struct KzuBinaryFileInfo file)

Gets the name of a file.

struct KzuBinaryDirectory* kzuBinaryFileInfoGetDirectory ( const struct KzuBinaryFileInfo file)

Gets a directory of the binary file info.

struct KzuBinarySource* kzuBinaryFileInfoGetSource ( const struct KzuBinaryFileInfo file)

Gets the binary source of a file.

kzUint kzuBinaryFileInfoGetSize ( const struct KzuBinaryFileInfo file)

Gets the size of a file.

enum KzuBinaryFileType kzuBinaryFileInfoGetType ( const struct KzuBinaryFileInfo file)

Gets the type of a file.

kzString kzuBinaryFileInfoGetPath ( const struct KzuBinaryFileInfo file)

Gets the path of a file.

kzU32 kzuBinaryFileInfoGetFlags ( const struct KzuBinaryFileInfo file)

Gets flags from binary file.

kzBool kzuBinaryFileInfoIsCached ( const struct KzuBinaryFileInfo file)

Returns true if the file should be cached.

kzBool kzuBinaryFileInfoIsImageUsedInCubemaps ( const struct KzuBinaryFileInfo file)

Returns true if the file is an image file that is used in cubemaps.

kzBool kzuBinaryFileInfoIsImagePremultipliedAlpha ( const struct KzuBinaryFileInfo file)

Returns true if the file is an image file that has premultiplied alpha.

kzString kzuBinaryFolderInfoGetName ( const struct KzuBinaryFolderInfo folder)

Gets the name of a folder.

struct KzcHashMap* kzuBinaryFolderInfoGetSubFolders ( const struct KzuBinaryFolderInfo folder)

Gets the sub folders of a folder.

Returns
Hash map of kzString -> KzuBinaryDirectoryFolder entries.
struct KzcHashMap* kzuBinaryFolderInfoGetFiles ( const struct KzuBinaryFolderInfo folder)

Gets the files of a folder.

Returns
Hash map of kzString -> KzuBinaryDirectoryFile entries.
kzsError kzuBinaryFolderInfoGetAllFiles ( const struct KzuBinaryFolderInfo folder,
struct KzcDynamicArray files 
)

Gets all files recursively from a folder.

The files are added to the given dynamic array.

struct KzuBinaryFolderInfo* kzuBinaryFolderInfoGetSubFolder ( const struct KzuBinaryFolderInfo folder,
kzString  name 
)

Gets a specific sub folder from a folder.

Parameters
nameName of the sub folder.
Returns
Returns a sub folder or KZ_NULL if a sub folder with the given name was not found.
struct KzuBinaryFileInfo* kzuBinaryFolderInfoGetFile ( const struct KzuBinaryFolderInfo folder,
kzString  name 
)

Gets a specific sub file from a folder.

Parameters
nameName of the file.
Returns
Returns a file or KZ_NULL if a file with the given name was not found.
kzsError kzuBinaryDirectoryCreateEmpty ( const struct KzcMemoryManager memoryManager,
struct KzuBinaryDirectory **  out_directory 
)

Creates an empty directory.

Content can be added to the directory with kzuBinaryDirectoryMerge().

kzsError kzuBinaryDirectoryCreateFromFile ( const struct KzcMemoryManager memoryManager,
kzString  filePath,
struct KzuBinaryDirectory **  out_directory,
struct KzuBinarySource **  out_binarySource 
)

Creates a directory and fills the content from a .kzb file.

Returns a binary directory and an associated binary source. out_binarySource can be KZ_NULL.

kzsError kzuBinaryDirectoryCreateFromMemoryMappedFile ( const struct KzcMemoryManager memoryManager,
kzString  filePath,
struct KzuBinaryDirectory **  out_directory,
struct KzuBinarySource **  out_binarySource 
)

Creates a directory and fills the content from a .kzb memory mapped file.

Returns a binary directory and an associated binary source. out_binarySource can be KZ_NULL.

kzsError kzuBinaryDirectoryCreateFromFileResource ( const struct KzcMemoryManager memoryManager,
kzString  resourcePath,
struct KzuBinaryDirectory **  out_directory,
struct KzuBinarySource **  out_binarySource 
)

Creates a directory and fills the content from a .kzb resource file.

Returns a binary directory and an associated binary source. out_binarySource can be KZ_NULL.

kzsException kzuBinaryDirectoryCreateFromMemory ( const struct KzcMemoryManager memoryManager,
const kzByte buffer,
kzUint  size,
struct KzuBinaryDirectory **  out_directory,
struct KzuBinarySource **  out_binarySource 
)

Creates a directory and fills the content from memory buffer with .kzb content.

Returns a binary directory and an associated binary source. out_binarySource can be KZ_NULL.

kzsError kzuBinaryDirectoryDelete ( struct KzuBinaryDirectory directory)

Deletes a directory.

kzsError kzuBinaryDirectoryClear ( struct KzuBinaryDirectory directory)

Clears a directory.

kzBool kzuBinaryDirectoryIsEmpty ( const struct KzuBinaryDirectory directory)

Checks if the binary directory is empty.

A directory is not empty if it was created with some other function than kzuBinaryDirectoryCreateEmpty or a non-empty directory was merged to an empty directory.

kzsError kzuBinaryDirectoryMerge ( struct KzuBinaryDirectory targetDirectory,
struct KzuBinaryDirectory sourceDirectory,
struct KzcDynamicArray mergedFiles 
)

Merges the content of two directories.

Note: This function will completely delete sourceDirectory rendering any references to it invalid. This is to ensure that each directory entry is owned by only one directory.

Parameters
mergedFilesIf this parameter is not NULL, all merged files are recorded in this dynamic array of KzuBinaryFileInfo objects.
kzsError kzuBinaryDirectoryCopyShortcuts ( const struct KzuBinaryDirectory targetDirectory,
const struct KzuBinaryDirectory sourceDirectory 
)

Copies shortcuts from one binary directory to another.

If target directory have the same shortcut, the shortcut will not be overwritten.

struct KzuBinaryFolderInfo* kzuBinaryDirectoryGetRootFolder ( const struct KzuBinaryDirectory directory)

Gets the root folder of a directory.

kzString kzuBinaryDirectoryGetName ( const struct KzuBinaryDirectory directory)

Gets the directory name.

struct KzcHashSetIterator kzuBinaryDirectoryGetDeletedFiles ( const struct KzuBinaryDirectory directory)

Gets an iterator of all deleted files in a directory.

kzsException kzuBinaryDirectoryGetFile ( const struct KzcMemoryManager memoryManager,
const struct KzuBinaryDirectory directory,
kzString  filePath,
struct KzuBinaryFileInfo **  out_file 
)

Gets a file with the given shortcut or full path from a binary directory.

Note that because of shortcut objects, the returned file may exist in different path than requested.

kzU32 kzuBinaryDirectoryGetFlags ( const struct KzuBinaryDirectory directory)

Gets flags from binary directory.

kzsException kzuBinaryDirectoryGetFolder ( const struct KzuBinaryDirectory directory,
kzString  folderPath,
struct KzuBinaryFolderInfo **  out_folder 
)

Gets a folder with given path from binary directory.

E.g. "Objects/" would return Object library.

kzsException kzuBinaryDirectoryOpenFile ( const struct KzcMemoryManager memoryManager,
const struct KzuBinaryFileInfo file,
struct KzcInputStream **  out_inputStream 
)

Opens a given file for reading.

kzsException kzuBinaryDirectoryOpenFileWithEndianness ( const struct KzcMemoryManager memoryManager,
const struct KzuBinaryFileInfo file,
enum KzcIOStreamEndianness  endianness,
struct KzcInputStream **  out_inputStream 
)

Opens a given file for reading with the specified endianness.

kzsError kzuBinaryDirectoryReadFile ( const struct KzcMemoryManager memoryManager,
const struct KzuBinaryFileInfo file,
kzByte **  out_data 
)

Returns binary data from file.

kzsException kzuBinaryDirectoryOpenFileWithReferences ( const struct KzcMemoryManager memoryManager,
const struct KzuBinaryFileInfo file,
kzUint **  out_referencePositions,
enum KzcIOStreamEndianness  endianness,
struct KzcInputStream **  out_inputStream 
)

Opens a given file for reading with reference positions returned in an array.

The references in the file can be queried with the functions kzuBinaryFileInfoGetSource() and kzuBinarySourceGetReferencedFilePath().

Parameters
out_referencePositionsThis array will be filled with positions of each reference in the file. If this parameter is KZ_NULL, the position information is ignored and the array is not created. The caller must free the array with kzcMemoryFreeArray afterwards.
kzsError kzuBinaryDirectoryGetFileReferences ( const struct KzcMemoryManager memoryManager,
const struct KzuBinaryFileInfo file,
kzString **  out_references 
)

Gets all file paths referenced by the given file.

The paths are returned in an array of strings, which the caller must delete after done using it.

struct KzcHashSetIterator kzuBinaryDirectoryGetBinarySources ( const struct KzuBinaryDirectory directory)

Gets all binary sources from directory.

kzsError kzuBinaryDirectoryGetFileDebugDescription ( const struct KzuBinaryFileInfo file,
kzMutableString out_description 
)

Gets a string description of a given file.

This is for debugging purposes only.

kzString kzuBinaryDirectoryGetActualPath ( const struct KzuBinaryDirectory directory,
kzString  filePath 
)

Search for the given file path from shortcuts.

If it is found, return the target path of the shortcut. Otherwise return filePath.

kzsException kzuBinaryDirectoryGetFileFromPropertyTypeLibrary ( const struct KzuBinaryDirectory directory,
kzString  name,
struct KzuBinaryFileInfo **  out_file 
)

Gets file from property type library, using optimized search.

kzsException kzuBinaryDirectoryGetFileFromAnimationLibrary ( const struct KzuBinaryDirectory directory,
kzString  filePath,
struct KzuBinaryFileInfo **  out_file 
)

Gets file from animation library, using optimized search.

kzsException kzuBinaryDirectoryGetFileFromMeshLibrary ( const struct KzuBinaryDirectory directory,
kzString  filePath,
struct KzuBinaryFileInfo **  out_file 
)

Gets file from mesh library, using optimized search.

kzsError kzuBinaryDirectoryReadReference ( struct KzcInputStream inputStream,
const struct KzuBinaryFileInfo file,
kzString out_path 
)

Loads reference.

void kzuBinaryDirectorySetFileFlagMask ( struct KzuBinaryDirectory binaryDirectory,
kzU32  fileFlagMask 
)

Sets file flag mask for binary directory files.

Results loaded files to have flags with formula: flags = file.flags & directory.mask

kzU32 kzuBinaryDirectoryGetFileFlagMask ( const struct KzuBinaryDirectory directory)

Gets file flag mask from directory.

kzBool kzuBinaryDirectoryHasLicenseRestriction ( const struct KzuBinaryDirectory directory,
enum KzuBinaryLicenseRestriction  licenseRestriction 
)

Checks if any of the loaded binaries have the given license restriction enabled.