Beispiel #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);
 }
Beispiel #2
0
        public FileSystem(SharpFileSystem.IFileSystem fileSystem)
        {
            if (fileSystem == null)
                throw new ArgumentNullException("fileSystem");

            FileSystemImpl = fileSystem;
        }
Beispiel #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);
 }
Beispiel #5
0
        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);
 }
Beispiel #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);
 }
Beispiel #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);
 }
Beispiel #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());
 }
Beispiel #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;
 }
 public SeamlessArchiveFileSystem(SharpFileSystem.IFileSystem fileSystem)
 {
     FileSystem = fileSystem;
     _rootUsage = new FileSystemUsage()
     {
         Owner = this,
         FileSystem = FileSystem,
         ArchiveFile = null
     };
 }
Beispiel #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;
 }
Beispiel #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);
 }
Beispiel #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>();
 }
 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;
 }
Beispiel #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);
 }
 protected abstract bool IsArchiveFile(SharpFileSystem.IFileSystem fileSystem, SharpFileSystem.FileSystemPath path);
 public void Delete(SharpFileSystem.FileSystemPath path)
 {
     throw new NotSupportedException();
 }
 public void CreateDirectory(SharpFileSystem.FileSystemPath path)
 {
     throw new NotSupportedException();
 }
 public Stream CreateFile(SharpFileSystem.FileSystemPath path)
 {
     throw new NotSupportedException();
 }
 public bool Exists(SharpFileSystem.FileSystemPath path)
 {
     return path.IsRoot || !path.IsDirectory && Assembly.GetManifestResourceNames().Contains(path.EntityName);
 }
 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();
 }
 private FileSystemReference CreateReference(SharpFileSystem.File file)
 {
     var usage = GetArchiveFs(file);
     var reference = new FileSystemReference(usage);
     usage.References.Add(reference);
     return reference;
 }
 private FileSystemReference CreateArchiveReference(SharpFileSystem.FileSystemPath archiveFile)
 {
     return CreateReference((SharpFileSystem.File)GetActualLocation(archiveFile));
 }
 protected bool HasArchive(SharpFileSystem.FileSystemPath path)
 {
     return path.ToString().LastIndexOf(ArchiveDirectorySeparator.ToString() + SharpFileSystem.FileSystemPath.DirectorySeparator) >= 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);
 }
 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);
 }
 public void CreateDirectory(SharpFileSystem.FileSystemPath path)
 {
     using (var r = Refer(path))
     {
         r.FileSystem.CreateDirectory(GetRelativePath(path));
     }
 }
 public void Delete(SharpFileSystem.FileSystemPath path)
 {
     using (var r = Refer(path))
     {
         r.FileSystem.Delete(GetRelativePath(path));
     }
 }