diff options
| author | archshift <admin@archshift.com> | 2014-12-07 14:40:27 -0800 |
|---|---|---|
| committer | archshift <admin@archshift.com> | 2014-12-07 14:47:14 -0800 |
| commit | 20d2ed09502f41519beb435a1300f2a57995c651 (patch) | |
| tree | 4d58349bdfc1ab122d522780c1d9692832ce9ad0 /src/core/file_sys/directory_sdmc.cpp | |
| parent | 17fae11fc7cf9392bb93dd2a1dc26a479ca75ed1 (diff) | |
Make OpenDirectory fail if the directory doesn't exist
This is in line with what the hardware itself does.
It does this by splitting the initial directory opening into Directory.Open(), which will return false if a stat fails.
Then, Archive::OpenDirectory will return nullptr, and archive.cpp will return an error code .
Diffstat (limited to 'src/core/file_sys/directory_sdmc.cpp')
| -rw-r--r-- | src/core/file_sys/directory_sdmc.cpp | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/src/core/file_sys/directory_sdmc.cpp b/src/core/file_sys/directory_sdmc.cpp index 60a197ce9..0f156a127 100644 --- a/src/core/file_sys/directory_sdmc.cpp +++ b/src/core/file_sys/directory_sdmc.cpp @@ -19,15 +19,22 @@ Directory_SDMC::Directory_SDMC(const Archive_SDMC* archive, const Path& path) { // 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. - std::string absolute_path = archive->GetMountPoint() + path.AsString(); - FileUtil::ScanDirectoryTree(absolute_path, directory); - children_iterator = directory.children.begin(); + this->path = archive->GetMountPoint() + path.AsString(); + } Directory_SDMC::~Directory_SDMC() { Close(); } +bool Directory_SDMC::Open() { + if (!FileUtil::IsDirectory(path)) + return false; + FileUtil::ScanDirectoryTree(path, directory); + children_iterator = directory.children.begin(); + return true; +} + /** * List files contained in the directory * @param count Number of entries to return at once in entries |
