Exemplo n.º 1
0
        public ConcatenationDirectory(ConcatenationFileSystem fs, IFileSystem baseFs, IDirectory parentDirectory, OpenDirectoryMode mode, U8Span path)
        {
            ParentFileSystem = fs;
            BaseFileSystem   = baseFs;
            ParentDirectory  = parentDirectory;
            Mode             = mode;

            StringUtils.Copy(_path.Str, path);
            _path.Str[PathTools.MaxPathLength] = StringTraits.NullTerminator;

            // Ensure the path ends with a separator
            int pathLength = StringUtils.GetLength(path, PathTools.MaxPathLength + 1);

            if (pathLength != 0 && _path.Str[pathLength - 1] == StringTraits.DirectorySeparator)
            {
                return;
            }

            if (pathLength >= PathTools.MaxPathLength)
            {
                throw new HorizonResultException(ResultFs.TooLongPath.Value, "abort");
            }

            _path.Str[pathLength]              = StringTraits.DirectorySeparator;
            _path.Str[pathLength + 1]          = StringTraits.NullTerminator;
            _path.Str[PathTools.MaxPathLength] = StringTraits.NullTerminator;
        }
Exemplo n.º 2
0
 public LayeredFileSystemDirectory(IFileSystem fs, List <IDirectory> sources, string path, OpenDirectoryMode mode)
 {
     ParentFileSystem = fs;
     Sources          = sources;
     FullPath         = path;
     Mode             = mode;
 }
Exemplo n.º 3
0
 public RomFsDirectory(RomFsFileSystem fs, string path, FindPosition position, OpenDirectoryMode mode)
 {
     ParentFileSystem = fs;
     InitialPosition  = position;
     FullPath         = path;
     Mode             = mode;
 }
Exemplo n.º 4
0
 public MemoryDirectory(DirectoryNode directory, OpenDirectoryMode mode)
 {
     Mode        = mode;
     Directory   = directory;
     CurrentDir  = directory.ChildDirectory;
     CurrentFile = directory.ChildFile;
 }
Exemplo n.º 5
0
 public LocalDirectory(IEnumerator <FileSystemInfo> entryEnumerator, DirectoryInfo dirInfo,
                       OpenDirectoryMode mode)
 {
     EntryEnumerator = entryEnumerator;
     DirInfo         = dirInfo;
     Mode            = mode;
 }
Exemplo n.º 6
0
        public IDirectory OpenDirectory(string path, OpenDirectoryMode mode)
        {
            path = PathTools.Normalize(path);

            var dirs = new List <IDirectory>();

            foreach (IFileSystem fs in Sources)
            {
                DirectoryEntryType type = fs.GetEntryType(path);

                if (type == DirectoryEntryType.File && dirs.Count == 0)
                {
                    ThrowHelper.ThrowResult(ResultFs.PathNotFound);
                }

                if (fs.GetEntryType(path) == DirectoryEntryType.Directory)
                {
                    dirs.Add(fs.OpenDirectory(path, mode));
                }
            }

            var dir = new LayeredFileSystemDirectory(this, dirs, path, mode);

            return(dir);
        }
Exemplo n.º 7
0
 public RomFsDirectory(RomFsFileSystem fs, FindPosition position, OpenDirectoryMode mode)
 {
     ParentFileSystem = fs;
     InitialPosition  = position;
     _currentPosition = position;
     Mode             = mode;
 }
Exemplo n.º 8
0
 public MergedDirectory(List <IFileSystem> sourceFileSystems, U8Span path, OpenDirectoryMode mode)
 {
     SourceFileSystems = sourceFileSystems;
     SourceDirs        = new List <IDirectory>(sourceFileSystems.Count);
     Path = path.ToU8String();
     Mode = mode;
 }
Exemplo n.º 9
0
 public ConcatenationDirectory(ConcatenationFileSystem fs, IDirectory parentDirectory, OpenDirectoryMode mode)
 {
     ParentFileSystem = fs;
     ParentDirectory  = parentDirectory;
     Mode             = mode;
     FullPath         = parentDirectory.FullPath;
 }
Exemplo n.º 10
0
 public AesXtsDirectory(IFileSystem baseFs, IDirectory baseDir, string path, OpenDirectoryMode mode)
 {
     BaseFileSystem = baseFs;
     BaseDirectory  = baseDir;
     Mode           = mode;
     Path           = path;
 }
