Stub DeleteDirectory

Should allow deleting/rewriting saves in some games
This commit is contained in:
Dima 2022-11-29 10:16:45 +03:00 committed by Billy Laws
parent bbd34ae7e7
commit 69ee3cfc66
5 changed files with 28 additions and 0 deletions

View File

@ -60,6 +60,13 @@ namespace skyline::service::fssrv {
return {};
}
Result IFileSystem::DeleteDirectory(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response) {
std::string path(request.inputBuf.at(0).as_string(true));
backing->DeleteDirectory(path);
return {};
}
Result IFileSystem::OpenDirectory(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response) {
std::string path(request.inputBuf.at(0).as_string(true));

View File

@ -33,6 +33,11 @@ namespace skyline::service::fssrv {
*/
Result CreateDirectory(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response);
/**
* @brief Deletes a directory at the specified path in the filesystem
*/
Result DeleteDirectory(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response);
/**
* @brief Queries the DirectoryEntryType of the given path
* @url https://switchbrew.org/wiki/Filesystem_services#GetEntryType
@ -60,6 +65,7 @@ namespace skyline::service::fssrv {
SFUNC(0x0, IFileSystem, CreateFile),
SFUNC(0x1, IFileSystem, DeleteFile),
SFUNC(0x2, IFileSystem, CreateDirectory),
SFUNC(0x3, IFileSystem, DeleteDirectory),
SFUNC(0x7, IFileSystem, GetEntryType),
SFUNC(0x8, IFileSystem, OpenFile),
SFUNC(0x9, IFileSystem, OpenDirectory),

View File

@ -20,6 +20,10 @@ namespace skyline::vfs {
throw exception("This filesystem does not support deleting files");
}
virtual void DeleteDirectoryImpl(const std::string &path) {
throw exception("This filesystem does not support deleting directories");
}
virtual bool CreateDirectoryImpl(const std::string &path, bool parents) {
throw exception("This filesystem does not support creating directories");
};
@ -56,6 +60,10 @@ namespace skyline::vfs {
DeleteFileImpl(path);
}
void DeleteDirectory(const std::string &path) {
DeleteDirectoryImpl(path);
}
/**
* @brief Creates a directory in the filesystem
* @param path The path to where the directory should be created

View File

@ -43,6 +43,11 @@ namespace skyline::vfs {
remove(fullPath.c_str());
}
void OsFileSystem::DeleteDirectoryImpl(const std::string &path) {
auto fullPath{basePath + path};
std::filesystem::remove_all(fullPath.c_str());
}
bool OsFileSystem::CreateDirectoryImpl(const std::string &path, bool parents) {
auto fullPath{basePath + path + "/"};

View File

@ -18,6 +18,8 @@ namespace skyline::vfs {
void DeleteFileImpl(const std::string &path) override;
void DeleteDirectoryImpl(const std::string &path) override;
bool CreateDirectoryImpl(const std::string &path, bool parents) override;
std::shared_ptr<Backing> OpenFileImpl(const std::string &path, Backing::Mode mode) override;