mirror of
https://github.com/crskycode/GARbro.git
synced 2025-01-11 20:39:29 +08:00
TreeArchiveFileSystem fixes.
This commit is contained in:
parent
67b24e5823
commit
a06bae057e
@ -308,6 +308,12 @@ namespace GameRes
|
|||||||
|
|
||||||
public override string CombinePath (string path1, string path2)
|
public override string CombinePath (string path1, string path2)
|
||||||
{
|
{
|
||||||
|
if (0 == path1.Length)
|
||||||
|
return path2;
|
||||||
|
if (0 == path2.Length)
|
||||||
|
return path1;
|
||||||
|
if (path1.EndsWith (PathDelimiter))
|
||||||
|
return path1+path2;
|
||||||
return string.Join (PathDelimiter, path1, path2);
|
return string.Join (PathDelimiter, path1, path2);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -325,19 +331,11 @@ namespace GameRes
|
|||||||
|
|
||||||
public override IEnumerable<Entry> GetFiles ()
|
public override IEnumerable<Entry> GetFiles ()
|
||||||
{
|
{
|
||||||
var root_dir = "";
|
IEnumerable<Entry> dir = GetFilesRecursive();
|
||||||
IEnumerable<Entry> dir = m_arc.Dir;
|
var root_dir = m_cwd;
|
||||||
if (!string.IsNullOrEmpty (m_cwd))
|
if (!string.IsNullOrEmpty (root_dir))
|
||||||
{
|
root_dir += PathDelimiter;
|
||||||
root_dir = m_cwd+PathDelimiter;
|
|
||||||
dir = from entry in dir
|
|
||||||
where entry.Name.StartsWith (root_dir)
|
|
||||||
select entry;
|
|
||||||
if (!dir.Any())
|
|
||||||
{
|
|
||||||
throw new DirectoryNotFoundException();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
var subdirs = new HashSet<string>();
|
var subdirs = new HashSet<string>();
|
||||||
foreach (var entry in dir)
|
foreach (var entry in dir)
|
||||||
{
|
{
|
||||||
@ -368,6 +366,23 @@ namespace GameRes
|
|||||||
select file;
|
select file;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public IEnumerable<Entry> GetFilesRecursive (IEnumerable<Entry> list)
|
||||||
|
{
|
||||||
|
var result = new List<Entry>();
|
||||||
|
foreach (var entry in list)
|
||||||
|
{
|
||||||
|
if (!(entry is SubDirEntry)) // add ordinary file
|
||||||
|
result.Add (entry);
|
||||||
|
else if (".." == entry.Name) // skip reference to parent directory
|
||||||
|
continue;
|
||||||
|
else // add all files contained within directory, recursive
|
||||||
|
result.AddRange (from file in m_arc.Dir
|
||||||
|
where file.Name.StartsWith (entry.Name+PathDelimiter)
|
||||||
|
select file);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
private void ChDir (string path)
|
private void ChDir (string path)
|
||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty (path))
|
if (string.IsNullOrEmpty (path))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user