Introduce IReadOnlyFileSystem interface.
This commit is contained in:
@@ -17,7 +17,15 @@ using OpenRA.Primitives;
|
|||||||
|
|
||||||
namespace OpenRA.FileSystem
|
namespace OpenRA.FileSystem
|
||||||
{
|
{
|
||||||
public class FileSystem
|
public interface IReadOnlyFileSystem
|
||||||
|
{
|
||||||
|
Stream Open(string filename);
|
||||||
|
bool TryGetPackageContaining(string path, out IReadOnlyPackage package, out string filename);
|
||||||
|
bool TryOpen(string filename, out Stream s);
|
||||||
|
bool Exists(string filename);
|
||||||
|
}
|
||||||
|
|
||||||
|
public class FileSystem : IReadOnlyFileSystem
|
||||||
{
|
{
|
||||||
public IEnumerable<IReadOnlyPackage> MountedPackages { get { return mountedPackages.Keys; } }
|
public IEnumerable<IReadOnlyPackage> MountedPackages { get { return mountedPackages.Keys; } }
|
||||||
readonly Dictionary<IReadOnlyPackage, int> mountedPackages = new Dictionary<IReadOnlyPackage, int>();
|
readonly Dictionary<IReadOnlyPackage, int> mountedPackages = new Dictionary<IReadOnlyPackage, int>();
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ using System.Collections.Generic;
|
|||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
|
using OpenRA.FileSystem;
|
||||||
using OpenRA.Graphics;
|
using OpenRA.Graphics;
|
||||||
using OpenRA.Widgets;
|
using OpenRA.Widgets;
|
||||||
using FS = OpenRA.FileSystem.FileSystem;
|
using FS = OpenRA.FileSystem.FileSystem;
|
||||||
@@ -36,6 +37,7 @@ namespace OpenRA
|
|||||||
|
|
||||||
readonly Lazy<Ruleset> defaultRules;
|
readonly Lazy<Ruleset> defaultRules;
|
||||||
public Ruleset DefaultRules { get { return defaultRules.Value; } }
|
public Ruleset DefaultRules { get { return defaultRules.Value; } }
|
||||||
|
public IReadOnlyFileSystem DefaultFileSystem { get { return ModFiles; } }
|
||||||
|
|
||||||
public ModData(string mod, bool useLoadScreen = false)
|
public ModData(string mod, bool useLoadScreen = false)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user