diff options
author | Subv <subv2112@gmail.com> | 2015-12-25 17:03:59 -0500 |
---|---|---|
committer | Subv <subv2112@gmail.com> | 2016-01-16 09:30:29 -0500 |
commit | 922b31ebbdc6d8cbfe76bebbaa158cf16b9e7b0c (patch) | |
tree | ac25404691b21304bb30b3e400da97b6c5671b76 | |
parent | 7b2d03476985ca3747350d195c32654a371ee85b (diff) |
DiskDirectory: Initialize the directory member with valid info.
-rw-r--r-- | src/common/file_util.cpp | 2 | ||||
-rw-r--r-- | src/core/file_sys/disk_archive.cpp | 6 |
2 files changed, 5 insertions, 3 deletions
diff --git a/src/common/file_util.cpp b/src/common/file_util.cpp index 052c0ecd68..c3061479ab 100644 --- a/src/common/file_util.cpp +++ b/src/common/file_util.cpp @@ -457,7 +457,7 @@ bool ForeachDirectoryEntry(unsigned* num_entries_out, const std::string &directo if (virtual_name == "." || virtual_name == "..") continue; - unsigned ret_entries; + unsigned ret_entries = 0; if (!callback(&ret_entries, directory, virtual_name)) { callback_error = true; break; diff --git a/src/core/file_sys/disk_archive.cpp b/src/core/file_sys/disk_archive.cpp index 0ba5022003..a51416774c 100644 --- a/src/core/file_sys/disk_archive.cpp +++ b/src/core/file_sys/disk_archive.cpp @@ -139,7 +139,7 @@ bool DiskFile::Close() const { //////////////////////////////////////////////////////////////////////////////////////////////////// -DiskDirectory::DiskDirectory(const DiskArchive& archive, const Path& path) { +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. @@ -149,7 +149,9 @@ DiskDirectory::DiskDirectory(const DiskArchive& archive, const Path& path) { bool DiskDirectory::Open() { if (!FileUtil::IsDirectory(path)) return false; - FileUtil::ScanDirectoryTree(path, directory); + unsigned size = FileUtil::ScanDirectoryTree(path, directory); + directory.size = size; + directory.isDirectory = true; children_iterator = directory.children.begin(); return true; } |