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

@@ -28,14 +28,15 @@ namespace OpenRA.FileSystem
}
}
readonly Stream s;
public string Name { get; private set; }
public IEnumerable<string> Contents { get { return index.Keys; } }
readonly string filename;
readonly Stream s;
readonly Dictionary<string, Entry> index = new Dictionary<string, Entry>();
public D2kSoundResources(FileSystem context, string filename)
{
this.filename = filename;
Name = filename;
s = context.Open(filename);
try
@@ -56,7 +57,7 @@ namespace OpenRA.FileSystem
}
}
public Stream GetContent(string filename)
public Stream GetStream(string filename)
{
Entry e;
if (!index.TryGetValue(filename, out e))
@@ -66,18 +67,11 @@ namespace OpenRA.FileSystem
return new MemoryStream(s.ReadBytes((int)e.Length));
}
public bool Exists(string filename)
public bool Contains(string filename)
{
return index.ContainsKey(filename);
}
public IEnumerable<string> AllFileNames()
{
return index.Keys;
}
public string Name { get { return filename; } }
public void Dispose()
{
s.Dispose();