diff options
author | bunnei <bunneidev@gmail.com> | 2018-04-15 21:13:02 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-04-15 21:13:02 +0200 |
commit | b8825fbf10c3122309313a959a93b20baa94ec2f (patch) | |
tree | c7e6223749099a7ae145cb1a925d6a71c16c169a | |
parent | Merge pull request #334 from Subv/used_buffers (diff) | |
parent | fsp_srv: Implement DeleteFile. (diff) | |
download | yuzu-b8825fbf10c3122309313a959a93b20baa94ec2f.tar yuzu-b8825fbf10c3122309313a959a93b20baa94ec2f.tar.gz yuzu-b8825fbf10c3122309313a959a93b20baa94ec2f.tar.bz2 yuzu-b8825fbf10c3122309313a959a93b20baa94ec2f.tar.lz yuzu-b8825fbf10c3122309313a959a93b20baa94ec2f.tar.xz yuzu-b8825fbf10c3122309313a959a93b20baa94ec2f.tar.zst yuzu-b8825fbf10c3122309313a959a93b20baa94ec2f.zip |
-rw-r--r-- | src/core/file_sys/disk_filesystem.cpp | 12 | ||||
-rw-r--r-- | src/core/file_sys/disk_filesystem.h | 2 | ||||
-rw-r--r-- | src/core/file_sys/filesystem.h | 2 | ||||
-rw-r--r-- | src/core/file_sys/romfs_filesystem.cpp | 2 | ||||
-rw-r--r-- | src/core/file_sys/romfs_filesystem.h | 2 | ||||
-rw-r--r-- | src/core/hle/service/filesystem/fsp_srv.cpp | 16 |
6 files changed, 27 insertions, 9 deletions
diff --git a/src/core/file_sys/disk_filesystem.cpp b/src/core/file_sys/disk_filesystem.cpp index 4235f3935..263392930 100644 --- a/src/core/file_sys/disk_filesystem.cpp +++ b/src/core/file_sys/disk_filesystem.cpp @@ -57,10 +57,14 @@ ResultVal<std::unique_ptr<StorageBackend>> Disk_FileSystem::OpenFile(const std:: std::make_unique<Disk_Storage>(std::move(file))); } -ResultCode Disk_FileSystem::DeleteFile(const Path& path) const { - LOG_WARNING(Service_FS, "(STUBBED) called"); - // TODO(bunnei): Use correct error code - return ResultCode(-1); +ResultCode Disk_FileSystem::DeleteFile(const std::string& path) const { + if (!FileUtil::Exists(path)) { + return ERROR_PATH_NOT_FOUND; + } + + FileUtil::Delete(path); + + return RESULT_SUCCESS; } ResultCode Disk_FileSystem::RenameFile(const Path& src_path, const Path& dest_path) const { diff --git a/src/core/file_sys/disk_filesystem.h b/src/core/file_sys/disk_filesystem.h index 742d7db1a..05a29bc3a 100644 --- a/src/core/file_sys/disk_filesystem.h +++ b/src/core/file_sys/disk_filesystem.h @@ -25,7 +25,7 @@ public: ResultVal<std::unique_ptr<StorageBackend>> OpenFile(const std::string& path, 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 DeleteDirectory(const Path& path) const override; ResultCode DeleteDirectoryRecursively(const Path& path) const override; diff --git a/src/core/file_sys/filesystem.h b/src/core/file_sys/filesystem.h index 399427ca2..beefcfdb2 100644 --- a/src/core/file_sys/filesystem.h +++ b/src/core/file_sys/filesystem.h @@ -97,7 +97,7 @@ public: * @param path Path relative to the archive * @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 diff --git a/src/core/file_sys/romfs_filesystem.cpp b/src/core/file_sys/romfs_filesystem.cpp index 0c6cc3157..3d77e2d5f 100644 --- a/src/core/file_sys/romfs_filesystem.cpp +++ b/src/core/file_sys/romfs_filesystem.cpp @@ -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)); } -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).", GetName().c_str()); // TODO(bunnei): Use correct error code diff --git a/src/core/file_sys/romfs_filesystem.h b/src/core/file_sys/romfs_filesystem.h index 3f94c04d0..1b5cac409 100644 --- a/src/core/file_sys/romfs_filesystem.h +++ b/src/core/file_sys/romfs_filesystem.h @@ -31,7 +31,7 @@ public: ResultVal<std::unique_ptr<StorageBackend>> OpenFile(const std::string& path, 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 DeleteDirectory(const Path& path) const override; ResultCode DeleteDirectoryRecursively(const Path& path) const override; diff --git a/src/core/hle/service/filesystem/fsp_srv.cpp b/src/core/hle/service/filesystem/fsp_srv.cpp index 458210a55..45accbf0e 100644 --- a/src/core/hle/service/filesystem/fsp_srv.cpp +++ b/src/core/hle/service/filesystem/fsp_srv.cpp @@ -236,7 +236,7 @@ public: : ServiceFramework("IFileSystem"), backend(std::move(backend)) { static const FunctionInfo functions[] = { {0, &IFileSystem::CreateFile, "CreateFile"}, - {1, nullptr, "DeleteFile"}, + {1, &IFileSystem::DeleteFile, "DeleteFile"}, {2, &IFileSystem::CreateDirectory, "CreateDirectory"}, {3, nullptr, "DeleteDirectory"}, {4, nullptr, "DeleteDirectoryRecursively"}, @@ -273,6 +273,20 @@ public: 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) { IPC::RequestParser rp{ctx}; |