Rename FlaxStorage::AllowDataModifications to IsReadOnly
This commit is contained in:
@@ -336,9 +336,7 @@ bool BinaryAsset::SaveToAsset(const StringView& path, AssetInitData& data, bool
|
||||
// Force-resolve storage (asset at that path could be not yet loaded into registry)
|
||||
storage = ContentStorageManager::GetStorage(filePath);
|
||||
}
|
||||
|
||||
// Check if can perform write operation to the asset container
|
||||
if (storage && !storage->AllowDataModifications())
|
||||
if (storage && storage->IsReadOnly())
|
||||
{
|
||||
LOG(Warning, "Cannot write to the asset storage container.");
|
||||
return true;
|
||||
@@ -635,7 +633,7 @@ void BinaryAsset::onRename(const StringView& newPath)
|
||||
ScopeLock lock(Locker);
|
||||
|
||||
// We don't support packages now
|
||||
ASSERT(!Storage->IsPackage() && Storage->AllowDataModifications() && Storage->GetEntriesCount() == 1);
|
||||
ASSERT(!Storage->IsPackage() && !Storage->IsReadOnly() && Storage->GetEntriesCount() == 1);
|
||||
|
||||
// Rename storage
|
||||
Storage->OnRename(newPath);
|
||||
|
||||
@@ -415,9 +415,7 @@ void AssetsCache::RegisterAssets(FlaxStorage* storage)
|
||||
// Check if need to resolve any collisions
|
||||
if (duplicatedEntries.HasItems())
|
||||
{
|
||||
// Check if cannot resolve collision for that container (it must allow to write to)
|
||||
// TODO: we could support packages as well but don't have to do it now, maybe in future
|
||||
if (storage->AllowDataModifications() == false)
|
||||
if (storage->IsReadOnly())
|
||||
{
|
||||
LOG(Error, "Cannot register \'{0}\'. Founded duplicated asset at \'{1}\' but storage container doesn't allow data modifications.", storagePath, info.Path);
|
||||
return;
|
||||
|
||||
@@ -28,7 +28,7 @@ bool BinaryAssetFactoryBase::Init(BinaryAsset* asset)
|
||||
#if USE_EDITOR
|
||||
// Check if need to perform data conversion to the newer version (only in Editor)
|
||||
const auto upgrader = GetUpgrader();
|
||||
if (storage->AllowDataModifications() && upgrader && upgrader->ShouldUpgrade(initData.SerializedVersion))
|
||||
if (!storage->IsReadOnly() && upgrader && upgrader->ShouldUpgrade(initData.SerializedVersion))
|
||||
{
|
||||
const auto startTime = DateTime::NowUTC();
|
||||
const AssetInfo info(asset->GetID(), asset->GetTypeName(), storage->GetPath());
|
||||
|
||||
@@ -23,7 +23,7 @@ public:
|
||||
// [FlaxStorage]
|
||||
String ToString() const override;
|
||||
bool IsPackage() const override;
|
||||
bool AllowDataModifications() const override;
|
||||
bool IsReadOnly() const override;
|
||||
bool HasAsset(const Guid& id) const override;
|
||||
bool HasAsset(const AssetInfo& info) const override;
|
||||
int32 GetEntriesCount() const override;
|
||||
|
||||
@@ -24,7 +24,7 @@ public:
|
||||
// [FlaxStorage]
|
||||
String ToString() const override;
|
||||
bool IsPackage() const override;
|
||||
bool AllowDataModifications() const override;
|
||||
bool IsReadOnly() const override;
|
||||
bool HasAsset(const Guid& id) const override;
|
||||
bool HasAsset(const AssetInfo& info) const override;
|
||||
int32 GetEntriesCount() const override;
|
||||
|
||||
@@ -809,7 +809,7 @@ bool FlaxStorage::ChangeAssetID(Entry& e, const Guid& newId)
|
||||
|
||||
// TODO: validate entry
|
||||
ASSERT(newId.IsValid());
|
||||
ASSERT(AllowDataModifications());
|
||||
ASSERT(!IsReadOnly());
|
||||
|
||||
LOG(Info, "Changing asset \'{0}\' id to \'{1}\' (storage: \'{2}\')", e.ID, newId, _path);
|
||||
|
||||
@@ -883,7 +883,7 @@ bool FlaxStorage::ChangeAssetID(Entry& e, const Guid& newId)
|
||||
|
||||
FlaxChunk* FlaxStorage::AllocateChunk()
|
||||
{
|
||||
if (AllowDataModifications())
|
||||
if (!IsReadOnly())
|
||||
{
|
||||
PROFILE_MEM(ContentFiles);
|
||||
auto chunk = New<FlaxChunk>();
|
||||
@@ -1133,7 +1133,7 @@ bool FlaxStorage::Create(WriteStream* stream, Span<AssetInitData> assets, const
|
||||
bool FlaxStorage::Save(const AssetInitData& data, bool silentMode)
|
||||
{
|
||||
// Check if can modify the storage
|
||||
if (!AllowDataModifications())
|
||||
if (IsReadOnly())
|
||||
return true;
|
||||
|
||||
// Note: we support saving only single asset, to save more assets in single package use FlaxStorage::Create(..)
|
||||
@@ -1544,7 +1544,7 @@ void FlaxStorage::Tick(double time)
|
||||
|
||||
void FlaxStorage::OnRename(const StringView& newPath)
|
||||
{
|
||||
ASSERT(AllowDataModifications());
|
||||
ASSERT(!IsReadOnly());
|
||||
_path = newPath;
|
||||
}
|
||||
|
||||
@@ -1566,9 +1566,9 @@ bool FlaxFile::IsPackage() const
|
||||
return false;
|
||||
}
|
||||
|
||||
bool FlaxFile::AllowDataModifications() const
|
||||
bool FlaxFile::IsReadOnly() const
|
||||
{
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool FlaxFile::HasAsset(const Guid& id) const
|
||||
@@ -1646,9 +1646,9 @@ bool FlaxPackage::IsPackage() const
|
||||
return true;
|
||||
}
|
||||
|
||||
bool FlaxPackage::AllowDataModifications() const
|
||||
bool FlaxPackage::IsReadOnly() const
|
||||
{
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool FlaxPackage::HasAsset(const Guid& id) const
|
||||
|
||||
@@ -276,9 +276,9 @@ public:
|
||||
virtual bool IsPackage() const = 0;
|
||||
|
||||
/// <summary>
|
||||
/// Checks whenever storage container allows the data modifications.
|
||||
/// Checks whenever storage container doesn't allow modifications.
|
||||
/// </summary>
|
||||
virtual bool AllowDataModifications() const = 0;
|
||||
virtual bool IsReadOnly() const = 0;
|
||||
|
||||
/// <summary>
|
||||
/// Determines whether the specified asset exists in this container.
|
||||
|
||||
Reference in New Issue
Block a user