Exemplo n.º 11
0
 public SaveDataDirectory(SaveDataFileSystemCore fs, SaveFindPosition position, OpenDirectoryMode mode)
 {
     ParentFileSystem = fs;
     InitialPosition  = position;
     _currentPosition = position;
     Mode             = mode;
 }
Exemplo n.º 12
0
 public SaveDataDirectory(SaveDataFileSystemCore fs, string path, SaveFindPosition position, OpenDirectoryMode mode)
 {
     ParentFileSystem = fs;
     InitialPosition  = position;
     FullPath         = path;
     Mode             = mode;
 }
 public SubdirectoryFileSystemDirectory(SubdirectoryFileSystem fs, IDirectory baseDir, string path, OpenDirectoryMode mode)
 {
     ParentFileSystem = fs;
     BaseDirectory    = baseDir;
     FullPath         = path;
     Mode             = mode;
 }
Exemplo n.º 14
0
        public Result OpenDirectory(out DirectoryHandle handle, U8Span path, OpenDirectoryMode mode)
        {
            handle = default;

            Result rc = FindFileSystem(out FileSystemAccessor fileSystem, out U8Span subPath, path);

            if (rc.IsFailure())
            {
                return(rc);
            }

            if (IsEnabledAccessLog() && fileSystem.IsAccessLogEnabled)
            {
                TimeSpan startTime = Time.GetCurrent();
                rc     = fileSystem.OpenDirectory(out DirectoryAccessor dir, subPath, mode);
                handle = new DirectoryHandle(dir);
                TimeSpan endTime = Time.GetCurrent();

                OutputAccessLog(rc, startTime, endTime, handle, $", path: \"{path.ToString()}\", open_mode: {mode}");
            }
            else
            {
                rc     = fileSystem.OpenDirectory(out DirectoryAccessor dir, subPath, mode);
                handle = new DirectoryHandle(dir);
            }

            return(rc);
        }
Exemplo n.º 15
0
 public Xb2Directory(IFileSystem fs, IDirectory baseDirectory)
 {
     BaseDirectory    = baseDirectory;
     ParentFileSystem = fs;
     FullPath         = baseDirectory.FullPath;
     Mode             = baseDirectory.Mode;
 }
Exemplo n.º 16
0
 public SaveDataDirectory(SaveDataFileSystemCore fs, string path, SaveDirectoryEntry dir, OpenDirectoryMode mode)
 {
     ParentFileSystem = fs;
     Directory        = dir;
     FullPath         = path;
     Mode             = mode;
 }
Exemplo n.º 17
0
        public IDirectory OpenDirectory(string path, OpenDirectoryMode mode)
        {
            path = PathTools.Normalize(path);

            IDirectory baseDir = BaseFs.OpenDirectory(path, mode);

            return(new Xb2Directory(this, baseDir));
        }
Exemplo n.º 18
0
 public AesXtsDirectory(AesXtsFileSystem parentFs, IDirectory baseDir, OpenDirectoryMode mode)
 {
     ParentFileSystem = parentFs;
     BaseDirectory    = baseDir;
     Mode             = mode;
     BaseFileSystem   = BaseDirectory.ParentFileSystem;
     FullPath         = BaseDirectory.FullPath;
 }
Exemplo n.º 19
0
        public IDirectory OpenDirectory(string path, OpenDirectoryMode mode)
        {
            path = PathTools.Normalize(path);

            IDirectory baseDir = ParentFileSystem.OpenDirectory(ResolveFullPath(path), mode);

            return(new SubdirectoryFileSystemDirectory(this, baseDir, path, mode));
        }
Exemplo n.º 20
0
 public ConcatenationDirectory(ConcatenationFileSystem fs, IFileSystem baseFs, IDirectory parentDirectory, OpenDirectoryMode mode, string path)
 {
     ParentFileSystem = fs;
     BaseFileSystem   = baseFs;
     ParentDirectory  = parentDirectory;
     Mode             = mode;
     Path             = path;
 }
Exemplo n.º 21
0
 public IDirectory GetDirectory(string name, OpenDirectoryMode mode)
 {
     name = FilterPath(name);
     if (Fs.DirectoryExists(name))
     {
         return(Fs.OpenDirectory(name, mode));
     }
     return(null);
 }
Exemplo n.º 22
0
        public IDirectory OpenDirectory(string path, OpenDirectoryMode mode)
        {
            string fullPath = GetFullPath(PathTools.Normalize(path));

            lock (Locker)
            {
                return(BaseFs.OpenDirectory(fullPath, mode));
            }
        }
