diff --git a/GameRes/FileSystem.cs b/GameRes/FileSystem.cs
index b855c3cc..5227f194 100644
--- a/GameRes/FileSystem.cs
+++ b/GameRes/FileSystem.cs
@@ -35,7 +35,7 @@ namespace GameRes
public interface IFileSystem : IDisposable
{
///
- /// Returns entry corresponding to the given filename within filesystem.
+ /// Returns entry corresponding to the given file or directory within filesystem.
///
/// File is not found.
Entry FindFile (string filename);
@@ -57,6 +57,11 @@ namespace GameRes
///
IEnumerable GetFiles ();
+ ///
+ /// System.IO.Path.Combine() analog.
+ ///
+ string CombinePath (string path1, string path2);
+
///
/// 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();
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)