aboutsummaryrefslogtreecommitdiff
path: root/src/core/file_sys/disk_archive.cpp
diff options
context:
space:
mode:
authorwwylele <wwylele@gmail.com>2016-10-16 23:09:36 +0800
committerwwylele <wwylele@gmail.com>2016-11-19 17:17:19 +0200
commit4675116401883c3bd0124ea943809916faeace8f (patch)
tree44aa53889179a678a0ec9b0015d83613913c5202 /src/core/file_sys/disk_archive.cpp
parent37d6cbc20058a2f393e52cfede42c6e871b907dc (diff)
FileSys: remove Open from DirectoryBackend
Open should not be an interface exposed by Directory because it is the Archive thats implement the methed to open the directory. The service API of 3DS also implies this - Open is not a function of directory service, but is of FS main service
Diffstat (limited to 'src/core/file_sys/disk_archive.cpp')
-rw-r--r--src/core/file_sys/disk_archive.cpp17
1 files changed, 4 insertions, 13 deletions
diff --git a/src/core/file_sys/disk_archive.cpp b/src/core/file_sys/disk_archive.cpp
index ce6b9360bc..fef6e68a2f 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) {