aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/file_sys
diff options
context:
space:
mode:
authorGravatar Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>2014-09-12 00:47:05 +0200
committerGravatar Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>2014-09-17 14:35:46 +0000
commitc14e5713f52cd58f2a8206d844448a8c2d1a54b6 (patch)
tree00b089a33c950107ad161a36b1c17808a85eef88 /src/core/file_sys
parent33b0d1081e27b83408786e83ff7d13a4a2acb45c (diff)
Core: Add a method to obtain a Directory from an Archive.
Diffstat (limited to 'src/core/file_sys')
-rw-r--r--src/core/file_sys/archive.h8
-rw-r--r--src/core/file_sys/archive_romfs.cpp10
-rw-r--r--src/core/file_sys/archive_romfs.h7
-rw-r--r--src/core/file_sys/archive_sdmc.cpp12
-rw-r--r--src/core/file_sys/archive_sdmc.h7
5 files changed, 44 insertions, 0 deletions
diff --git a/src/core/file_sys/archive.h b/src/core/file_sys/archive.h
index 67440ef5..560db6de 100644
--- a/src/core/file_sys/archive.h
+++ b/src/core/file_sys/archive.h
@@ -10,6 +10,7 @@
#include "common/bit_field.h"
#include "core/file_sys/file.h"
+#include "core/file_sys/directory.h"
#include "core/hle/kernel/kernel.h"
@@ -56,6 +57,13 @@ public:
virtual std::unique_ptr<File> OpenFile(const std::string& path, const Mode mode) const = 0;
/**
+ * Open a directory specified by its path
+ * @param path Path relative to the archive
+ * @return Opened directory, or nullptr
+ */
+ virtual std::unique_ptr<Directory> OpenDirectory(const std::string& path) const = 0;
+
+ /**
* Read data from the archive
* @param offset Offset in bytes to start reading data from
* @param length Length in bytes of data to read from archive
diff --git a/src/core/file_sys/archive_romfs.cpp b/src/core/file_sys/archive_romfs.cpp
index 99ded4d8..9bab3471 100644
--- a/src/core/file_sys/archive_romfs.cpp
+++ b/src/core/file_sys/archive_romfs.cpp
@@ -5,6 +5,7 @@
#include "common/common_types.h"
#include "core/file_sys/archive_romfs.h"
+#include "core/file_sys/directory_romfs.h"
#include "core/file_sys/file_romfs.h"
////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -33,6 +34,15 @@ std::unique_ptr<File> Archive_RomFS::OpenFile(const std::string& path, const Mod
}
/**
+ * Open a directory specified by its path
+ * @param path Path relative to the archive
+ * @return Opened directory, or nullptr
+ */
+std::unique_ptr<Directory> Archive_RomFS::OpenDirectory(const std::string& path) const {
+ return std::unique_ptr<Directory>(new Directory_RomFS);
+}
+
+/**
* Read data from the archive
* @param offset Offset in bytes to start reading data from
* @param length Length in bytes of data to read from archive
diff --git a/src/core/file_sys/archive_romfs.h b/src/core/file_sys/archive_romfs.h
index a7669dd7..fcdefa95 100644
--- a/src/core/file_sys/archive_romfs.h
+++ b/src/core/file_sys/archive_romfs.h
@@ -37,6 +37,13 @@ public:
std::unique_ptr<File> OpenFile(const std::string& path, const Mode mode) const override;
/**
+ * Open a directory specified by its path
+ * @param path Path relative to the archive
+ * @return Opened directory, or nullptr
+ */
+ std::unique_ptr<Directory> OpenDirectory(const std::string& path) const override;
+
+ /**
* Read data from the archive
* @param offset Offset in bytes to start reading data from
* @param length Length in bytes of data to read from archive
diff --git a/src/core/file_sys/archive_sdmc.cpp b/src/core/file_sys/archive_sdmc.cpp
index fb155430..30d33be5 100644
--- a/src/core/file_sys/archive_sdmc.cpp
+++ b/src/core/file_sys/archive_sdmc.cpp
@@ -8,6 +8,7 @@
#include "common/file_util.h"
#include "core/file_sys/archive_sdmc.h"
+#include "core/file_sys/directory_sdmc.h"
#include "core/file_sys/file_sdmc.h"
////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -45,6 +46,17 @@ std::unique_ptr<File> Archive_SDMC::OpenFile(const std::string& path, const Mode
}
/**
+ * Open a directory specified by its path
+ * @param path Path relative to the archive
+ * @return Opened directory, or nullptr
+ */
+std::unique_ptr<Directory> Archive_SDMC::OpenDirectory(const std::string& path) const {
+ DEBUG_LOG(FILESYS, "called path=%s", path.c_str());
+ Directory_SDMC* directory = new Directory_SDMC(this, path);
+ return std::unique_ptr<Directory>(directory);
+}
+
+/**
* Read data from the archive
* @param offset Offset in bytes to start reading archive from
* @param length Length in bytes to read data from archive
diff --git a/src/core/file_sys/archive_sdmc.h b/src/core/file_sys/archive_sdmc.h
index 931817e5..946f8b95 100644
--- a/src/core/file_sys/archive_sdmc.h
+++ b/src/core/file_sys/archive_sdmc.h
@@ -37,6 +37,13 @@ public:
std::unique_ptr<File> OpenFile(const std::string& path, const Mode mode) const override;
/**
+ * Open a directory specified by its path
+ * @param path Path relative to the archive
+ * @return Opened directory, or nullptr
+ */
+ std::unique_ptr<Directory> OpenDirectory(const std::string& path) const override;
+
+ /**
* Read data from the archive
* @param offset Offset in bytes to start reading archive from
* @param length Length in bytes to read data from archive