Skip to content

Commit

Permalink
chroot merge and zip FS
Browse files Browse the repository at this point in the history
  • Loading branch information
olduh29 committed May 16, 2023
1 parent baccc90 commit 8be7b87
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion SharpCoreFileSystem/FileSystems/AbstractFileSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public ICollection<FileSystemPath> GetFiles(FileSystemPath path)



public void ChRoot(FileSystemPath newRoot)
public virtual void ChRoot(FileSystemPath newRoot)
{
Root = newRoot;
}
Expand Down
9 changes: 9 additions & 0 deletions SharpCoreFileSystem/FileSystems/MergedFileSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -83,5 +83,14 @@ public override void Delete(FileSystemPath path)
foreach(var fs in FileSystems.Where(fs => fs.Exists(path)))
fs.Delete(path);
}

public override void ChRoot(FileSystemPath root)
{
Root = root;
foreach (var fileSystem in FileSystems)
{
fileSystem.ChRoot(root);
}
}
}
}
6 changes: 6 additions & 0 deletions SharpCoreFileSystem/FileSystems/NetZipArchiveFileSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,12 @@ protected FileSystemPath ToPath(ZipArchiveEntry entry)
protected string ToEntryPath(FileSystemPath path)
{
// Remove heading '/' from path.
string rootedPath = path;
if (!Root.IsRoot)
{
rootedPath = Path.Combine(Root, path);
}

return path.Path.TrimStart(FileSystemPath.DirectorySeparator);
}

Expand Down

0 comments on commit 8be7b87

Please sign in to comment.