From 04c90c395d27e6bc205fb2d933ced50e70c1841a Mon Sep 17 00:00:00 2001 From: archshift Date: Tue, 28 Oct 2014 22:52:56 -0700 Subject: Added CreateDirectory function to service/fs.cpp, and in Archive. --- src/core/file_sys/archive.h | 7 +++++++ src/core/file_sys/archive_romfs.cpp | 10 ++++++++++ src/core/file_sys/archive_romfs.h | 7 +++++++ src/core/file_sys/archive_sdmc.cpp | 9 +++++++++ src/core/file_sys/archive_sdmc.h | 7 +++++++ 5 files changed, 40 insertions(+) (limited to 'src/core/file_sys') diff --git a/src/core/file_sys/archive.h b/src/core/file_sys/archive.h index 560db6de..aeabf09a 100644 --- a/src/core/file_sys/archive.h +++ b/src/core/file_sys/archive.h @@ -56,6 +56,13 @@ public: */ virtual std::unique_ptr OpenFile(const std::string& path, const Mode mode) const = 0; + /** + * Create a directory specified by its path + * @param path Path relative to the archive + * @return Whether the directory could be created + */ + virtual bool CreateDirectory(const std::string& path) const = 0; + /** * Open a directory specified by its path * @param path Path relative to the archive diff --git a/src/core/file_sys/archive_romfs.cpp b/src/core/file_sys/archive_romfs.cpp index f101fc72..cc759faa 100644 --- a/src/core/file_sys/archive_romfs.cpp +++ b/src/core/file_sys/archive_romfs.cpp @@ -33,6 +33,16 @@ std::unique_ptr Archive_RomFS::OpenFile(const std::string& path, const Mod return std::unique_ptr(new File_RomFS); } +/** + * Create a directory specified by its path + * @param path Path relative to the archive + * @return Whether the directory could be created + */ +bool Archive_RomFS::CreateDirectory(const std::string& path) const { + ERROR_LOG(FILESYS, "Attempted to create a directory in ROMFS."); + return false; +}; + /** * Open a directory specified by its path * @param path Path relative to the archive diff --git a/src/core/file_sys/archive_romfs.h b/src/core/file_sys/archive_romfs.h index fcdefa95..ae2344e8 100644 --- a/src/core/file_sys/archive_romfs.h +++ b/src/core/file_sys/archive_romfs.h @@ -36,6 +36,13 @@ public: */ std::unique_ptr OpenFile(const std::string& path, const Mode mode) const override; + /** + * Create a directory specified by its path + * @param path Path relative to the archive + * @return Whether the directory could be created + */ + bool CreateDirectory(const std::string& path) const override; + /** * Open a directory specified by its path * @param path Path relative to the archive diff --git a/src/core/file_sys/archive_sdmc.cpp b/src/core/file_sys/archive_sdmc.cpp index 0b647f7d..66931e93 100644 --- a/src/core/file_sys/archive_sdmc.cpp +++ b/src/core/file_sys/archive_sdmc.cpp @@ -57,6 +57,15 @@ std::unique_ptr Archive_SDMC::OpenFile(const std::string& path, const Mode return std::unique_ptr(file); } +/** + * Create a directory specified by its path + * @param path Path relative to the archive + * @return Whether the directory could be created + */ +bool Archive_SDMC::CreateDirectory(const std::string& path) const { + return FileUtil::CreateDir(GetMountPoint() + path); +} + /** * Open a directory specified by its path * @param path Path relative to the archive diff --git a/src/core/file_sys/archive_sdmc.h b/src/core/file_sys/archive_sdmc.h index f68648e6..0e059b63 100644 --- a/src/core/file_sys/archive_sdmc.h +++ b/src/core/file_sys/archive_sdmc.h @@ -40,6 +40,13 @@ public: */ std::unique_ptr OpenFile(const std::string& path, const Mode mode) const override; + /** + * Create a directory specified by its path + * @param path Path relative to the archive + * @return Whether the directory could be created + */ + bool CreateDirectory(const std::string& path) const override; + /** * Open a directory specified by its path * @param path Path relative to the archive -- cgit v1.2.3