mirror of
https://github.com/crskycode/GARbro.git
synced 2024-11-27 15:44:00 +08:00
(IFileSystem.CombinePath): new method.
This commit is contained in:
parent
72d14c07df
commit
1db7e865cd
@ -35,7 +35,7 @@ namespace GameRes
|
||||
public interface IFileSystem : IDisposable
|
||||
{
|
||||
/// <summary>
|
||||
/// Returns entry corresponding to the given filename within filesystem.
|
||||
/// Returns entry corresponding to the given file or directory within filesystem.
|
||||
/// </summary>
|
||||
/// <exception cref="FileNotFoundException">File is not found.</exception>
|
||||
Entry FindFile (string filename);
|
||||
@ -57,6 +57,11 @@ namespace GameRes
|
||||
/// </summary>
|
||||
IEnumerable<Entry> GetFiles ();
|
||||
|
||||
/// <summary>
|
||||
/// System.IO.Path.Combine() analog.
|
||||
/// </summary>
|
||||
string CombinePath (string path1, string path2);
|
||||
|
||||
/// <summary>
|
||||
/// Recursively enumerates files in the current directory and its subdirectories.
|
||||
/// Subdirectory entries are omitted from resulting set.
|
||||
@ -85,6 +90,11 @@ namespace GameRes
|
||||
set { Directory.SetCurrentDirectory (value); }
|
||||
}
|
||||
|
||||
public string CombinePath (string path1, string path2)
|
||||
{
|
||||
return Path.Combine (path1, path2);
|
||||
}
|
||||
|
||||
public Entry FindFile (string filename)
|
||||
{
|
||||
var attr = File.GetAttributes (filename);
|
||||
@ -215,6 +225,11 @@ namespace GameRes
|
||||
return m_arc.Dir;
|
||||
}
|
||||
|
||||
public virtual string CombinePath (string path1, string path2)
|
||||
{
|
||||
return Path.Combine (path1, path2);
|
||||
}
|
||||
|
||||
#region IDisposable Members
|
||||
bool _arc_disposed = false;
|
||||
|
||||
@ -258,6 +273,11 @@ namespace GameRes
|
||||
set { ChDir (value); }
|
||||
}
|
||||
|
||||
public override string CombinePath (string path1, string path2)
|
||||
{
|
||||
return string.Join (PathDelimiter, path1, path2);
|
||||
}
|
||||
|
||||
public override Entry FindFile (string filename)
|
||||
{
|
||||
Entry entry = null;
|
||||
@ -318,13 +338,16 @@ namespace GameRes
|
||||
private void ChDir (string path)
|
||||
{
|
||||
if (string.IsNullOrEmpty (path))
|
||||
{
|
||||
m_cwd = "";
|
||||
return;
|
||||
}
|
||||
var cur_dir = new List<string>();
|
||||
if (-1 != Array.IndexOf (m_path_delimiters, path[0]))
|
||||
{
|
||||
path = path.TrimStart (m_path_delimiters);
|
||||
}
|
||||
else if (!string.IsNullOrEmpty (m_cwd))
|
||||
else if (".." == path && !string.IsNullOrEmpty (m_cwd))
|
||||
{
|
||||
cur_dir.AddRange (m_cwd.Split (m_path_delimiters));
|
||||
}
|
||||
@ -381,17 +404,14 @@ namespace GameRes
|
||||
{
|
||||
if (entry is SubDirEntry)
|
||||
{
|
||||
if (1 == m_fs_stack.Count)
|
||||
{
|
||||
Top.CurrentDirectory = entry.Name;
|
||||
return;
|
||||
}
|
||||
if (".." == entry.Name && string.IsNullOrEmpty (Top.CurrentDirectory))
|
||||
if (Count > 1 && ".." == entry.Name && string.IsNullOrEmpty (Top.CurrentDirectory))
|
||||
{
|
||||
Pop();
|
||||
return;
|
||||
}
|
||||
Top.CurrentDirectory = entry.Name;
|
||||
else
|
||||
{
|
||||
Top.CurrentDirectory = entry.Name;
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (entry.Name == LastVisitedPath && null != LastVisitedArc)
|
||||
@ -497,6 +517,11 @@ namespace GameRes
|
||||
}
|
||||
}
|
||||
|
||||
public static string CombinePath (string path1, string path2)
|
||||
{
|
||||
return m_vfs.Top.CombinePath (path1, path2);
|
||||
}
|
||||
|
||||
public static Entry FindFile (string filename)
|
||||
{
|
||||
if (".." == filename)
|
||||
|
Loading…
Reference in New Issue
Block a user