summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/core/file_sys/disk_filesystem.cpp12
-rw-r--r--src/core/file_sys/disk_filesystem.h2
-rw-r--r--src/core/file_sys/filesystem.h2
-rw-r--r--src/core/file_sys/romfs_filesystem.cpp2
-rw-r--r--src/core/file_sys/romfs_filesystem.h2
-rw-r--r--src/core/hle/service/filesystem/fsp_srv.cpp16
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::
57 std::make_unique<Disk_Storage>(std::move(file))); 57 std::make_unique<Disk_Storage>(std::move(file)));
58} 58}
59 59
60ResultCode Disk_FileSystem::DeleteFile(const Path& path) const { 60ResultCode Disk_FileSystem::DeleteFile(const std::string& path) const {
61 LOG_WARNING(Service_FS, "(STUBBED) called"); 61 if (!FileUtil::Exists(path)) {
62 // TODO(bunnei): Use correct error code 62 return ERROR_PATH_NOT_FOUND;
63 return ResultCode(-1); 63 }
64
65 FileUtil::Delete(path);
66
67 return RESULT_SUCCESS;
64} 68}
65 69
66ResultCode Disk_FileSystem::RenameFile(const Path& src_path, const Path& dest_path) const { 70ResultCode 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:
25 25
26 ResultVal<std::unique_ptr<StorageBackend>> OpenFile(const std::string& path, 26 ResultVal<std::unique_ptr<StorageBackend>> OpenFile(const std::string& path,
27 Mode mode) const override; 27 Mode mode) const override;
28 ResultCode DeleteFile(const Path& path) const override; 28 ResultCode DeleteFile(const std::string& path) const override;
29 ResultCode RenameFile(const Path& src_path, const Path& dest_path) const override; 29 ResultCode RenameFile(const Path& src_path, const Path& dest_path) const override;
30 ResultCode DeleteDirectory(const Path& path) const override; 30 ResultCode DeleteDirectory(const Path& path) const override;
31 ResultCode DeleteDirectoryRecursively(const Path& path) const override; 31 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:
97 * @param path Path relative to the archive 97 * @param path Path relative to the archive
98 * @return Result of the operation 98 * @return Result of the operation
99 */ 99 */
100 virtual ResultCode DeleteFile(const Path& path) const = 0; 100 virtual ResultCode DeleteFile(const std::string& path) const = 0;
101 101
102 /** 102 /**
103 * Create a directory specified by its path 103 * 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:
20 std::make_unique<RomFS_Storage>(romfs_file, data_offset, data_size)); 20 std::make_unique<RomFS_Storage>(romfs_file, data_offset, data_size));
21} 21}
22 22
23ResultCode RomFS_FileSystem::DeleteFile(const Path& path) const { 23ResultCode RomFS_FileSystem::DeleteFile(const std::string& path) const {
24 LOG_CRITICAL(Service_FS, "Attempted to delete a file from an ROMFS archive (%s).", 24 LOG_CRITICAL(Service_FS, "Attempted to delete a file from an ROMFS archive (%s).",
25 GetName().c_str()); 25 GetName().c_str());
26 // TODO(bunnei): Use correct error code 26 // 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:
31 31
32 ResultVal<std::unique_ptr<StorageBackend>> OpenFile(const std::string& path, 32 ResultVal<std::unique_ptr<StorageBackend>> OpenFile(const std::string& path,
33 Mode mode) const override; 33 Mode mode) const override;
34 ResultCode DeleteFile(const Path& path) const override; 34 ResultCode DeleteFile(const std::string& path) const override;
35 ResultCode RenameFile(const Path& src_path, const Path& dest_path) const override; 35 ResultCode RenameFile(const Path& src_path, const Path& dest_path) const override;
36 ResultCode DeleteDirectory(const Path& path) const override; 36 ResultCode DeleteDirectory(const Path& path) const override;
37 ResultCode DeleteDirectoryRecursively(const Path& path) const override; 37 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:
236 : ServiceFramework("IFileSystem"), backend(std::move(backend)) { 236 : ServiceFramework("IFileSystem"), backend(std::move(backend)) {
237 static const FunctionInfo functions[] = { 237 static const FunctionInfo functions[] = {
238 {0, &IFileSystem::CreateFile, "CreateFile"}, 238 {0, &IFileSystem::CreateFile, "CreateFile"},
239 {1, nullptr, "DeleteFile"}, 239 {1, &IFileSystem::DeleteFile, "DeleteFile"},
240 {2, &IFileSystem::CreateDirectory, "CreateDirectory"}, 240 {2, &IFileSystem::CreateDirectory, "CreateDirectory"},
241 {3, nullptr, "DeleteDirectory"}, 241 {3, nullptr, "DeleteDirectory"},
242 {4, nullptr, "DeleteDirectoryRecursively"}, 242 {4, nullptr, "DeleteDirectoryRecursively"},
@@ -273,6 +273,20 @@ public:
273 rb.Push(backend->CreateFile(name, size)); 273 rb.Push(backend->CreateFile(name, size));
274 } 274 }
275 275
276 void DeleteFile(Kernel::HLERequestContext& ctx) {
277 IPC::RequestParser rp{ctx};
278
279 auto file_buffer = ctx.ReadBuffer();
280 auto end = std::find(file_buffer.begin(), file_buffer.end(), '\0');
281
282 std::string name(file_buffer.begin(), end);
283
284 LOG_DEBUG(Service_FS, "called file %s", name.c_str());
285
286 IPC::ResponseBuilder rb{ctx, 2};
287 rb.Push(backend->DeleteFile(name));
288 }
289
276 void CreateDirectory(Kernel::HLERequestContext& ctx) { 290 void CreateDirectory(Kernel::HLERequestContext& ctx) {
277 IPC::RequestParser rp{ctx}; 291 IPC::RequestParser rp{ctx};
278 292