protected override Result DoGetFileAttributes(out NxFileAttributes attributes, U8Span path) { UnsafeHelpers.SkipParamInit(out attributes); Unsafe.SkipInit(out FsPath normalizedPath); Result rc = PathNormalizer.Normalize(normalizedPath.Str, out _, path, false, false); if (rc.IsFailure()) { return(rc); } if (FsTable.GetFile(normalizedPath, out FileNode file).IsSuccess()) { attributes = file.Attributes; return(Result.Success); } if (FsTable.GetDirectory(normalizedPath, out DirectoryNode dir).IsSuccess()) { attributes = dir.Attributes; return(Result.Success); } return(ResultFs.PathNotFound.Log()); }
protected override Result DoCreateDirectory(U8Span path, NxFileAttributes archiveAttribute) { Unsafe.SkipInit(out FsPath normalizedPath); Result rc = PathNormalizer.Normalize(normalizedPath.Str, out _, path, false, false); if (rc.IsFailure()) { return(rc); } rc = FsTable.AddDirectory(normalizedPath); if (rc.IsFailure()) { return(rc); } rc = FsTable.GetDirectory(normalizedPath, out DirectoryNode dir); if (rc.IsFailure()) { return(rc); } dir.Attributes = archiveAttribute; return(Result.Success); }
protected override Result DoGetEntryType(out DirectoryEntryType entryType, U8Span path) { UnsafeHelpers.SkipParamInit(out entryType); Unsafe.SkipInit(out FsPath normalizedPath); Result rc = PathNormalizer.Normalize(normalizedPath.Str, out _, path, false, false); if (rc.IsFailure()) { return(rc); } if (FsTable.GetFile(normalizedPath, out _).IsSuccess()) { entryType = DirectoryEntryType.File; return(Result.Success); } if (FsTable.GetDirectory(normalizedPath, out _).IsSuccess()) { entryType = DirectoryEntryType.Directory; return(Result.Success); } return(ResultFs.PathNotFound.Log()); }
protected override Result DoDeleteDirectory(U8Span path) { Unsafe.SkipInit(out FsPath normalizedPath); Result rc = PathNormalizer.Normalize(normalizedPath.Str, out _, path, false, false); if (rc.IsFailure()) { return(rc); } return(FsTable.DeleteDirectory(normalizedPath, false)); }
protected override Result DoGetFileSize(out long fileSize, U8Span path) { UnsafeHelpers.SkipParamInit(out fileSize); Unsafe.SkipInit(out FsPath normalizedPath); Result rc = PathNormalizer.Normalize(normalizedPath.Str, out _, path, false, false); if (rc.IsFailure()) { return(rc); } if (FsTable.GetFile(normalizedPath, out FileNode file).IsSuccess()) { return(file.File.GetSize(out fileSize)); } return(ResultFs.PathNotFound.Log()); }
protected override Result DoRenameFile(U8Span currentPath, U8Span newPath) { Unsafe.SkipInit(out FsPath normalizedCurrentPath); Unsafe.SkipInit(out FsPath normalizedNewPath); Result rc = PathNormalizer.Normalize(normalizedCurrentPath.Str, out _, currentPath, false, false); if (rc.IsFailure()) { return(rc); } rc = PathNormalizer.Normalize(normalizedNewPath.Str, out _, newPath, false, false); if (rc.IsFailure()) { return(rc); } return(FsTable.RenameFile(normalizedCurrentPath, normalizedNewPath)); }
protected override Result DoOpenDirectory(out IDirectory directory, U8Span path, OpenDirectoryMode mode) { UnsafeHelpers.SkipParamInit(out directory); Unsafe.SkipInit(out FsPath normalizedPath); Result rc = PathNormalizer.Normalize(normalizedPath.Str, out _, path, false, false); if (rc.IsFailure()) { return(rc); } rc = FsTable.GetDirectory(normalizedPath, out DirectoryNode dirNode); if (rc.IsFailure()) { return(rc); } directory = new MemoryDirectory(dirNode, mode); return(Result.Success); }
protected override Result DoOpenFile(out IFile file, U8Span path, OpenMode mode) { UnsafeHelpers.SkipParamInit(out file); Unsafe.SkipInit(out FsPath normalizedPath); Result rc = PathNormalizer.Normalize(normalizedPath.Str, out _, path, false, false); if (rc.IsFailure()) { return(rc); } rc = FsTable.GetFile(normalizedPath, out FileNode fileNode); if (rc.IsFailure()) { return(rc); } file = new MemoryFile(mode, fileNode.File); return(Result.Success); }
protected override Result DoCreateFile(U8Span path, long size, CreateFileOptions options) { Unsafe.SkipInit(out FsPath normalizedPath); Result rc = PathNormalizer.Normalize(normalizedPath.Str, out _, path, false, false); if (rc.IsFailure()) { return(rc); } rc = FsTable.AddFile(normalizedPath); if (rc.IsFailure()) { return(rc); } rc = FsTable.GetFile(normalizedPath, out FileNode file); if (rc.IsFailure()) { return(rc); } return(file.File.SetSize(size)); }