Add recycle bin to script deleting.
This commit is contained in:
@@ -791,6 +791,27 @@ void Content::DeleteAsset(Asset* asset)
|
||||
asset->DeleteObject();
|
||||
}
|
||||
|
||||
void Content::DeleteScript(const StringView& path)
|
||||
{
|
||||
PROFILE_CPU();
|
||||
if (path.IsEmpty())
|
||||
return;
|
||||
|
||||
// Return if asset
|
||||
Asset* asset = GetAsset(path);
|
||||
if (asset != nullptr)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
#if USE_EDITOR
|
||||
LOG(Info, "Deleting script '{0}'", path);
|
||||
|
||||
// Delete file
|
||||
deleteFileSafety(path, Guid::Empty, false);
|
||||
#endif
|
||||
}
|
||||
|
||||
void Content::DeleteAsset(const StringView& path)
|
||||
{
|
||||
PROFILE_CPU();
|
||||
@@ -823,9 +844,9 @@ void Content::DeleteAsset(const StringView& path)
|
||||
#endif
|
||||
}
|
||||
|
||||
void Content::deleteFileSafety(const StringView& path, const Guid& id)
|
||||
void Content::deleteFileSafety(const StringView& path, const Guid& id, bool useId)
|
||||
{
|
||||
if (!id.IsValid())
|
||||
if (!id.IsValid() && useId)
|
||||
{
|
||||
LOG(Warning, "Cannot remove file \'{0}\'. Given ID is invalid.", path);
|
||||
return;
|
||||
@@ -834,7 +855,7 @@ void Content::deleteFileSafety(const StringView& path, const Guid& id)
|
||||
|
||||
// Ensure that file has the same ID (prevent from deleting different assets)
|
||||
auto storage = ContentStorageManager::TryGetStorage(path);
|
||||
if (storage)
|
||||
if (storage && useId)
|
||||
{
|
||||
storage->CloseFileHandles(); // Close file handle to allow removing it
|
||||
if (!storage->HasAsset(id))
|
||||
|
||||
Reference in New Issue
Block a user