Class FlaxStorage
Flax assets storage container.
Inheritance
Assembly: FlaxEngine.dll
File: Engine/Content/Storage/FlaxStorage.h
Syntax
public class FlaxStorage : public Object
Constructors
~FlaxStorage()
FlaxStorage(const StringView& path)
Fields
_chunks
Declaration
protected Array<FlaxChunk* > _chunks
Field Value
Array<FlaxChunk >
|
_chunksLock
Declaration
protected int64 _chunksLock = 0
Field Value
int64
|
_file
Declaration
protected ThreadLocal<FileReadStream* > _file
Field Value
ThreadLocal<FileReadStream >
|
_files
Declaration
protected int64 _files = 0
Field Value
int64
|
_lastRefLostTime
Declaration
protected double _lastRefLostTime
Field Value
double
|
_loadLocker
Declaration
protected CriticalSection _loadLocker
Field Value
CriticalSection
|
_path
_refCount
Declaration
protected int64 _refCount = 0
Field Value
int64
|
_version
Declaration
protected uint32 _version = 0
Field Value
uint32
|
MagicCode
Magic code stored in file header to identify contents.
Declaration
public static int32 MagicCode
Field Value
int32
|
OnReloaded
Action fired on storage reloading. bool param means 'wasReloadFail'
Declaration
public Delegate<FlaxStorage* , bool> OnReloaded
Field Value
Delegate<FlaxStorage , bool>
|
OnReloading
Action fired on storage reloading.
Declaration
public Delegate<FlaxStorage* > OnReloading
Field Value
Delegate<FlaxStorage >
|
Methods
AddChunk(FlaxChunk* chunk)
AddEntry(Entry& e)
Declaration
protected virtual void AddEntry(Entry& e) = 0
Parameters
Entry
e
|
AllocateChunk()
Allocates the new chunk within a storage container (if it's possible).
Declaration
public FlaxChunk* AllocateChunk()
Returns
FlaxChunk
Allocated chunk or null if cannot. |
AllowDataModifications()
Checks whenever storage container allows the data modifications.
Declaration
public virtual bool AllowDataModifications() const = 0
Returns
bool
|
ChangeAssetID(Entry& e, const Guid& newId)
Changes the asset identifier. Warning! Changes only ID in storage layer, not dependencies resolving at all!
Declaration
public bool ChangeAssetID(Entry& e, const Guid& newId)
Parameters
Entry
e
The asset entry. |
Guid
newId
The new identifier. |
Returns
bool
True if cannot change data, otherwise false |
CloseFileHandles()
Closes the file handles (it can be modified from the outside).
Declaration
public bool CloseFileHandles()
Returns
bool
|
Create(const StringView& path, const Array<AssetInitData>& assets, bool silentMode=false, const CustomData* customData=nullptr)
Creates new FlaxFile using specified assets data.
Declaration
public static bool Create(const StringView& path, const Array<AssetInitData>& assets, bool silentMode=false, const CustomData* customData=nullptr)
Parameters
StringView
path
The file path. |
Array<AssetInitData>
assets
The assets data to write. |
bool
silentMode
In silent mode don't reload opened storage container that is using target file. |
CustomData
customData
Custom options. |
Returns
bool
True if cannot create package, otherwise false |
Create(const StringView& path, const AssetInitData& asset, bool silentMode=false, const CustomData* customData=nullptr)
Creates new FlaxFile using specified asset data.
Declaration
public static bool Create(const StringView& path, const AssetInitData& asset, bool silentMode=false, const CustomData* customData=nullptr)
Parameters
StringView
path
The file path. |
AssetInitData
asset
The asset data to write. |
bool
silentMode
In silent mode don't reload opened storage container that is using target file. |
CustomData
customData
Custom options. |
Returns
bool
True if cannot create package, otherwise false |
Create(const StringView& path, Span<AssetInitData> assets, bool silentMode=false, const CustomData* customData=nullptr)
Creates new FlaxFile using specified assets data.
Declaration
public static bool Create(const StringView& path, Span<AssetInitData> assets, bool silentMode=false, const CustomData* customData=nullptr)
Parameters
StringView
path
The file path. |
Span<AssetInitData>
assets
The assets data to write. |
bool
silentMode
In silent mode don't reload opened storage container that is using target file. |
CustomData
customData
Custom options. |
Returns
bool
True if cannot create package, otherwise false |
Create(WriteStream* stream, Span<AssetInitData> assets, const CustomData* customData=nullptr)
Creates new FlaxFile using specified assets data.
Declaration
public static bool Create(WriteStream* stream, Span<AssetInitData> assets, const CustomData* customData=nullptr)
Parameters
WriteStream
stream
The output stream. |
Span<AssetInitData>
assets
The assets data to write. |
CustomData
customData
Custom options. |
Returns
bool
True if cannot create package, otherwise false |
Dispose()
Releases storage resources and closes handle to the file.
Declaration
public virtual void Dispose()
GetChunks(Array<FlaxChunk* >& output)
Gets all the chunks in the storage.
Declaration
public void GetChunks(Array<FlaxChunk* >& output) const
Parameters
Array<FlaxChunk >
output
The output. |
Returns
void
|
GetEntries(Array<Entry>& output)
Gets all the entries in the storage.
Declaration
public virtual void GetEntries(Array<Entry>& output) const = 0
Parameters
Array<Entry>
output
The output. |
GetEntriesCount()
Gets amount of entries in the storage.
Declaration
public virtual int32 GetEntriesCount() const = 0
Returns
int32
|
GetEntry(const Guid& id, Entry& e)
Declaration
protected virtual bool GetEntry(const Guid& id, Entry& e) = 0
Parameters
Guid
id
|
Entry
e
|
Returns
bool
|
GetEntry(int32 index)
Gets the asset entry at given index.
Declaration
public Entry GetEntry(int32 index) const
Parameters
int32
index
The asset index. |
Returns
Entry
The output. |
GetEntry(int32 index, Entry& value)
Gets the asset entry at given index.
Declaration
public virtual void GetEntry(int32 index, Entry& value) const = 0
Parameters
int32
index
The asset index. |
Entry
value
The result. |
GetMemoryUsage()
Gets total memory used by chunks (in bytes).
Declaration
public uint32 GetMemoryUsage() const
Returns
uint32
|
GetPath()
GetRefCount()
Gets the references count.
Declaration
public uint32 GetRefCount() const
Returns
uint32
|
HasAsset(const AssetInfo& info)
Determines whether the specified asset exists in this container.
Declaration
public virtual bool HasAsset(const AssetInfo& info) const = 0
Parameters
AssetInfo
info
The asset info. |
Returns
bool
True if the specified asset exists in this container, otherwise false. |
HasAsset(const Guid& id)
Determines whether the specified asset exists in this container.
Declaration
public virtual bool HasAsset(const Guid& id) const = 0
Parameters
Guid
id
The asset identifier. |
Returns
bool
True if the specified asset exists in this container, otherwise false. |
IsDisposed()
Determines whether this instance is disposed.
Declaration
public bool IsDisposed() const
Returns
bool
|
IsLoaded()
Determines whether this instance is loaded.
Declaration
public bool IsLoaded() const
Returns
bool
|
IsPackage()
Determines whether this storage container is a package.
Declaration
public virtual bool IsPackage() const = 0
Returns
bool
|
Load()
Loads package from the file.
Declaration
public bool Load()
Returns
bool
True if cannot load, otherwise false |
LoadAssetChunk(FlaxChunk* chunk)
Loads the asset chunk.
Declaration
public bool LoadAssetChunk(FlaxChunk* chunk)
Parameters
FlaxChunk
chunk
The chunk. |
Returns
bool
True if cannot load data, otherwise false |
LoadAssetHeader(const Entry& e, AssetInitData& data)
Declaration
protected bool LoadAssetHeader(const Entry& e, AssetInitData& data)
Parameters
Entry
e
|
AssetInitData
data
|
Returns
bool
|
LoadAssetHeader(const Guid& id, AssetInitData& data)
Loads the asset header.
Declaration
public bool LoadAssetHeader(const Guid& id, AssetInitData& data)
Parameters
Guid
id
The asset identifier. |
AssetInitData
data
The data. |
Returns
bool
True if cannot load data, otherwise false |
LoadAssetHeader(const int32 index, AssetInitData& data)
Loads the asset header.
Declaration
public bool LoadAssetHeader(const int32 index, AssetInitData& data)
Parameters
int32
index
The asset index. |
AssetInitData
data
The data. |
Returns
bool
True if cannot load data, otherwise false |
Lock()
Locks the storage container chunks within a code block section (using a local variable that keeps a scope lock).
Declaration
public LockData Lock()
Returns
LockData
The scope lock. |
LockChunks()
Locks the storage chunks data to prevent disposing them. Also ensures that file handles won't be closed while chunks are locked.
Declaration
public void LockChunks()
Returns
void
|
LockSafe()
Locks the storage container chunks within a code block section (using a local variable that keeps a scope lock).
Lock is done with a safe critical section for a ContentStorageManager that prevents to minor issues with threading. Should be used on a separate threads (eg. GameCooker thread).
Declaration
public LockData LockSafe()
Returns
LockData
The scope lock. |
OnRename(const StringView& newPath)
OpenFile()
Reload()
Reloads this storage container.
Declaration
public bool Reload()
Returns
bool
True if cannot load, otherwise false |
ReloadSilent()
Declaration
protected bool ReloadSilent()
Returns
bool
|
Save(const AssetInitData& data, bool silentMode=false)
Saves the specified asset data to the storage container.
Declaration
public bool Save(const AssetInitData& data, bool silentMode=false)
Parameters
AssetInitData
data
The data to save. |
bool
silentMode
In silent mode don't reload opened storage container that is using target file. |
Returns
bool
True if cannot save, otherwise false |
SetEntry(int32 index, const Entry& value)
Sets the asset entry at given index.
Declaration
public virtual void SetEntry(int32 index, const Entry& value) = 0
Parameters
int32
index
The asset index. |
Entry
value
The input value. |
ShouldDispose()
Checks if storage container should be disposed (it's not used anymore).
Declaration
public bool ShouldDispose() const
Returns
bool
|
Tick(double time)
Ticks this instance.
Declaration
public void Tick(double time)
Parameters
double
time
|
UnlockChunks()
Unlocks the storage chunks data.
Declaration
public void UnlockChunks()
Returns
void
|