Skip to content

Commit

Permalink
Added to allow deleting an asset using Content Service.
Browse files Browse the repository at this point in the history
  • Loading branch information
Wolftein committed Feb 13, 2024
1 parent 3bce737 commit 6781ed1
Show file tree
Hide file tree
Showing 7 changed files with 53 additions and 6 deletions.
5 changes: 4 additions & 1 deletion Source/Public/Content/Locator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,8 @@ namespace Content

// -=(Undocumented)=-
virtual void Write(CStr Path, CPtr<const UInt08> Data) = 0;
};

// -=(Undocumented)=-
virtual void Delete(CStr Path) = 0;
};
}
8 changes: 8 additions & 0 deletions Source/Public/Content/Locator/MemoryLocator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,12 @@ namespace Content
void MemoryLocator::Write(CStr Path, CPtr<const UInt08> Data)
{
}

// -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
// -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

void MemoryLocator::Delete(CStr Path)
{

}
}
7 changes: 5 additions & 2 deletions Source/Public/Content/Locator/MemoryLocator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,13 @@ namespace Content
{
public:

// -=(Undocumented)=-
// \see Locator::Open
Chunk Open(CStr Path) override;

// -=(Undocumented)=-
// \see Locator::Write
void Write(CStr Path, CPtr<const UInt08> Data) override;

// \see Locator::Delete
void Delete(CStr Path) override;
};
}
12 changes: 12 additions & 0 deletions Source/Public/Content/Locator/SystemLocator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,18 @@ namespace Content

::CloseHandle(Handle);
}
#endif // EA_PLATFORM_WINDOWS
}

// -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
// -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

void SystemLocator::Delete(CStr Path)
{
#ifdef EA_PLATFORM_WINDOWS
const SStr File = Format("{}/{}", mPath, Path);

::DeleteFileA(File.c_str());
#endif // EA_PLATFORM_WINDOWS
}
}
9 changes: 6 additions & 3 deletions Source/Public/Content/Locator/SystemLocator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,15 @@ namespace Content
// -=(Undocumented)=-
~SystemLocator() override = default;

// -=(Undocumented)=-
Chunk Open(CStr Path) override;
// \see Locator::Open
Chunk Open(CStr Path) override;

// -=(Undocumented)=-
// \see Locator::Write
void Write(CStr Path, CPtr<const UInt08> Data) override;

// \see Locator::Delete
void Delete(CStr Path) override;

private:

// -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Expand Down
15 changes: 15 additions & 0 deletions Source/Public/Content/Service.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,21 @@ namespace Content
// -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
// -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

Bool Service::Delete(Ref<const Uri> Key)
{
if (const auto It = mLocators.find(Key.GetSchema()); It != mLocators.end())
{
It->second->Delete(Key.GetPath());
return true;
}

LOG_WARNING("Could not find a locator to delete the asset '{}'.", Key.GetUrl());
return false;
}

// -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
// -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

void Service::Load(ConstSPtr<Resource> Asset, Bool Async)
{
if (Asset && Asset->HasCreated())
Expand Down
3 changes: 3 additions & 0 deletions Source/Public/Content/Service.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,9 @@ namespace Content
// -=(Undocumented)=-
Bool Save(Ref<const Uri> Key, CPtr<const UInt08> Data);

// -=(Undocumented)=-
Bool Delete(Ref<const Uri> Key);

// -=(Undocumented)=-
template<typename Type>
SPtr<Type> Load(Ref<const Uri> Key)
Expand Down

0 comments on commit 6781ed1

Please sign in to comment.