Allow mounted IFolders to be queried.
This commit is contained in:
@@ -18,7 +18,7 @@ namespace OpenRA.FileFormats
|
|||||||
{
|
{
|
||||||
public static class FileSystem
|
public static class FileSystem
|
||||||
{
|
{
|
||||||
static List<IFolder> MountedFolders = new List<IFolder>();
|
public static List<IFolder> MountedFolders = new List<IFolder>();
|
||||||
|
|
||||||
static Cache<uint, List<IFolder>> allFiles = new Cache<uint, List<IFolder>>( _ => new List<IFolder>() );
|
static Cache<uint, List<IFolder>> allFiles = new Cache<uint, List<IFolder>>( _ => new List<IFolder>() );
|
||||||
|
|
||||||
@@ -80,10 +80,8 @@ namespace OpenRA.FileFormats
|
|||||||
if (name.StartsWith("^"))
|
if (name.StartsWith("^"))
|
||||||
name = Platform.SupportDir+name.Substring(1);
|
name = Platform.SupportDir+name.Substring(1);
|
||||||
|
|
||||||
if (Directory.Exists(name))
|
FolderPaths.Add(name);
|
||||||
FolderPaths.Add(name);
|
Action a = () => FileSystem.MountInner(OpenPackage(name));
|
||||||
|
|
||||||
var a = (Action)(() => FileSystem.MountInner(OpenPackage(name)));
|
|
||||||
|
|
||||||
if (optional)
|
if (optional)
|
||||||
try { a(); }
|
try { a(); }
|
||||||
|
|||||||
@@ -17,8 +17,7 @@ namespace OpenRA.FileFormats
|
|||||||
public class Folder : IFolder
|
public class Folder : IFolder
|
||||||
{
|
{
|
||||||
readonly string path;
|
readonly string path;
|
||||||
|
readonly int priority;
|
||||||
int priority;
|
|
||||||
|
|
||||||
// Create a new folder package
|
// Create a new folder package
|
||||||
public Folder(string path, int priority, Dictionary<string, byte[]> contents)
|
public Folder(string path, int priority, Dictionary<string, byte[]> contents)
|
||||||
@@ -65,11 +64,8 @@ namespace OpenRA.FileFormats
|
|||||||
return File.Exists(Path.Combine(path, filename));
|
return File.Exists(Path.Combine(path, filename));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int Priority { get { return priority; } }
|
||||||
public int Priority
|
public string Name { get { return path; } }
|
||||||
{
|
|
||||||
get { return priority; }
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Write(Dictionary<string, byte[]> contents)
|
public void Write(Dictionary<string, byte[]> contents)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -21,10 +21,12 @@ namespace OpenRA.FileFormats
|
|||||||
readonly List<string> filenames;
|
readonly List<string> filenames;
|
||||||
readonly Stream s;
|
readonly Stream s;
|
||||||
readonly long dataStart = 255;
|
readonly long dataStart = 255;
|
||||||
int priority;
|
readonly int priority;
|
||||||
|
readonly string filename;
|
||||||
|
|
||||||
public InstallShieldPackage(string filename, int priority)
|
public InstallShieldPackage(string filename, int priority)
|
||||||
{
|
{
|
||||||
|
this.filename = filename;
|
||||||
this.priority = priority;
|
this.priority = priority;
|
||||||
filenames = new List<string>();
|
filenames = new List<string>();
|
||||||
s = FileSystem.Open(filename);
|
s = FileSystem.Open(filename);
|
||||||
@@ -120,11 +122,8 @@ namespace OpenRA.FileFormats
|
|||||||
return index.ContainsKey(PackageEntry.HashFilename(filename));
|
return index.ContainsKey(PackageEntry.HashFilename(filename));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int Priority { get { return 2000 + priority; }}
|
||||||
public int Priority
|
public string Name { get { return filename; } }
|
||||||
{
|
|
||||||
get { return 2000 + priority; }
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Write(Dictionary<string, byte[]> contents)
|
public void Write(Dictionary<string, byte[]> contents)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ namespace OpenRA.FileFormats
|
|||||||
IEnumerable<string> AllFileNames();
|
IEnumerable<string> AllFileNames();
|
||||||
void Write(Dictionary<string, byte[]> contents);
|
void Write(Dictionary<string, byte[]> contents);
|
||||||
int Priority { get; }
|
int Priority { get; }
|
||||||
|
string Name { get; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class MixFile : IFolder
|
public class MixFile : IFolder
|
||||||
@@ -31,11 +32,13 @@ namespace OpenRA.FileFormats
|
|||||||
readonly Dictionary<uint, PackageEntry> index;
|
readonly Dictionary<uint, PackageEntry> index;
|
||||||
readonly long dataStart;
|
readonly long dataStart;
|
||||||
readonly Stream s;
|
readonly Stream s;
|
||||||
int priority;
|
readonly int priority;
|
||||||
|
readonly string filename;
|
||||||
|
|
||||||
// Save a mix to disk with the given contents
|
// Save a mix to disk with the given contents
|
||||||
public MixFile(string filename, int priority, Dictionary<string, byte[]> contents)
|
public MixFile(string filename, int priority, Dictionary<string, byte[]> contents)
|
||||||
{
|
{
|
||||||
|
this.filename = filename;
|
||||||
this.priority = priority;
|
this.priority = priority;
|
||||||
if (File.Exists(filename))
|
if (File.Exists(filename))
|
||||||
File.Delete(filename);
|
File.Delete(filename);
|
||||||
@@ -48,6 +51,7 @@ namespace OpenRA.FileFormats
|
|||||||
|
|
||||||
public MixFile(string filename, int priority)
|
public MixFile(string filename, int priority)
|
||||||
{
|
{
|
||||||
|
this.filename = filename;
|
||||||
this.priority = priority;
|
this.priority = priority;
|
||||||
s = FileSystem.Open(filename);
|
s = FileSystem.Open(filename);
|
||||||
|
|
||||||
@@ -226,11 +230,9 @@ namespace OpenRA.FileFormats
|
|||||||
return FindMatchingHash(filename).HasValue;
|
return FindMatchingHash(filename).HasValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int Priority
|
public int Priority { get { return 1000 + priority; } }
|
||||||
{
|
public string Name { get { return filename; } }
|
||||||
get { return 1000 + priority; }
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Write(Dictionary<string, byte[]> contents)
|
public void Write(Dictionary<string, byte[]> contents)
|
||||||
{
|
{
|
||||||
// Cannot modify existing mixfile - rename existing file and
|
// Cannot modify existing mixfile - rename existing file and
|
||||||
|
|||||||
@@ -81,10 +81,8 @@ namespace OpenRA.FileFormats
|
|||||||
return pkg.GetEntry(filename) != null;
|
return pkg.GetEntry(filename) != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int Priority
|
public int Priority { get { return 500 + priority; } }
|
||||||
{
|
public string Name { get { return filename; } }
|
||||||
get { return 500 + priority; }
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Write(Dictionary<string, byte[]> contents)
|
public void Write(Dictionary<string, byte[]> contents)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user