Exemplo n.º 23
0
        public LocalDirectory(LocalFileSystem fs, string path, OpenDirectoryMode mode)
        {
            ParentFileSystem = fs;
            FullPath = path;
            LocalPath = fs.ResolveLocalPath(path);
            Mode = mode;

            DirInfo = new DirectoryInfo(LocalPath);
        }
Exemplo n.º 24
0
        public Result OpenDirectory(out IDirectory directory, string path, OpenDirectoryMode mode)
        {
            if (IsDisposed)
            {
                directory = default;
                return(ResultFs.PreconditionViolation.Log());
            }

            return(OpenDirectoryImpl(out directory, path, mode));
        }
Exemplo n.º 25
0
        public IDirectory OpenDirectory(string path, OpenDirectoryMode mode)
        {
            path = PathTools.Normalize(path);

            IDirectory baseDir = BaseFileSystem.OpenDirectory(path, mode);

            var dir = new AesXtsDirectory(this, baseDir, mode);

            return(dir);
        }
Exemplo n.º 26
0
        public FatFileSystemDirectory(FatFileSystemProvider fs, string path, OpenDirectoryMode mode)
        {
            ParentFileSystem = fs;
            FullPath         = path;
            Mode             = mode;

            path = FatFileSystemProvider.ToDiscUtilsPath(PathTools.Normalize(path));

            DirInfo = fs.Fs.GetDirectoryInfo(path);
        }
Exemplo n.º 27
0
        public static Result OpenDirectory(this FileSystemClient fs, out DirectoryHandle handle, U8Span path,
                                           OpenDirectoryMode mode)
        {
            UnsafeHelpers.SkipParamInit(out handle);

            Result             rc;
            U8Span             subPath;
            FileSystemAccessor fileSystem;
            Span <byte>        logBuffer = stackalloc byte[0x300];

            if (fs.Impl.IsEnabledAccessLog())
            {
                Tick start = fs.Hos.Os.GetSystemTick();
                rc = fs.Impl.FindFileSystem(out fileSystem, out subPath, path);
                Tick end = fs.Hos.Os.GetSystemTick();

                var sb = new U8StringBuilder(logBuffer, true);
                sb.Append(LogPath).Append(path).Append((byte)'"').Append(LogOpenMode).AppendFormat((int)mode, 'X');
                logBuffer = sb.Buffer;

                fs.Impl.OutputAccessLogUnlessResultSuccess(rc, start, end, null, new U8Span(logBuffer));
            }
            else
            {
                rc = fs.Impl.FindFileSystem(out fileSystem, out subPath, path);
            }
            fs.Impl.AbortIfNeeded(rc);
            if (rc.IsFailure())
            {
                return(rc);
            }

            DirectoryAccessor accessor;

            if (fs.Impl.IsEnabledAccessLog() && fileSystem.IsEnabledAccessLog())
            {
                Tick start = fs.Hos.Os.GetSystemTick();
                rc = fileSystem.OpenDirectory(out accessor, subPath, mode);
                Tick end = fs.Hos.Os.GetSystemTick();

                fs.Impl.OutputAccessLog(rc, start, end, accessor, new U8Span(logBuffer));
            }
            else
            {
                rc = fileSystem.OpenDirectory(out accessor, subPath, mode);
            }
            fs.Impl.AbortIfNeeded(rc);
            if (rc.IsFailure())
            {
                return(rc);
            }

            handle = new DirectoryHandle(accessor);
            return(Result.Success);
        }
Exemplo n.º 28
0
        public IDirectory OpenDirectory(string path, OpenDirectoryMode mode)
        {
            path = PathTools.Normalize(path);

            if (!DirDictionary.TryGetValue(path, out SaveDirectoryEntry dir))
            {
                throw new DirectoryNotFoundException(path);
            }

            return(new SaveDataDirectory(this, path, dir, mode));
        }
Exemplo n.º 29
0
        public IDirectory OpenDirectory(string path, OpenDirectoryMode mode)
        {
            path = PathTools.Normalize(path);

            if (!FileTable.TryOpenDirectory(path, out FindPosition position))
            {
                ThrowHelper.ThrowResult(ResultFs.PathNotFound);
            }

            return(new RomFsDirectory(this, path, position, mode));
        }
Exemplo n.º 30
0
        public IDirectory OpenDirectory(string path, OpenDirectoryMode mode)
        {
            path = PathTools.Normalize(path);

            if (!FileTable.TryOpenDirectory(path, out FindPosition position))
            {
                throw new DirectoryNotFoundException();
            }

            return(new RomFsDirectory(this, path, position, mode));
        }