Core: Add a method to obtain a Directory from an Archive.
This commit is contained in:
		@@ -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"
 | 
			
		||||
 | 
			
		||||
@@ -55,6 +56,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
 | 
			
		||||
 
 | 
			
		||||
@@ -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"
 | 
			
		||||
 | 
			
		||||
////////////////////////////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
@@ -32,6 +33,15 @@ std::unique_ptr<File> Archive_RomFS::OpenFile(const std::string& path, const Mod
 | 
			
		||||
    return std::unique_ptr<File>(new File_RomFS);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * 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
 | 
			
		||||
 
 | 
			
		||||
@@ -36,6 +36,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
 | 
			
		||||
 
 | 
			
		||||
@@ -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"
 | 
			
		||||
 | 
			
		||||
////////////////////////////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
@@ -44,6 +45,17 @@ std::unique_ptr<File> Archive_SDMC::OpenFile(const std::string& path, const Mode
 | 
			
		||||
    return std::unique_ptr<File>(file);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * 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
 | 
			
		||||
 
 | 
			
		||||
@@ -36,6 +36,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
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user