private void SetConcatenationFileAttribute(string path) { NxFileAttributes attributes = BaseFileSystem.GetFileAttributes(path); attributes |= NxFileAttributes.Archive; BaseFileSystem.SetFileAttributes(path, attributes); }
protected override Result DoGetFileAttributes(out NxFileAttributes attributes, U8Span path) { UnsafeHelpers.SkipParamInit(out attributes); Result rc = ResolveFullPath(out string fullPath, path, true); if (rc.IsFailure()) { return(rc); } rc = GetFileInfo(out FileInfo info, fullPath); if (rc.IsFailure()) { return(rc); } if (info.Attributes == (FileAttributes)(-1)) { return(ResultFs.PathNotFound.Log()); } attributes = info.Attributes.ToNxAttributes(); return(Result.Success); }
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) { Result rc = ResolveFullPath(out string fullPath, path, false); if (rc.IsFailure()) { return(rc); } rc = GetDirInfo(out DirectoryInfo dir, fullPath); if (rc.IsFailure()) { return(rc); } if (dir.Exists) { return(ResultFs.PathAlreadyExists.Log()); } if (dir.Parent?.Exists != true) { return(ResultFs.PathNotFound.Log()); } return(CreateDirInternal(dir, archiveAttribute)); }
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 SetFileAttributesImpl(string path, NxFileAttributes attributes) { string localPath = ResolveLocalPath(PathTools.Normalize(path)); Result rc = GetFileInfo(out FileInfo info, localPath); if (rc.IsFailure()) { return(rc); } if (info.Attributes == (FileAttributes)(-1)) { return(ResultFs.PathNotFound.Log()); } FileAttributes attributesOld = info.Attributes; FileAttributes attributesNew = attributesOld.ApplyNxAttributes(attributes); try { info.Attributes = attributesNew; } catch (IOException) { return(ResultFs.PathNotFound.Log()); } return(Result.Success); }
protected override Result DoSetFileAttributes(U8Span path, NxFileAttributes attributes) { Result rc = ResolveFullPath(out string fullPath, path, true); if (rc.IsFailure()) { return(rc); } rc = GetFileInfo(out FileInfo info, fullPath); if (rc.IsFailure()) { return(rc); } if (info.Attributes == (FileAttributes)(-1)) { return(ResultFs.PathNotFound.Log()); } FileAttributes attributesOld = info.Attributes; FileAttributes attributesNew = attributesOld.ApplyNxAttributes(attributes); try { info.Attributes = attributesNew; } catch (IOException) { return(ResultFs.PathNotFound.Log()); } return(Result.Success); }
protected override Result GetFileAttributesImpl(out NxFileAttributes attributes, U8Span path) { attributes = default; Result rc = ResolveFullPath(out string fullPath, path); if (rc.IsFailure()) { return(rc); } rc = GetFileInfo(out FileInfo info, fullPath); if (rc.IsFailure()) { return(rc); } if (info.Attributes == (FileAttributes)(-1)) { attributes = default; return(ResultFs.PathNotFound.Log()); } attributes = info.Attributes.ToNxAttributes(); return(Result.Success); }
public Result CreateDirectory(string path, NxFileAttributes archiveAttribute) { if (IsDisposed) { return(ResultFs.PreconditionViolation.Log()); } return(CreateDirectoryImpl(path, archiveAttribute)); }
public Result SetFileAttributes(string path, NxFileAttributes attributes) { if (IsDisposed) { return(ResultFs.PreconditionViolation.Log()); } return(SetFileAttributesImpl(path, attributes)); }
public void SetFileAttributes(string path, NxFileAttributes attributes) { path = ToDiscUtilsPath(PathTools.Normalize(path)); FileAttributes attributesOld = File.GetAttributes(path); FileAttributes attributesNew = attributesOld.ApplyNxAttributes(attributes); Fs.SetAttributes(path, attributesNew); }
public Result SetFileAttributes(U8Span path, NxFileAttributes attributes) { if (path.IsNull()) { return(ResultFs.NullptrArgument.Log()); } return(DoSetFileAttributes(path, attributes)); }
public Result CreateDirectory(U8Span path, NxFileAttributes archiveAttribute) { if (path.IsNull()) { return(ResultFs.NullptrArgument.Log()); } return(DoCreateDirectory(path, archiveAttribute)); }
public Result SetFileAttributes(U8Span spanpath, NxFileAttributes attributes) { string path = PathTools.Normalize(spanpath.ToString()); Tuple <string, IAttributeFileSystem> t = FileDict[path]; t.Item2.SetFileAttributes(t.Item1.ToU8Span(), attributes); return(Result.Success); }
public Result GetFileAttributes(string path, out NxFileAttributes attributes) { if (IsDisposed) { attributes = default; return(ResultFs.PreconditionViolation.Log()); } return(GetFileAttributesImpl(path, out attributes)); }
public Result GetFileAttributes(out NxFileAttributes attributes, U8Span path) { if (IsDisposed) { attributes = default; return(ResultFs.PreconditionViolation.Log()); } return(GetFileAttributesImpl(out attributes, path)); }
public Result GetFileAttributes(out NxFileAttributes attributes, U8Span path) { if (path.IsNull()) { attributes = default; return(ResultFs.NullptrArgument.Log()); } return(DoGetFileAttributes(out attributes, path)); }
public void SetFileAttributes(string path, NxFileAttributes attributes) { path = PathTools.Normalize(path); string localPath = ResolveLocalPath(path); FileAttributes attributesOld = File.GetAttributes(localPath); FileAttributes attributesNew = attributesOld.ApplyNxAttributes(attributes); File.SetAttributes(localPath, attributesNew); }
public Result GetFileAttributes(out NxFileAttributes attributes, U8Span path) { UnsafeHelpers.SkipParamInit(out attributes); if (path.IsNull()) { return(ResultFs.NullptrArgument.Log()); } return(DoGetFileAttributes(out attributes, path)); }
protected override Result DoSetFileAttributes(U8Span path, NxFileAttributes attributes) { if (FsTable.GetFile(path, out FileNode file).IsSuccess()) { file.Attributes = attributes; return(Result.Success); } if (FsTable.GetDirectory(path, out DirectoryNode dir).IsSuccess()) { dir.Attributes = attributes; return(Result.Success); } return(ResultFs.PathNotFound.Log()); }
protected override Result DoGetFileAttributes(out NxFileAttributes attributes, U8Span path) { if (FsTable.GetFile(path, out FileNode file).IsSuccess()) { attributes = file.Attributes; return(Result.Success); } if (FsTable.GetDirectory(path, out DirectoryNode dir).IsSuccess()) { attributes = dir.Attributes; return(Result.Success); } attributes = default; return(ResultFs.PathNotFound.Log()); }
protected override Result DoCreateDirectory(U8Span path, NxFileAttributes archiveAttribute) { Result rc = FsTable.AddDirectory(path); if (rc.IsFailure()) { return(rc); } rc = FsTable.GetDirectory(path, out DirectoryNode dir); if (rc.IsFailure()) { return(rc); } dir.Attributes = archiveAttribute; return(Result.Success); }
protected override Result DoGetFileAttributes(out NxFileAttributes attributes, U8Span path) { UnsafeHelpers.SkipParamInit(out attributes); if (FsTable.GetFile(path, out FileNode file).IsSuccess()) { attributes = file.Attributes; return(Result.Success); } if (FsTable.GetDirectory(path, out DirectoryNode dir).IsSuccess()) { attributes = dir.Attributes; return(Result.Success); } return(ResultFs.PathNotFound.Log()); }
private static Result CreateDirInternal(DirectoryInfo dir, NxFileAttributes attributes) { try { dir.Create(); dir.Refresh(); if (attributes.HasFlag(NxFileAttributes.Archive)) { dir.Attributes |= FileAttributes.Archive; } } catch (Exception ex) when(ex.HResult < 0) { return(HResult.HResultToHorizonResult(ex.HResult).Log()); } return(Result.Success); }
protected override Result GetFileAttributesImpl(string path, out NxFileAttributes attributes) { attributes = default; string localPath = ResolveLocalPath(PathTools.Normalize(path)); Result rc = GetFileInfo(out FileInfo info, localPath); if (rc.IsFailure()) { return(rc); } if (info.Attributes == (FileAttributes)(-1)) { attributes = default; return(ResultFs.PathNotFound.Log()); } attributes = info.Attributes.ToNxAttributes(); return(Result.Success); }
protected override Result CreateDirectoryImpl(string path, NxFileAttributes archiveAttribute) { string localPath = ResolveLocalPath(PathTools.Normalize(path)); Result rc = GetDirInfo(out DirectoryInfo dir, localPath); if (rc.IsFailure()) { return(rc); } if (dir.Exists) { return(ResultFs.PathAlreadyExists.Log()); } if (dir.Parent?.Exists != true) { return(ResultFs.PathNotFound.Log()); } return(CreateDirInternal(dir, archiveAttribute)); }
public void CreateFile(string path, long size, CreateFileOptions options) { path = PathTools.Normalize(path); CreateFileOptions newOptions = options & ~CreateFileOptions.CreateConcatenationFile; if (!options.HasFlag(CreateFileOptions.CreateConcatenationFile)) { BaseFileSystem.CreateFile(path, size, newOptions); return; } // A concatenation file directory can't contain normal files string parentDir = PathTools.GetParentDirectory(path); if (IsConcatenationFile(parentDir)) { throw new IOException("Cannot create files inside of a concatenation file"); } BaseFileSystem.CreateDirectory(path); NxFileAttributes attributes = BaseFileSystem.GetFileAttributes(path) | NxFileAttributes.Archive; BaseFileSystem.SetFileAttributes(path, attributes); long remaining = size; for (int i = 0; remaining > 0; i++) { long fileSize = Math.Min(SubFileSize, remaining); string fileName = GetSubFilePath(path, i); BaseFileSystem.CreateFile(fileName, fileSize, CreateFileOptions.None); remaining -= fileSize; } }
internal static bool HasConcatenationFileAttribute(NxFileAttributes attributes) { return((attributes & NxFileAttributes.Directory) != 0 && (attributes & NxFileAttributes.Archive) != 0); }
public static FileAttributes ApplyNxAttributes(this FileAttributes attributes, NxFileAttributes nxAttributes) { // The only 2 bits from FileAttributes that are used in NxFileAttributes const int mask = 3 << 4; FileAttributes oldAttributes = attributes & (FileAttributes)mask; return(oldAttributes | nxAttributes.ToFatAttributes()); }
public static FileAttributes ToFatAttributes(this NxFileAttributes attributes) { return((FileAttributes)(((int)attributes & 3) << 4)); }