summaryrefslogtreecommitdiffstats
path: root/src/core/file_sys
diff options
context:
space:
mode:
authorwwylele <wwylele@gmail.com>2016-10-16 17:09:36 +0200
committerwwylele <wwylele@gmail.com>2016-11-19 16:17:19 +0100
commit0e754875d175bfec393a3f4c4f6ad73f45ed361f (patch)
tree44aa53889179a678a0ec9b0015d83613913c5202 /src/core/file_sys
parentFileSys: add PathParser (diff)
downloadyuzu-0e754875d175bfec393a3f4c4f6ad73f45ed361f.tar
yuzu-0e754875d175bfec393a3f4c4f6ad73f45ed361f.tar.gz
yuzu-0e754875d175bfec393a3f4c4f6ad73f45ed361f.tar.bz2
yuzu-0e754875d175bfec393a3f4c4f6ad73f45ed361f.tar.lz
yuzu-0e754875d175bfec393a3f4c4f6ad73f45ed361f.tar.xz
yuzu-0e754875d175bfec393a3f4c4f6ad73f45ed361f.tar.zst
yuzu-0e754875d175bfec393a3f4c4f6ad73f45ed361f.zip
Diffstat (limited to 'src/core/file_sys')
-rw-r--r--src/core/file_sys/directory_backend.h6
-rw-r--r--src/core/file_sys/disk_archive.cpp17
-rw-r--r--src/core/file_sys/disk_archive.h4
-rw-r--r--src/core/file_sys/ivfc_archive.h3
4 files changed, 5 insertions, 25 deletions
diff --git a/src/core/file_sys/directory_backend.h b/src/core/file_sys/directory_backend.h
index b55e382ef..0c93f2074 100644
--- a/src/core/file_sys/directory_backend.h
+++ b/src/core/file_sys/directory_backend.h
@@ -41,12 +41,6 @@ public:
virtual ~DirectoryBackend() {}
/**
- * Open the directory
- * @return true if the directory opened correctly
- */
- virtual bool Open() = 0;
-
- /**
* List files contained in the directory
* @param count Number of entries to return at once in entries
* @param entries Buffer to read data into
diff --git a/src/core/file_sys/disk_archive.cpp b/src/core/file_sys/disk_archive.cpp
index ce6b9360b..fef6e68a2 100644
--- a/src/core/file_sys/disk_archive.cpp
+++ b/src/core/file_sys/disk_archive.cpp
@@ -112,10 +112,11 @@ ResultCode DiskArchive::RenameDirectory(const Path& src_path, const Path& dest_p
ResultVal<std::unique_ptr<DirectoryBackend>> DiskArchive::OpenDirectory(const Path& path) const {
LOG_DEBUG(Service_FS, "called path=%s", path.DebugStr().c_str());
- auto directory = std::make_unique<DiskDirectory>(*this, path);
- if (!directory->Open())
+ auto full_path = mount_point + path.AsString();
+ if (!FileUtil::IsDirectory(full_path))
return ResultCode(ErrorDescription::FS_NotFound, ErrorModule::FS, ErrorSummary::NotFound,
ErrorLevel::Permanent);
+ auto directory = std::make_unique<DiskDirectory>(full_path);
return MakeResult<std::unique_ptr<DirectoryBackend>>(std::move(directory));
}
@@ -211,21 +212,11 @@ bool DiskFile::Close() const {
////////////////////////////////////////////////////////////////////////////////////////////////////
-DiskDirectory::DiskDirectory(const DiskArchive& archive, const Path& path) : directory() {
- // TODO(Link Mauve): normalize path into an absolute path without "..", it can currently bypass
- // the root directory we set while opening the archive.
- // For example, opening /../../usr/bin can give the emulated program your installed programs.
- this->path = archive.mount_point + path.AsString();
-}
-
-bool DiskDirectory::Open() {
- if (!FileUtil::IsDirectory(path))
- return false;
+DiskDirectory::DiskDirectory(const std::string& path) : directory() {
unsigned size = FileUtil::ScanDirectoryTree(path, directory);
directory.size = size;
directory.isDirectory = true;
children_iterator = directory.children.begin();
- return true;
}
u32 DiskDirectory::Read(const u32 count, Entry* entries) {
diff --git a/src/core/file_sys/disk_archive.h b/src/core/file_sys/disk_archive.h
index 0edd87954..c93c32eb2 100644
--- a/src/core/file_sys/disk_archive.h
+++ b/src/core/file_sys/disk_archive.h
@@ -75,13 +75,12 @@ protected:
class DiskDirectory : public DirectoryBackend {
public:
- DiskDirectory(const DiskArchive& archive, const Path& path);
+ DiskDirectory(const std::string& path);
~DiskDirectory() override {
Close();
}
- bool Open() override;
u32 Read(const u32 count, Entry* entries) override;
bool Close() const override {
@@ -89,7 +88,6 @@ public:
}
protected:
- std::string path;
u32 total_entries_in_directory;
FileUtil::FSTEntry directory;
diff --git a/src/core/file_sys/ivfc_archive.h b/src/core/file_sys/ivfc_archive.h
index af6297e1f..826261441 100644
--- a/src/core/file_sys/ivfc_archive.h
+++ b/src/core/file_sys/ivfc_archive.h
@@ -75,9 +75,6 @@ private:
class IVFCDirectory : public DirectoryBackend {
public:
- bool Open() override {
- return false;
- }
u32 Read(const u32 count, Entry* entries) override {
return 0;
}