Skip to content
Permalink
Browse files
Merge pull request #9306 from JosJuice/recursive-extract
DiscIO: Fix recursive directory extraction
  • Loading branch information
lioncash committed Dec 3, 2020
2 parents dbc0fd1 + b43f7c8 commit a34823d
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 3 deletions.
@@ -130,8 +130,10 @@ void ExportDirectory(const Volume& volume, const Partition& partition, const Fil
const std::string& export_folder,
const std::function<bool(const std::string& path)>& update_progress)
{
const std::string export_root =
export_folder + (directory.IsDirectory() ? "/" + directory.GetName() + "/" : "/");
std::string export_root = export_folder + '/';
if (directory.IsDirectory() && !directory.IsRoot())
export_root += directory.GetName() + '/';

File::CreateFullPath(export_root);

for (const FileInfo& file_info : directory)
@@ -154,7 +156,8 @@ void ExportDirectory(const Volume& volume, const Partition& partition, const Fil
}
else if (recursive)
{
ExportDirectory(volume, partition, file_info, recursive, path, export_path, update_progress);
ExportDirectory(volume, partition, file_info, recursive, filesystem_path, export_root,
update_progress);
}
}
}
@@ -96,6 +96,11 @@ u64 FileInfoGCWii::GetOffset() const
return static_cast<u64>(Get(EntryProperty::FILE_OFFSET)) << m_offset_shift;
}

bool FileInfoGCWii::IsRoot() const
{
return m_index == 0;
}

bool FileInfoGCWii::IsDirectory() const
{
return (Get(EntryProperty::NAME_OFFSET) & 0xFF000000) != 0;
@@ -42,6 +42,7 @@ class FileInfoGCWii : public FileInfo

u64 GetOffset() const override;
u32 GetSize() const override;
bool IsRoot() const override;
bool IsDirectory() const override;
u32 GetTotalChildren() const override;
std::string GetName() const override;
@@ -89,6 +89,7 @@ class FileInfo
virtual u32 GetSize() const = 0;
// For a file, returns its size. For a directory, returns the total size of its contents.
u64 GetTotalSize() const;
virtual bool IsRoot() const = 0;
virtual bool IsDirectory() const = 0;
// The number of files and directories in a directory, including those in subdirectories.
// Not guaranteed to return a meaningful value for files.

0 comments on commit a34823d

Please sign in to comment.