Tidy IReadOnlyPackage interface and implementations.
This commit is contained in:
@@ -21,13 +21,15 @@ namespace OpenRA.FileSystem
|
||||
{
|
||||
public sealed class BagFile : IReadOnlyPackage
|
||||
{
|
||||
readonly string bagFilename;
|
||||
public string Name { get; private set; }
|
||||
public IEnumerable<string> Contents { get { return index.Keys; } }
|
||||
|
||||
readonly Stream s;
|
||||
readonly Dictionary<string, IdxEntry> index;
|
||||
|
||||
public BagFile(FileSystem context, string filename)
|
||||
{
|
||||
bagFilename = filename;
|
||||
Name = filename;
|
||||
|
||||
// A bag file is always accompanied with an .idx counterpart
|
||||
// For example: audio.bag requires the audio.idx file
|
||||
@@ -45,9 +47,7 @@ namespace OpenRA.FileSystem
|
||||
s = context.Open(filename);
|
||||
}
|
||||
|
||||
public string Name { get { return bagFilename; } }
|
||||
|
||||
public Stream GetContent(string filename)
|
||||
public Stream GetStream(string filename)
|
||||
{
|
||||
IdxEntry entry;
|
||||
if (!index.TryGetValue(filename, out entry))
|
||||
@@ -113,16 +113,11 @@ namespace OpenRA.FileSystem
|
||||
return mergedStream;
|
||||
}
|
||||
|
||||
public bool Exists(string filename)
|
||||
public bool Contains(string filename)
|
||||
{
|
||||
return index.ContainsKey(filename);
|
||||
}
|
||||
|
||||
public IEnumerable<string> AllFileNames()
|
||||
{
|
||||
return index.Keys;
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
s.Dispose();
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -93,7 +93,7 @@ namespace OpenRA.FileSystem
|
||||
// Package is already mounted
|
||||
// Increment the mount count and bump up the file loading priority
|
||||
mountedPackages[package] = mountCount + 1;
|
||||
foreach (var filename in package.AllFileNames())
|
||||
foreach (var filename in package.Contents)
|
||||
{
|
||||
fileIndex[filename].Remove(package);
|
||||
fileIndex[filename].Add(package);
|
||||
@@ -103,7 +103,7 @@ namespace OpenRA.FileSystem
|
||||
{
|
||||
// Mounting the package for the first time
|
||||
mountedPackages.Add(package, 1);
|
||||
foreach (var filename in package.AllFileNames())
|
||||
foreach (var filename in package.Contents)
|
||||
fileIndex[filename].Add(package);
|
||||
}
|
||||
}
|
||||
@@ -147,10 +147,10 @@ namespace OpenRA.FileSystem
|
||||
Stream GetFromCache(string filename)
|
||||
{
|
||||
var package = fileIndex[filename]
|
||||
.LastOrDefault(x => x.Exists(filename));
|
||||
.LastOrDefault(x => x.Contains(filename));
|
||||
|
||||
if (package != null)
|
||||
return package.GetContent(filename);
|
||||
return package.GetStream(filename);
|
||||
|
||||
return null;
|
||||
}
|
||||
@@ -192,11 +192,11 @@ namespace OpenRA.FileSystem
|
||||
if (explicitPackage && !string.IsNullOrEmpty(packageName))
|
||||
package = mountedPackages.Keys.LastOrDefault(x => x.Name == packageName);
|
||||
else
|
||||
package = mountedPackages.Keys.LastOrDefault(x => x.Exists(filename));
|
||||
package = mountedPackages.Keys.LastOrDefault(x => x.Contains(filename));
|
||||
|
||||
if (package != null)
|
||||
{
|
||||
s = package.GetContent(filename);
|
||||
s = package.GetStream(filename);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -212,10 +212,10 @@ namespace OpenRA.FileSystem
|
||||
var divide = name.Split(':');
|
||||
var packageName = divide.First();
|
||||
var filename = divide.Last();
|
||||
return mountedPackages.Keys.Where(n => n.Name == packageName).Any(f => f.Exists(filename));
|
||||
return mountedPackages.Keys.Where(n => n.Name == packageName).Any(f => f.Contains(filename));
|
||||
}
|
||||
else
|
||||
return mountedPackages.Keys.Any(f => f.Exists(name));
|
||||
return mountedPackages.Keys.Any(f => f.Contains(name));
|
||||
}
|
||||
|
||||
public static Assembly ResolveAssembly(object sender, ResolveEventArgs e)
|
||||
|
||||
@@ -34,25 +34,28 @@ namespace OpenRA.FileSystem
|
||||
Directory.CreateDirectory(path);
|
||||
}
|
||||
|
||||
public Stream GetContent(string filename)
|
||||
public string Name { get { return path; } }
|
||||
|
||||
public IEnumerable<string> Contents
|
||||
{
|
||||
get
|
||||
{
|
||||
foreach (var filename in Directory.GetFiles(path, "*", SearchOption.TopDirectoryOnly))
|
||||
yield return Path.GetFileName(filename);
|
||||
}
|
||||
}
|
||||
|
||||
public Stream GetStream(string filename)
|
||||
{
|
||||
try { return File.OpenRead(Path.Combine(path, filename)); }
|
||||
catch { return null; }
|
||||
}
|
||||
|
||||
public IEnumerable<string> AllFileNames()
|
||||
{
|
||||
foreach (var filename in Directory.GetFiles(path, "*", SearchOption.TopDirectoryOnly))
|
||||
yield return Path.GetFileName(filename);
|
||||
}
|
||||
|
||||
public bool Exists(string filename)
|
||||
public bool Contains(string filename)
|
||||
{
|
||||
return File.Exists(Path.Combine(path, filename));
|
||||
}
|
||||
|
||||
public string Name { get { return path; } }
|
||||
|
||||
public void Write(Dictionary<string, byte[]> contents)
|
||||
{
|
||||
if (!Directory.Exists(path))
|
||||
|
||||
@@ -16,10 +16,10 @@ namespace OpenRA.FileSystem
|
||||
{
|
||||
public interface IReadOnlyPackage : IDisposable
|
||||
{
|
||||
Stream GetContent(string filename);
|
||||
bool Exists(string filename);
|
||||
IEnumerable<string> AllFileNames();
|
||||
string Name { get; }
|
||||
IEnumerable<string> Contents { get; }
|
||||
Stream GetStream(string filename);
|
||||
bool Contains(string filename);
|
||||
}
|
||||
|
||||
public interface IReadWritePackage : IReadOnlyPackage
|
||||
|
||||
@@ -329,11 +329,11 @@ namespace OpenRA.FileSystem
|
||||
readonly List<uint> directoryTable;
|
||||
readonly Dictionary<uint, string> directoryNames = new Dictionary<uint, string>();
|
||||
readonly Dictionary<uint, FileDescriptor> fileDescriptors = new Dictionary<uint, FileDescriptor>();
|
||||
readonly Dictionary<string, uint> fileLookup = new Dictionary<string, uint>();
|
||||
readonly Dictionary<string, uint> index = new Dictionary<string, uint>();
|
||||
readonly FileSystem context;
|
||||
string commonName;
|
||||
|
||||
public string Name { get { return commonName; } }
|
||||
public string Name { get; private set; }
|
||||
public IEnumerable<string> Contents { get { return index.Keys; } }
|
||||
|
||||
public InstallShieldCABExtractor(FileSystem context, string hdrFilename)
|
||||
{
|
||||
@@ -344,7 +344,7 @@ namespace OpenRA.FileSystem
|
||||
this.context = context;
|
||||
|
||||
// Strips archive number AND file extension
|
||||
commonName = Regex.Replace(hdrFilename, @"\d*\.[^\.]*$", "");
|
||||
Name = Regex.Replace(hdrFilename, @"\d*\.[^\.]*$", "");
|
||||
var signature = hdrFile.ReadUInt32();
|
||||
|
||||
if (signature != 0x28635349)
|
||||
@@ -380,12 +380,12 @@ namespace OpenRA.FileSystem
|
||||
hdrFile.Seek(commonHeader.CabDescriptorOffset + cabDescriptor.FileTableOffset + cabDescriptor.FileTableOffset2, SeekOrigin.Begin);
|
||||
foreach (var fileGroup in fileGroups)
|
||||
{
|
||||
for (var index = fileGroup.FirstFile; index <= fileGroup.LastFile; ++index)
|
||||
for (var i = fileGroup.FirstFile; i <= fileGroup.LastFile; ++i)
|
||||
{
|
||||
AddFileDescriptorToList(index);
|
||||
var fileDescriptor = fileDescriptors[index];
|
||||
AddFileDescriptorToList(i);
|
||||
var fileDescriptor = fileDescriptors[i];
|
||||
var fullFilePath = "{0}\\{1}\\{2}".F(fileGroup.Name, DirectoryName(fileDescriptor.DirectoryIndex), fileDescriptor.Filename);
|
||||
fileLookup.Add(fullFilePath, index);
|
||||
index.Add(fullFilePath, i);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -404,9 +404,9 @@ namespace OpenRA.FileSystem
|
||||
return test;
|
||||
}
|
||||
|
||||
public bool Exists(string filename)
|
||||
public bool Contains(string filename)
|
||||
{
|
||||
return fileLookup.ContainsKey(filename);
|
||||
return index.ContainsKey(filename);
|
||||
}
|
||||
|
||||
public uint DirectoryCount()
|
||||
@@ -462,7 +462,7 @@ namespace OpenRA.FileSystem
|
||||
|
||||
var output = new MemoryStream((int)fileDes.ExpandedSize);
|
||||
|
||||
using (var reader = new CabReader(context, fileDes, index, commonName))
|
||||
using (var reader = new CabReader(context, fileDes, index, Name))
|
||||
reader.CopyTo(output);
|
||||
|
||||
if (output.Length != fileDes.ExpandedSize)
|
||||
@@ -487,21 +487,16 @@ namespace OpenRA.FileSystem
|
||||
if ((fileDes.Flags & FileObfuscated) != 0)
|
||||
throw new NotImplementedException("Haven't implemented obfuscated files");
|
||||
|
||||
using (var reader = new CabReader(context, fileDes, index, commonName))
|
||||
using (var reader = new CabReader(context, fileDes, index, Name))
|
||||
reader.CopyTo(output);
|
||||
|
||||
if (output.Length != fileDes.ExpandedSize)
|
||||
throw new Exception("Did not fully extract Expected = {0}, Got = {1}".F(fileDes.ExpandedSize, output.Length));
|
||||
}
|
||||
|
||||
public Stream GetContent(string fileName)
|
||||
public Stream GetStream(string fileName)
|
||||
{
|
||||
return GetContentById(fileLookup[fileName]);
|
||||
}
|
||||
|
||||
public IEnumerable<string> AllFileNames()
|
||||
{
|
||||
return fileLookup.Keys;
|
||||
return GetContentById(index[fileName]);
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
|
||||
@@ -29,14 +29,16 @@ namespace OpenRA.FileSystem
|
||||
}
|
||||
}
|
||||
|
||||
public string Name { get; private set; }
|
||||
public IEnumerable<string> Contents { get { return index.Keys; } }
|
||||
|
||||
readonly Dictionary<string, Entry> index = new Dictionary<string, Entry>();
|
||||
readonly Stream s;
|
||||
readonly long dataStart = 255;
|
||||
readonly string filename;
|
||||
|
||||
public InstallShieldPackage(FileSystem context, string filename)
|
||||
{
|
||||
this.filename = filename;
|
||||
Name = filename;
|
||||
|
||||
s = context.Open(filename);
|
||||
try
|
||||
@@ -104,7 +106,7 @@ namespace OpenRA.FileSystem
|
||||
s.Position += chunkSize - nameLength - 30;
|
||||
}
|
||||
|
||||
public Stream GetContent(string filename)
|
||||
public Stream GetStream(string filename)
|
||||
{
|
||||
Entry e;
|
||||
if (!index.TryGetValue(filename, out e))
|
||||
@@ -116,18 +118,11 @@ namespace OpenRA.FileSystem
|
||||
return new MemoryStream(Blast.Decompress(data));
|
||||
}
|
||||
|
||||
public IEnumerable<string> AllFileNames()
|
||||
{
|
||||
return index.Keys;
|
||||
}
|
||||
|
||||
public bool Exists(string filename)
|
||||
public bool Contains(string filename)
|
||||
{
|
||||
return index.ContainsKey(filename);
|
||||
}
|
||||
|
||||
public string Name { get { return filename; } }
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
s.Dispose();
|
||||
|
||||
@@ -21,6 +21,7 @@ namespace OpenRA.FileSystem
|
||||
public sealed class MixFile : IReadOnlyPackage
|
||||
{
|
||||
public string Name { get; private set; }
|
||||
public IEnumerable<string> Contents { get { return index.Keys; } }
|
||||
|
||||
readonly Dictionary<string, PackageEntry> index;
|
||||
readonly long dataStart;
|
||||
@@ -192,7 +193,7 @@ namespace OpenRA.FileSystem
|
||||
return new SegmentStream(File.OpenRead(path), offset, entry.Length);
|
||||
}
|
||||
|
||||
public Stream GetContent(string filename)
|
||||
public Stream GetStream(string filename)
|
||||
{
|
||||
PackageEntry e;
|
||||
if (!index.TryGetValue(filename, out e))
|
||||
@@ -201,12 +202,7 @@ namespace OpenRA.FileSystem
|
||||
return GetContent(e);
|
||||
}
|
||||
|
||||
public IEnumerable<string> AllFileNames()
|
||||
{
|
||||
return index.Keys;
|
||||
}
|
||||
|
||||
public bool Exists(string filename)
|
||||
public bool Contains(string filename)
|
||||
{
|
||||
return index.ContainsKey(filename);
|
||||
}
|
||||
|
||||
@@ -22,13 +22,15 @@ namespace OpenRA.FileSystem
|
||||
|
||||
public sealed class PakFile : IReadOnlyPackage
|
||||
{
|
||||
readonly string filename;
|
||||
public string Name { get; private set; }
|
||||
public IEnumerable<string> Contents { get { return index.Keys; } }
|
||||
|
||||
readonly Dictionary<string, Entry> index;
|
||||
readonly Stream stream;
|
||||
|
||||
public PakFile(FileSystem context, string filename)
|
||||
{
|
||||
this.filename = filename;
|
||||
Name = filename;
|
||||
index = new Dictionary<string, Entry>();
|
||||
|
||||
stream = context.Open(filename);
|
||||
@@ -57,7 +59,7 @@ namespace OpenRA.FileSystem
|
||||
}
|
||||
}
|
||||
|
||||
public Stream GetContent(string filename)
|
||||
public Stream GetStream(string filename)
|
||||
{
|
||||
Entry entry;
|
||||
if (!index.TryGetValue(filename, out entry))
|
||||
@@ -68,19 +70,11 @@ namespace OpenRA.FileSystem
|
||||
return new MemoryStream(data);
|
||||
}
|
||||
|
||||
public IEnumerable<string> AllFileNames()
|
||||
{
|
||||
foreach (var filename in index.Keys)
|
||||
yield return filename;
|
||||
}
|
||||
|
||||
public bool Exists(string filename)
|
||||
public bool Contains(string filename)
|
||||
{
|
||||
return index.ContainsKey(filename);
|
||||
}
|
||||
|
||||
public string Name { get { return filename; } }
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
stream.Dispose();
|
||||
|
||||
@@ -18,7 +18,7 @@ namespace OpenRA.FileSystem
|
||||
{
|
||||
public sealed class ZipFile : IReadWritePackage
|
||||
{
|
||||
readonly string filename;
|
||||
public string Name { get; private set; }
|
||||
SZipFile pkg;
|
||||
|
||||
static ZipFile()
|
||||
@@ -28,7 +28,7 @@ namespace OpenRA.FileSystem
|
||||
|
||||
public ZipFile(FileSystem context, string filename)
|
||||
{
|
||||
this.filename = filename;
|
||||
Name = filename;
|
||||
|
||||
try
|
||||
{
|
||||
@@ -44,7 +44,7 @@ namespace OpenRA.FileSystem
|
||||
// Create a new zip with the specified contents.
|
||||
public ZipFile(FileSystem context, string filename, Dictionary<string, byte[]> contents)
|
||||
{
|
||||
this.filename = filename;
|
||||
Name = filename;
|
||||
|
||||
if (File.Exists(filename))
|
||||
File.Delete(filename);
|
||||
@@ -53,7 +53,7 @@ namespace OpenRA.FileSystem
|
||||
Write(contents);
|
||||
}
|
||||
|
||||
public Stream GetContent(string filename)
|
||||
public Stream GetStream(string filename)
|
||||
{
|
||||
var entry = pkg.GetEntry(filename);
|
||||
if (entry == null)
|
||||
@@ -68,24 +68,25 @@ namespace OpenRA.FileSystem
|
||||
}
|
||||
}
|
||||
|
||||
public IEnumerable<string> AllFileNames()
|
||||
public IEnumerable<string> Contents
|
||||
{
|
||||
foreach (ZipEntry entry in pkg)
|
||||
yield return entry.Name;
|
||||
get
|
||||
{
|
||||
foreach (ZipEntry entry in pkg)
|
||||
yield return entry.Name;
|
||||
}
|
||||
}
|
||||
|
||||
public bool Exists(string filename)
|
||||
public bool Contains(string filename)
|
||||
{
|
||||
return pkg.GetEntry(filename) != null;
|
||||
}
|
||||
|
||||
public string Name { get { return filename; } }
|
||||
|
||||
public void Write(Dictionary<string, byte[]> contents)
|
||||
{
|
||||
// TODO: Clear existing content?
|
||||
pkg.Close();
|
||||
pkg = SZipFile.Create(filename);
|
||||
pkg = SZipFile.Create(Name);
|
||||
pkg.BeginUpdate();
|
||||
|
||||
foreach (var kvp in contents)
|
||||
@@ -93,7 +94,7 @@ namespace OpenRA.FileSystem
|
||||
|
||||
pkg.CommitUpdate();
|
||||
pkg.Close();
|
||||
pkg = new SZipFile(new MemoryStream(File.ReadAllBytes(filename)));
|
||||
pkg = new SZipFile(new MemoryStream(File.ReadAllBytes(Name)));
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
|
||||
@@ -263,7 +263,7 @@ namespace OpenRA
|
||||
|
||||
void AssertExists(string filename)
|
||||
{
|
||||
using (var s = Container.GetContent(filename))
|
||||
using (var s = Container.GetStream(filename))
|
||||
if (s == null)
|
||||
throw new InvalidOperationException("Required file {0} not present in this map".F(filename));
|
||||
}
|
||||
@@ -321,7 +321,7 @@ namespace OpenRA
|
||||
AssertExists("map.yaml");
|
||||
AssertExists("map.bin");
|
||||
|
||||
var yaml = new MiniYaml(null, MiniYaml.FromStream(Container.GetContent("map.yaml"), path));
|
||||
var yaml = new MiniYaml(null, MiniYaml.FromStream(Container.GetStream("map.yaml"), path));
|
||||
FieldLoader.Load(this, yaml);
|
||||
|
||||
// Support for formats 1-3 dropped 2011-02-11.
|
||||
@@ -427,8 +427,8 @@ namespace OpenRA
|
||||
LastSubCell = (SubCell)(SubCellOffsets.Length - 1);
|
||||
DefaultSubCell = (SubCell)Grid.SubCellDefaultIndex;
|
||||
|
||||
if (Container.Exists("map.png"))
|
||||
using (var dataStream = Container.GetContent("map.png"))
|
||||
if (Container.Contains("map.png"))
|
||||
using (var dataStream = Container.GetStream("map.png"))
|
||||
CustomPreview = new Bitmap(dataStream);
|
||||
|
||||
PostInit();
|
||||
@@ -634,12 +634,12 @@ namespace OpenRA
|
||||
// Add any custom assets
|
||||
if (Container != null)
|
||||
{
|
||||
foreach (var file in Container.AllFileNames())
|
||||
foreach (var file in Container.Contents)
|
||||
{
|
||||
if (file == "map.bin" || file == "map.yaml")
|
||||
continue;
|
||||
|
||||
entries.Add(file, Container.GetContent(file).ReadAllBytes());
|
||||
entries.Add(file, Container.GetStream(file).ReadAllBytes());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -662,7 +662,7 @@ namespace OpenRA
|
||||
public CellLayer<TerrainTile> LoadMapTiles()
|
||||
{
|
||||
var tiles = new CellLayer<TerrainTile>(this);
|
||||
using (var s = Container.GetContent("map.bin"))
|
||||
using (var s = Container.GetStream("map.bin"))
|
||||
{
|
||||
var header = new BinaryDataHeader(s, MapSize);
|
||||
if (header.TilesOffset > 0)
|
||||
@@ -694,7 +694,7 @@ namespace OpenRA
|
||||
public CellLayer<byte> LoadMapHeight()
|
||||
{
|
||||
var tiles = new CellLayer<byte>(this);
|
||||
using (var s = Container.GetContent("map.bin"))
|
||||
using (var s = Container.GetStream("map.bin"))
|
||||
{
|
||||
var header = new BinaryDataHeader(s, MapSize);
|
||||
if (header.HeightsOffset > 0)
|
||||
@@ -716,7 +716,7 @@ namespace OpenRA
|
||||
{
|
||||
var resources = new CellLayer<ResourceTile>(this);
|
||||
|
||||
using (var s = Container.GetContent("map.bin"))
|
||||
using (var s = Container.GetStream("map.bin"))
|
||||
{
|
||||
var header = new BinaryDataHeader(s, MapSize);
|
||||
if (header.ResourcesOffset > 0)
|
||||
@@ -968,9 +968,9 @@ namespace OpenRA
|
||||
using (var ms = new MemoryStream())
|
||||
{
|
||||
// Read the relevant data into the buffer
|
||||
using (var s = Container.GetContent("map.yaml"))
|
||||
using (var s = Container.GetStream("map.yaml"))
|
||||
s.CopyTo(ms);
|
||||
using (var s = Container.GetContent("map.bin"))
|
||||
using (var s = Container.GetStream("map.bin"))
|
||||
s.CopyTo(ms);
|
||||
|
||||
// Take the SHA1
|
||||
|
||||
@@ -361,7 +361,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
if (assetSource == null)
|
||||
return;
|
||||
|
||||
var files = assetSource.AllFileNames().OrderBy(s => s);
|
||||
var files = assetSource.Contents.OrderBy(s => s);
|
||||
foreach (var file in files)
|
||||
{
|
||||
if (allowedExtensions.Any(ext => file.EndsWith(ext, true, CultureInfo.InvariantCulture)))
|
||||
|
||||
Reference in New Issue
Block a user