diff --git a/app/src/main/cpp/skyline/services/fssrv/IFileSystem.cpp b/app/src/main/cpp/skyline/services/fssrv/IFileSystem.cpp index 1b9d5a0c..a91509ea 100644 --- a/app/src/main/cpp/skyline/services/fssrv/IFileSystem.cpp +++ b/app/src/main/cpp/skyline/services/fssrv/IFileSystem.cpp @@ -53,6 +53,13 @@ namespace skyline::service::fssrv { return {}; } + Result IFileSystem::DeleteFile(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response) { + std::string path(request.inputBuf.at(0).as_string(true)); + + backing->DeleteFile(path); + return {}; + } + Result IFileSystem::OpenDirectory(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response) { std::string path(request.inputBuf.at(0).as_string(true)); diff --git a/app/src/main/cpp/skyline/services/fssrv/IFileSystem.h b/app/src/main/cpp/skyline/services/fssrv/IFileSystem.h index caa918f1..61805b4c 100644 --- a/app/src/main/cpp/skyline/services/fssrv/IFileSystem.h +++ b/app/src/main/cpp/skyline/services/fssrv/IFileSystem.h @@ -23,6 +23,11 @@ namespace skyline::service::fssrv { */ Result CreateFile(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); + /** + * @brief Deletes a file at the specified path in the filesystem + */ + Result DeleteFile(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); + /** * @brief Creates a directory at the specified path in the filesystem */ @@ -53,6 +58,7 @@ namespace skyline::service::fssrv { SERVICE_DECL( SFUNC(0x0, IFileSystem, CreateFile), + SFUNC(0x1, IFileSystem, DeleteFile), SFUNC(0x2, IFileSystem, CreateDirectory), SFUNC(0x7, IFileSystem, GetEntryType), SFUNC(0x8, IFileSystem, OpenFile), diff --git a/app/src/main/cpp/skyline/vfs/filesystem.h b/app/src/main/cpp/skyline/vfs/filesystem.h index 7b424ca7..1418c8fe 100644 --- a/app/src/main/cpp/skyline/vfs/filesystem.h +++ b/app/src/main/cpp/skyline/vfs/filesystem.h @@ -16,6 +16,10 @@ namespace skyline::vfs { throw exception("This filesystem does not support creating files"); }; + virtual void DeleteFileImpl(const std::string &path) { + throw exception("This filesystem does not support deleting files"); + } + virtual bool CreateDirectoryImpl(const std::string &path, bool parents) { throw exception("This filesystem does not support creating directories"); }; @@ -46,7 +50,11 @@ namespace skyline::vfs { */ bool CreateFile(const std::string &path, size_t size) { return CreateFileImpl(path, size); - }; + } + + void DeleteFile(const std::string &path) { + DeleteFileImpl(path); + } /** * @brief Creates a directory in the filesystem diff --git a/app/src/main/cpp/skyline/vfs/os_filesystem.cpp b/app/src/main/cpp/skyline/vfs/os_filesystem.cpp index e20ce889..0ce10d91 100644 --- a/app/src/main/cpp/skyline/vfs/os_filesystem.cpp +++ b/app/src/main/cpp/skyline/vfs/os_filesystem.cpp @@ -38,6 +38,11 @@ namespace skyline::vfs { return true; } + void OsFileSystem::DeleteFileImpl(const std::string &path) { + auto fullPath{basePath + path}; + remove(fullPath.c_str()); + } + bool OsFileSystem::CreateDirectoryImpl(const std::string &path, bool parents) { auto fullPath{basePath + path + "/"}; diff --git a/app/src/main/cpp/skyline/vfs/os_filesystem.h b/app/src/main/cpp/skyline/vfs/os_filesystem.h index 3a9bd0d3..7e9df31e 100644 --- a/app/src/main/cpp/skyline/vfs/os_filesystem.h +++ b/app/src/main/cpp/skyline/vfs/os_filesystem.h @@ -16,6 +16,8 @@ namespace skyline::vfs { protected: bool CreateFileImpl(const std::string &path, size_t size) override; + void DeleteFileImpl(const std::string &path) override; + bool CreateDirectoryImpl(const std::string &path, bool parents) override; std::shared_ptr OpenFileImpl(const std::string &path, Backing::Mode mode) override;