Tidy IReadOnlyPackage interface and implementations.

This commit is contained in:
Paul Chote
2016-01-20 23:22:58 +00:00
parent feab81bdea
commit 00945dc9ef
13 changed files with 98 additions and 128 deletions

View File

@@ -18,7 +18,9 @@ namespace OpenRA.FileSystem
public sealed class BigFile : IReadOnlyPackage
{
public string Name { get; private set; }
readonly Dictionary<string, Entry> entries = new Dictionary<string, Entry>();
public IEnumerable<string> Contents { get { return index.Keys; } }
readonly Dictionary<string, Entry> index = new Dictionary<string, Entry>();
readonly Stream s;
public BigFile(FileSystem context, string filename)
@@ -45,7 +47,7 @@ namespace OpenRA.FileSystem
for (var i = 0; i < entryCount; i++)
{
var entry = new Entry(s);
entries.Add(entry.Path, entry);
index.Add(entry.Path, entry);
}
}
catch
@@ -84,19 +86,14 @@ namespace OpenRA.FileSystem
}
}
public Stream GetContent(string filename)
public Stream GetStream(string filename)
{
return entries[filename].GetData();
return index[filename].GetData();
}
public bool Exists(string filename)
public bool Contains(string filename)
{
return entries.ContainsKey(filename);
}
public IEnumerable<string> AllFileNames()
{
return entries.Keys;
return index.ContainsKey(filename);
}
public void Dispose()