public override Int32 Overwrite( Object FileNode, Object FileDesc0, UInt32 FileAttributes, Boolean ReplaceFileAttributes, UInt64 AllocationSize, out FileInfo FileInfo) { FileDesc FileDesc = (FileDesc)FileDesc0; if (ReplaceFileAttributes) { FileDesc.SetFileAttributes(FileAttributes); } else if (0 != FileAttributes) { FileDesc.SetFileAttributes(FileDesc.GetFileAttributes() | FileAttributes); } FileDesc.Stream.SetLength(0); return(FileDesc.GetFileInfo(out FileInfo)); }
public override Int32 Create( String FileName, UInt32 CreateOptions, UInt32 GrantedAccess, UInt32 FileAttributes, Byte[] SecurityDescriptor, UInt64 AllocationSize, out Object FileNode, out Object FileDesc0, out FileInfo FileInfo, out String NormalizedName) { FileDesc FileDesc = null; try { FileName = ConcatPath(FileName); if (0 == (CreateOptions & FILE_DIRECTORY_FILE)) { FileSecurity Security = null; if (null != SecurityDescriptor) { Security = new FileSecurity(); Security.SetSecurityDescriptorBinaryForm(SecurityDescriptor); } FileDesc = new FileDesc( new FileStream( FileName, FileMode.CreateNew, (FileSystemRights)GrantedAccess | FileSystemRights.WriteAttributes, FileShare.Read | FileShare.Write | FileShare.Delete, 4096, 0, Security)); FileDesc.SetFileAttributes(FileAttributes | (UInt32)System.IO.FileAttributes.Archive); } else { if (Directory.Exists(FileName)) { ThrowIoExceptionWithNtStatus(STATUS_OBJECT_NAME_COLLISION); } DirectorySecurity Security = null; if (null != SecurityDescriptor) { Security = new DirectorySecurity(); Security.SetSecurityDescriptorBinaryForm(SecurityDescriptor); } FileDesc = new FileDesc( Directory.CreateDirectory(FileName, Security)); FileDesc.SetFileAttributes(FileAttributes); } FileNode = default(Object); FileDesc0 = FileDesc; NormalizedName = default(String); return(FileDesc.GetFileInfo(out FileInfo)); } catch { if (null != FileDesc && null != FileDesc.Stream) { FileDesc.Stream.Dispose(); } throw; } }