summaryrefslogtreecommitdiffstats
path: root/src/core/file_sys
diff options
context:
space:
mode:
authorbunnei <bunneidev@gmail.com>2014-11-24 02:02:23 +0100
committerbunnei <bunneidev@gmail.com>2014-11-24 02:02:23 +0100
commitef1b16a7eb3da11d18e68521ddd996e8f48f3aa1 (patch)
tree5562cdcd5eaa63021832dab60abfbb2756533838 /src/core/file_sys
parentMerge pull request #220 from yuriks/patch-1 (diff)
parentAdded DeleteFile and DeleteDirectory functions to FS:USER and the archives. (diff)
downloadyuzu-ef1b16a7eb3da11d18e68521ddd996e8f48f3aa1.tar
yuzu-ef1b16a7eb3da11d18e68521ddd996e8f48f3aa1.tar.gz
yuzu-ef1b16a7eb3da11d18e68521ddd996e8f48f3aa1.tar.bz2
yuzu-ef1b16a7eb3da11d18e68521ddd996e8f48f3aa1.tar.lz
yuzu-ef1b16a7eb3da11d18e68521ddd996e8f48f3aa1.tar.xz
yuzu-ef1b16a7eb3da11d18e68521ddd996e8f48f3aa1.tar.zst
yuzu-ef1b16a7eb3da11d18e68521ddd996e8f48f3aa1.zip
Diffstat (limited to 'src/core/file_sys')
-rw-r--r--src/core/file_sys/archive.h14
-rw-r--r--src/core/file_sys/archive_romfs.cpp20
-rw-r--r--src/core/file_sys/archive_romfs.h14
-rw-r--r--src/core/file_sys/archive_sdmc.cpp18
-rw-r--r--src/core/file_sys/archive_sdmc.h14
5 files changed, 80 insertions, 0 deletions
diff --git a/src/core/file_sys/archive.h b/src/core/file_sys/archive.h
index 1135d8804..2e79bb883 100644
--- a/src/core/file_sys/archive.h
+++ b/src/core/file_sys/archive.h
@@ -185,6 +185,20 @@ public:
virtual std::unique_ptr<File> OpenFile(const Path& path, const Mode mode) const = 0;
/**
+ * Delete a file specified by its path
+ * @param path Path relative to the archive
+ * @return Whether the file could be deleted
+ */
+ virtual bool DeleteFile(const FileSys::Path& path) const = 0;
+
+ /**
+ * Delete a directory specified by its path
+ * @param path Path relative to the archive
+ * @return Whether the directory could be deleted
+ */
+ virtual bool DeleteDirectory(const FileSys::Path& path) const = 0;
+
+ /**
* Create a directory specified by its path
* @param path Path relative to the archive
* @return Whether the directory could be created
diff --git a/src/core/file_sys/archive_romfs.cpp b/src/core/file_sys/archive_romfs.cpp
index 551913a42..53dc57954 100644
--- a/src/core/file_sys/archive_romfs.cpp
+++ b/src/core/file_sys/archive_romfs.cpp
@@ -34,6 +34,26 @@ std::unique_ptr<File> Archive_RomFS::OpenFile(const Path& path, const Mode mode)
}
/**
+ * Delete a file specified by its path
+ * @param path Path relative to the archive
+ * @return Whether the file could be deleted
+ */
+bool Archive_RomFS::DeleteFile(const FileSys::Path& path) const {
+ ERROR_LOG(FILESYS, "Attempted to delete a file from ROMFS.");
+ return false;
+}
+
+/**
+ * Delete a directory specified by its path
+ * @param path Path relative to the archive
+ * @return Whether the directory could be deleted
+ */
+bool Archive_RomFS::DeleteDirectory(const FileSys::Path& path) const {
+ ERROR_LOG(FILESYS, "Attempted to delete a directory from ROMFS.");
+ return false;
+}
+
+/**
* Create a directory specified by its path
* @param path Path relative to the archive
* @return Whether the directory could be created
diff --git a/src/core/file_sys/archive_romfs.h b/src/core/file_sys/archive_romfs.h
index f05327f51..0649dde99 100644
--- a/src/core/file_sys/archive_romfs.h
+++ b/src/core/file_sys/archive_romfs.h
@@ -37,6 +37,20 @@ public:
std::unique_ptr<File> OpenFile(const Path& path, const Mode mode) const override;
/**
+ * Delete a file specified by its path
+ * @param path Path relative to the archive
+ * @return Whether the file could be deleted
+ */
+ bool DeleteFile(const FileSys::Path& path) const override;
+
+ /**
+ * Delete a directory specified by its path
+ * @param path Path relative to the archive
+ * @return Whether the directory could be deleted
+ */
+ bool DeleteDirectory(const FileSys::Path& path) const override;
+
+ /**
* Create a directory specified by its path
* @param path Path relative to the archive
* @return Whether the directory could be created
diff --git a/src/core/file_sys/archive_sdmc.cpp b/src/core/file_sys/archive_sdmc.cpp
index ecdb7f211..c2ffcd40d 100644
--- a/src/core/file_sys/archive_sdmc.cpp
+++ b/src/core/file_sys/archive_sdmc.cpp
@@ -58,6 +58,24 @@ std::unique_ptr<File> Archive_SDMC::OpenFile(const Path& path, const Mode mode)
}
/**
+ * Delete a file specified by its path
+ * @param path Path relative to the archive
+ * @return Whether the file could be deleted
+ */
+bool Archive_SDMC::DeleteFile(const FileSys::Path& path) const {
+ return FileUtil::Delete(GetMountPoint() + path.AsString());
+}
+
+/**
+ * Delete a directory specified by its path
+ * @param path Path relative to the archive
+ * @return Whether the directory could be deleted
+ */
+bool Archive_SDMC::DeleteDirectory(const FileSys::Path& path) const {
+ return FileUtil::DeleteDir(GetMountPoint() + path.AsString());
+}
+
+/**
* Create a directory specified by its path
* @param path Path relative to the archive
* @return Whether the directory could be created
diff --git a/src/core/file_sys/archive_sdmc.h b/src/core/file_sys/archive_sdmc.h
index 17b9209b4..74ce29c0d 100644
--- a/src/core/file_sys/archive_sdmc.h
+++ b/src/core/file_sys/archive_sdmc.h
@@ -41,6 +41,20 @@ public:
std::unique_ptr<File> OpenFile(const Path& path, const Mode mode) const override;
/**
+ * Delete a file specified by its path
+ * @param path Path relative to the archive
+ * @return Whether the file could be deleted
+ */
+ bool DeleteFile(const FileSys::Path& path) const override;
+
+ /**
+ * Delete a directory specified by its path
+ * @param path Path relative to the archive
+ * @return Whether the directory could be deleted
+ */
+ bool DeleteDirectory(const FileSys::Path& path) const override;
+
+ /**
* Create a directory specified by its path
* @param path Path relative to the archive
* @return Whether the directory could be created