beginnings of removing rampant ../../../ from sources

git-svn-id: svn://svn.ijw.co.nz/svn/OpenRa@1318 993157c7-ee19-0410-b2c4-bb4e9862e678
This commit is contained in:
(no author)
2007-07-21 04:16:15 +00:00
parent c331e190a7
commit dde1852b12
11 changed files with 64 additions and 30 deletions

40
OpenRa.Game/FileSystem.cs Normal file
View File

@@ -0,0 +1,40 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
using OpenRa.FileFormats;
namespace OpenRa.Game
{
class Folder : IFolder
{
readonly string path;
public Folder(string path) { this.path = path; }
public Stream GetContent(string filename)
{
try { return File.OpenRead(path + filename); }
catch { throw new FileNotFoundException("File not found", filename); }
}
}
static class FileSystem
{
static List<IFolder> mountedFolders = new List<IFolder>();
public static void Mount(IFolder folder)
{
mountedFolders.Add(folder);
}
public static Stream Open(string filename)
{
foreach (IFolder folder in mountedFolders)
try { return folder.GetContent(filename); }
catch { }
throw new FileNotFoundException("File not found", filename);
}
}
}