public override Int32 Overwrite( Object fileNode, Object fileDesc0, UInt32 fileAttributes, Boolean replaceFileAttributes, UInt64 allocationSize, out FileInfo fileInfo) { FileDescriptor fileDesc = (FileDescriptor)fileDesc0; MakeWriteable(fileDesc); if (replaceFileAttributes) { fileDesc.SetFileAttributes(fileAttributes | (UInt32)System.IO.FileAttributes.Archive); } else if (0 != fileAttributes) { fileDesc.SetFileAttributes(fileDesc.GetFileAttributes() | fileAttributes | (UInt32)System.IO.FileAttributes.Archive); } fileDesc.WriteStream.SetLength(0); return(fileDesc.GetFileInfo(out fileInfo)); }
public override Int32 GetFileInfo( Object fileNode, Object fileDesc0, out FileInfo fileInfo) { FileDescriptor fileDesc = (FileDescriptor)fileDesc0; return(fileDesc.GetFileInfo(out fileInfo)); }
public override Int32 SetBasicInfo( Object fileNode, Object fileDesc0, UInt32 fileAttributes, UInt64 creationTime, UInt64 lastAccessTime, UInt64 lastWriteTime, UInt64 changeTime, out FileInfo fileInfo) { FileDescriptor fileDesc = (FileDescriptor)fileDesc0; MakeWriteable(fileDesc); fileDesc.SetBasicInfo(fileAttributes, creationTime, lastAccessTime, lastWriteTime); return(fileDesc.GetFileInfo(out fileInfo)); }
public override Int32 Flush( Object fileNode, Object fileDesc0, out FileInfo fileInfo) { FileDescriptor fileDesc = (FileDescriptor)fileDesc0; if (null == fileDesc) { /* we do not flush the whole volume, so just return SUCCESS */ fileInfo = default(FileInfo); return(STATUS_SUCCESS); } fileDesc.Flush(); return(fileDesc.GetFileInfo(out fileInfo)); }
public override Int32 Write( Object fileNode, Object fileDesc0, IntPtr buffer, UInt64 offset, UInt32 length, Boolean writeToEndOfFile, Boolean constrainedIo, out UInt32 pBytesTransferred, out FileInfo fileInfo) { FileDescriptor fileDesc = (FileDescriptor)fileDesc0; MakeWriteable(fileDesc); FileStream stream = fileDesc.WriteStream; if (constrainedIo) { if (offset >= (UInt64)stream.Length) { pBytesTransferred = default(UInt32); fileInfo = default(FileInfo); return(STATUS_SUCCESS); } if (offset + length > (UInt64)stream.Length) { length = (UInt32)((UInt64)stream.Length - offset); } } Byte[] bytes = new byte[length]; Marshal.Copy(buffer, bytes, 0, bytes.Length); if (!writeToEndOfFile) { stream.Seek((Int64)offset, SeekOrigin.Begin); } stream.Write(bytes, 0, bytes.Length); pBytesTransferred = (UInt32)bytes.Length; return(fileDesc.GetFileInfo(out fileInfo)); }
public override Int32 SetFileSize( Object fileNode, Object fileDesc0, UInt64 newSize, Boolean setAllocationSize, out FileInfo fileInfo) { FileDescriptor fileDesc = (FileDescriptor)fileDesc0; MakeWriteable(fileDesc); if (!setAllocationSize || (UInt64)fileDesc.WriteStream.Length > newSize) { /* * "FileInfo.FileSize > NewSize" explanation: * Ptfs does not support allocation size. However if the new AllocationSize * is less than the current FileSize we must truncate the file. */ fileDesc.WriteStream.SetLength((Int64)newSize); } return(fileDesc.GetFileInfo(out fileInfo)); }