mirror of
https://git.h3cjp.net/H3cJP/yuzu.git
synced 2024-11-14 12:22:46 +00:00
fsp_srv: Implement DeleteFile.
- Used by Binding of Isaac.
This commit is contained in:
parent
34264879b3
commit
bddad50dd4
|
@ -57,10 +57,14 @@ ResultVal<std::unique_ptr<StorageBackend>> Disk_FileSystem::OpenFile(const std::
|
||||||
std::make_unique<Disk_Storage>(std::move(file)));
|
std::make_unique<Disk_Storage>(std::move(file)));
|
||||||
}
|
}
|
||||||
|
|
||||||
ResultCode Disk_FileSystem::DeleteFile(const Path& path) const {
|
ResultCode Disk_FileSystem::DeleteFile(const std::string& path) const {
|
||||||
LOG_WARNING(Service_FS, "(STUBBED) called");
|
if (!FileUtil::Exists(path)) {
|
||||||
// TODO(bunnei): Use correct error code
|
return ERROR_PATH_NOT_FOUND;
|
||||||
return ResultCode(-1);
|
}
|
||||||
|
|
||||||
|
FileUtil::Delete(path);
|
||||||
|
|
||||||
|
return RESULT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
ResultCode Disk_FileSystem::RenameFile(const Path& src_path, const Path& dest_path) const {
|
ResultCode Disk_FileSystem::RenameFile(const Path& src_path, const Path& dest_path) const {
|
||||||
|
|
|
@ -25,7 +25,7 @@ public:
|
||||||
|
|
||||||
ResultVal<std::unique_ptr<StorageBackend>> OpenFile(const std::string& path,
|
ResultVal<std::unique_ptr<StorageBackend>> OpenFile(const std::string& path,
|
||||||
Mode mode) const override;
|
Mode mode) const override;
|
||||||
ResultCode DeleteFile(const Path& path) const override;
|
ResultCode DeleteFile(const std::string& path) const override;
|
||||||
ResultCode RenameFile(const Path& src_path, const Path& dest_path) const override;
|
ResultCode RenameFile(const Path& src_path, const Path& dest_path) const override;
|
||||||
ResultCode DeleteDirectory(const Path& path) const override;
|
ResultCode DeleteDirectory(const Path& path) const override;
|
||||||
ResultCode DeleteDirectoryRecursively(const Path& path) const override;
|
ResultCode DeleteDirectoryRecursively(const Path& path) const override;
|
||||||
|
|
|
@ -97,7 +97,7 @@ public:
|
||||||
* @param path Path relative to the archive
|
* @param path Path relative to the archive
|
||||||
* @return Result of the operation
|
* @return Result of the operation
|
||||||
*/
|
*/
|
||||||
virtual ResultCode DeleteFile(const Path& path) const = 0;
|
virtual ResultCode DeleteFile(const std::string& path) const = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a directory specified by its path
|
* Create a directory specified by its path
|
||||||
|
|
|
@ -20,7 +20,7 @@ ResultVal<std::unique_ptr<StorageBackend>> RomFS_FileSystem::OpenFile(const std:
|
||||||
std::make_unique<RomFS_Storage>(romfs_file, data_offset, data_size));
|
std::make_unique<RomFS_Storage>(romfs_file, data_offset, data_size));
|
||||||
}
|
}
|
||||||
|
|
||||||
ResultCode RomFS_FileSystem::DeleteFile(const Path& path) const {
|
ResultCode RomFS_FileSystem::DeleteFile(const std::string& path) const {
|
||||||
LOG_CRITICAL(Service_FS, "Attempted to delete a file from an ROMFS archive (%s).",
|
LOG_CRITICAL(Service_FS, "Attempted to delete a file from an ROMFS archive (%s).",
|
||||||
GetName().c_str());
|
GetName().c_str());
|
||||||
// TODO(bunnei): Use correct error code
|
// TODO(bunnei): Use correct error code
|
||||||
|
|
|
@ -31,7 +31,7 @@ public:
|
||||||
|
|
||||||
ResultVal<std::unique_ptr<StorageBackend>> OpenFile(const std::string& path,
|
ResultVal<std::unique_ptr<StorageBackend>> OpenFile(const std::string& path,
|
||||||
Mode mode) const override;
|
Mode mode) const override;
|
||||||
ResultCode DeleteFile(const Path& path) const override;
|
ResultCode DeleteFile(const std::string& path) const override;
|
||||||
ResultCode RenameFile(const Path& src_path, const Path& dest_path) const override;
|
ResultCode RenameFile(const Path& src_path, const Path& dest_path) const override;
|
||||||
ResultCode DeleteDirectory(const Path& path) const override;
|
ResultCode DeleteDirectory(const Path& path) const override;
|
||||||
ResultCode DeleteDirectoryRecursively(const Path& path) const override;
|
ResultCode DeleteDirectoryRecursively(const Path& path) const override;
|
||||||
|
|
|
@ -236,7 +236,7 @@ public:
|
||||||
: ServiceFramework("IFileSystem"), backend(std::move(backend)) {
|
: ServiceFramework("IFileSystem"), backend(std::move(backend)) {
|
||||||
static const FunctionInfo functions[] = {
|
static const FunctionInfo functions[] = {
|
||||||
{0, &IFileSystem::CreateFile, "CreateFile"},
|
{0, &IFileSystem::CreateFile, "CreateFile"},
|
||||||
{1, nullptr, "DeleteFile"},
|
{1, &IFileSystem::DeleteFile, "DeleteFile"},
|
||||||
{2, &IFileSystem::CreateDirectory, "CreateDirectory"},
|
{2, &IFileSystem::CreateDirectory, "CreateDirectory"},
|
||||||
{3, nullptr, "DeleteDirectory"},
|
{3, nullptr, "DeleteDirectory"},
|
||||||
{4, nullptr, "DeleteDirectoryRecursively"},
|
{4, nullptr, "DeleteDirectoryRecursively"},
|
||||||
|
@ -273,6 +273,20 @@ public:
|
||||||
rb.Push(backend->CreateFile(name, size));
|
rb.Push(backend->CreateFile(name, size));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DeleteFile(Kernel::HLERequestContext& ctx) {
|
||||||
|
IPC::RequestParser rp{ctx};
|
||||||
|
|
||||||
|
auto file_buffer = ctx.ReadBuffer();
|
||||||
|
auto end = std::find(file_buffer.begin(), file_buffer.end(), '\0');
|
||||||
|
|
||||||
|
std::string name(file_buffer.begin(), end);
|
||||||
|
|
||||||
|
LOG_DEBUG(Service_FS, "called file %s", name.c_str());
|
||||||
|
|
||||||
|
IPC::ResponseBuilder rb{ctx, 2};
|
||||||
|
rb.Push(backend->DeleteFile(name));
|
||||||
|
}
|
||||||
|
|
||||||
void CreateDirectory(Kernel::HLERequestContext& ctx) {
|
void CreateDirectory(Kernel::HLERequestContext& ctx) {
|
||||||
IPC::RequestParser rp{ctx};
|
IPC::RequestParser rp{ctx};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue