示例#1
0
 public Stream OpenFile(SharpFileSystem.FileSystemPath path, FileAccess access)
 {
     var fs = GetFirst(path);
     if (fs == null)
         throw new FileNotFoundException();
     return fs.OpenFile(path, access);
 }
示例#2
0
        public FileSystem(SharpFileSystem.IFileSystem fileSystem)
        {
            if (fileSystem == null)
                throw new ArgumentNullException("fileSystem");

            FileSystemImpl = fileSystem;
        }
示例#3
0
 public void Delete(SharpFileSystem.FileSystemPath path)
 {
     if (path.IsFile)
         System.IO.File.Delete(GetPhysicalPath(path));
     else
         System.IO.Directory.Delete(GetPhysicalPath(path), true);
 }
 protected FileSystemReference Refer(SharpFileSystem.FileSystemPath path)
 {
     SharpFileSystem.FileSystemPath archivePath;
     if (TryGetArchivePath(path, out archivePath))
         return CreateArchiveReference(archivePath);
     return new FileSystemReference(_rootUsage);
 }
示例#5
0
文件: Engine.cs 项目: johang88/triton
        public Engine(Windowing.IWindowProvider windowProvider, SharpFileSystem.IFileSystem fileSystem)
        {
            WindowProvider = windowProvider;

            // Initialize file system and resource manager
            FileSystem = new Common.IO.FileSystem(fileSystem);

            ResourceGroupManager = new Common.ResourceGroupManager(FileSystem);
            CoreResources = ResourceGroupManager.Add("core", 100);
            GameResources = ResourceGroupManager.Add("game", 10);

            // Setup graphics core
            GraphicsBackend = new Graphics.Backend(CoreResources, WindowProvider.Width, WindowProvider.Height, WindowProvider.WindowInfo);

            // Init resource loaders
            RegisterResourceLoaders(CoreResources);
            RegisterResourceLoaders(GameResources);

            // High level renderer (deferred + hdr)
            Renderer = new RendererImplementation(FileSystem, CoreResources, GraphicsBackend);

            // The input stuff
            InputManager = new Input.InputManager(WindowProvider.Bounds);

            // Setup game world
            GameWorld = new GameWorld(GameResources, GraphicsBackend);
        }
 private SharpFileSystem.FileSystemPath GetRelativePath(SharpFileSystem.FileSystemPath path)
 {
     string s = path.ToString();
     int sindex = s.LastIndexOf(ArchiveDirectorySeparator.ToString() + SharpFileSystem.FileSystemPath.DirectorySeparator);
     if (sindex < 0)
         return path;
     return SharpFileSystem.FileSystemPath.Parse(s.Substring(sindex + 1));
 }
 public Stream OpenFile(SharpFileSystem.FileSystemPath path, FileAccess access)
 {
     if (access == FileAccess.Write)
         throw new NotSupportedException();
     if (path.IsDirectory || path.ParentPath != SharpFileSystem.FileSystemPath.Root)
         throw new FileNotFoundException();
     return Assembly.GetManifestResourceStream(path.EntityName);
 }
示例#8
0
 public void CreateDirectory(SharpFileSystem.FileSystemPath path)
 {
     if (Exists(path))
         throw new ArgumentException("The specified directory already exists.");
     var fs = GetFirst(path.ParentPath);
     if (fs == null)
         throw new ArgumentException("The directory-parent does not exist.");
     fs.CreateDirectory(path);
 }
示例#9
0
 public Stream OpenFile(SharpFileSystem.FileSystemPath path, FileAccess access)
 {
     if (!path.IsFile)
         throw new ArgumentException("The specified path is no file.", "path");
     MemoryFile file;
     if (!_files.TryGetValue(path, out file))
         throw new FileNotFoundException();
     return new MemoryFileStream(file);
 }
示例#10
0
 public Stream CreateFile(SharpFileSystem.FileSystemPath path)
 {
     if (!path.IsFile)
         throw new ArgumentException("The specified path is no file.", "path");
     if (!_directories.ContainsKey(path.ParentPath))
         throw new DirectoryNotFoundException();
     _directories[path.ParentPath].AddLast(path);
     return new MemoryFileStream(_files[path] = new MemoryFile());
 }
示例#11
0
 public ICollection<SharpFileSystem.FileSystemPath> GetEntities(SharpFileSystem.FileSystemPath path)
 {
     if (!path.IsDirectory)
         throw new ArgumentException("The specified path is no directory.", "path");
     LinkedList<SharpFileSystem.FileSystemPath> subentities;
     if (!_directories.TryGetValue(path, out subentities))
         throw new DirectoryNotFoundException();
     return subentities;
 }
示例#12
0
 public SeamlessArchiveFileSystem(SharpFileSystem.IFileSystem fileSystem)
 {
     FileSystem = fileSystem;
     _rootUsage = new FileSystemUsage()
     {
         Owner = this,
         FileSystem = FileSystem,
         ArchiveFile = null
     };
 }
示例#13
0
 public ICollection<SharpFileSystem.FileSystemPath> GetEntities(SharpFileSystem.FileSystemPath path)
 {
     var entities = new SortedList<SharpFileSystem.FileSystemPath, SharpFileSystem.FileSystemPath>();
     foreach (var fs in FileSystems.Where(fs => fs.Exists(path)))
     {
         foreach(var entity in fs.GetEntities(path))
             if (!entities.ContainsKey(entity))
                 entities.Add(entity, entity);
     }
     return entities.Values;
 }
示例#14
0
 public ICollection<SharpFileSystem.FileSystemPath> GetEntities(SharpFileSystem.FileSystemPath path)
 {
     string physicalPath = GetPhysicalPath(path);
     string[] directories = System.IO.Directory.GetDirectories(physicalPath);
     string[] files = System.IO.Directory.GetFiles(physicalPath);
     var virtualDirectories =
         directories.Select(p => GetVirtualDirectoryPath(p));
     var virtualFiles =
         files.Select(p => GetVirtualFilePath(p));
     return new EnumerableCollection<SharpFileSystem.FileSystemPath>(virtualDirectories.Concat(virtualFiles), directories.Length + files.Length);
 }
示例#15
0
 public void CreateDirectory(SharpFileSystem.FileSystemPath path)
 {
     if (!path.IsDirectory)
         throw new ArgumentException("The specified path is no directory.", "path");
     LinkedList<SharpFileSystem.FileSystemPath> subentities;
     if (_directories.ContainsKey(path))
         throw new ArgumentException("The specified directory-path already exists.", "path");
     if (!_directories.TryGetValue(path.ParentPath, out subentities))
         throw new DirectoryNotFoundException();
     subentities.AddLast(path);
     _directories[path] = new LinkedList<SharpFileSystem.FileSystemPath>();
 }
示例#16
0
 protected bool TryGetArchivePath(SharpFileSystem.FileSystemPath path, out SharpFileSystem.FileSystemPath archivePath)
 {
     string p = path.ToString();
     int sindex = p.LastIndexOf(ArchiveDirectorySeparator.ToString() + SharpFileSystem.FileSystemPath.DirectorySeparator);
     if (sindex < 0)
     {
         archivePath = path;
         return false;
     }
     archivePath = SharpFileSystem.FileSystemPath.Parse(p.Substring(0, sindex));
     return true;
 }
示例#17
0
 public void Delete(SharpFileSystem.FileSystemPath path)
 {
     if (path.IsRoot)
         throw new ArgumentException("The root cannot be deleted.");
     bool removed;
     if (path.IsDirectory)
         removed = _directories.Remove(path);
     else
         removed = _files.Remove(path);
     if (!removed)
         throw new ArgumentException("The specified path does not exist.");
     var parent = _directories[path.ParentPath];
     parent.Remove(path);
 }
示例#18
0
 protected abstract bool IsArchiveFile(SharpFileSystem.IFileSystem fileSystem, SharpFileSystem.FileSystemPath path);
示例#19
0
 public void Delete(SharpFileSystem.FileSystemPath path)
 {
     throw new NotSupportedException();
 }
示例#20
0
 public void CreateDirectory(SharpFileSystem.FileSystemPath path)
 {
     throw new NotSupportedException();
 }
示例#21
0
 public Stream CreateFile(SharpFileSystem.FileSystemPath path)
 {
     throw new NotSupportedException();
 }
示例#22
0
 public bool Exists(SharpFileSystem.FileSystemPath path)
 {
     return path.IsRoot || !path.IsDirectory && Assembly.GetManifestResourceNames().Contains(path.EntityName);
 }
示例#23
0
 public ICollection<SharpFileSystem.FileSystemPath> GetEntities(SharpFileSystem.FileSystemPath path)
 {
     if (!path.IsRoot)
         throw new DirectoryNotFoundException();
     return Assembly.GetManifestResourceNames().Select(name => SharpFileSystem.FileSystemPath.Root.AppendFile(name)).ToArray();
 }
示例#24
0
 private FileSystemReference CreateReference(SharpFileSystem.File file)
 {
     var usage = GetArchiveFs(file);
     var reference = new FileSystemReference(usage);
     usage.References.Add(reference);
     return reference;
 }
示例#25
0
 private FileSystemReference CreateArchiveReference(SharpFileSystem.FileSystemPath archiveFile)
 {
     return CreateReference((SharpFileSystem.File)GetActualLocation(archiveFile));
 }
示例#26
0
 protected bool HasArchive(SharpFileSystem.FileSystemPath path)
 {
     return path.ToString().LastIndexOf(ArchiveDirectorySeparator.ToString() + SharpFileSystem.FileSystemPath.DirectorySeparator) >= 0;
 }
示例#27
0
 public System.IO.Stream CreateFile(SharpFileSystem.FileSystemPath path)
 {
     var r = Refer(path);
     var s = r.FileSystem.CreateFile(GetRelativePath(path));
     return new SafeReferenceStream(s, r);
 }
示例#28
0
 private SharpFileSystem.FileSystemPath ArchiveFileToDirectory(SharpFileSystem.FileSystemPath path)
 {
     if (!path.IsFile)
         throw new ArgumentException("The specified path is not a file.");
     return path.ParentPath.AppendDirectory(path.EntityName + ArchiveDirectorySeparator);
 }
示例#29
0
 public void CreateDirectory(SharpFileSystem.FileSystemPath path)
 {
     using (var r = Refer(path))
     {
         r.FileSystem.CreateDirectory(GetRelativePath(path));
     }
 }
示例#30
0
 public void Delete(SharpFileSystem.FileSystemPath path)
 {
     using (var r = Refer(path))
     {
         r.FileSystem.Delete(GetRelativePath(path));
     }
 }