mirror of
https://github.com/winfsp/winfsp.git
synced 2025-04-22 08:23:05 -05:00
src: dotnet: refactor FileSystem class into FileSystemHost and FileSystemBase
This commit is contained in:
parent
8787f2c528
commit
1ee563cd13
@ -47,11 +47,14 @@
|
||||
<Reference Include="System" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="..\..\..\src\dotnet\FileSystem+Const.cs">
|
||||
<Link>FileSystem+Const.cs</Link>
|
||||
<Compile Include="..\..\..\src\dotnet\FileSystemBase+Const.cs">
|
||||
<Link>FileSystemBase+Const.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\..\..\src\dotnet\FileSystem.cs">
|
||||
<Link>FileSystem.cs</Link>
|
||||
<Compile Include="..\..\..\src\dotnet\FileSystemBase.cs">
|
||||
<Link>FileSystemBase.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\..\..\src\dotnet\FileSystemHost.cs">
|
||||
<Link>FileSystemHost.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\..\..\src\dotnet\Interop.cs">
|
||||
<Link>Interop.cs</Link>
|
||||
|
@ -1,5 +1,5 @@
|
||||
/**
|
||||
* @file dotnet/FileSystem+Const.cs
|
||||
* @file dotnet/FileSystemBase+Const.cs
|
||||
*
|
||||
* @copyright 2015-2017 Bill Zissimopoulos
|
||||
*/
|
||||
@ -20,7 +20,7 @@ using System;
|
||||
namespace Fsp
|
||||
{
|
||||
|
||||
public partial class FileSystem
|
||||
public partial class FileSystemBase
|
||||
{
|
||||
/* CreateOptions */
|
||||
public const UInt32 FILE_DIRECTORY_FILE = 0x00000001;
|
454
src/dotnet/FileSystemBase.cs
Normal file
454
src/dotnet/FileSystemBase.cs
Normal file
@ -0,0 +1,454 @@
|
||||
/**
|
||||
* @file dotnet/FileSystemBase.cs
|
||||
*
|
||||
* @copyright 2015-2017 Bill Zissimopoulos
|
||||
*/
|
||||
/*
|
||||
* This file is part of WinFsp.
|
||||
*
|
||||
* You can redistribute it and/or modify it under the terms of the GNU
|
||||
* General Public License version 3 as published by the Free Software
|
||||
* Foundation.
|
||||
*
|
||||
* Licensees holding a valid commercial license may use this file in
|
||||
* accordance with the commercial license agreement provided with the
|
||||
* software.
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Security.AccessControl;
|
||||
|
||||
using Fsp.Interop;
|
||||
|
||||
namespace Fsp
|
||||
{
|
||||
|
||||
public partial class FileSystemBase
|
||||
{
|
||||
/* types */
|
||||
public class DirectoryBuffer : IDisposable
|
||||
{
|
||||
~DirectoryBuffer()
|
||||
{
|
||||
Dispose(false);
|
||||
}
|
||||
public void Dispose()
|
||||
{
|
||||
lock (this)
|
||||
Dispose(true);
|
||||
GC.SuppressFinalize(true);
|
||||
}
|
||||
protected virtual void Dispose(bool disposing)
|
||||
{
|
||||
Api.FspFileSystemDeleteDirectoryBuffer(ref DirBuffer);
|
||||
}
|
||||
|
||||
internal IntPtr DirBuffer;
|
||||
}
|
||||
|
||||
/* operations */
|
||||
public virtual Int32 ExceptionHandler(Exception ex)
|
||||
{
|
||||
return STATUS_UNEXPECTED_IO_ERROR;
|
||||
}
|
||||
public virtual Int32 Init(Object Host)
|
||||
{
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
public virtual Int32 Mounted(Object Host)
|
||||
{
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
public virtual void Unmounted(Object Host)
|
||||
{
|
||||
}
|
||||
public virtual Int32 GetVolumeInfo(
|
||||
out VolumeInfo VolumeInfo)
|
||||
{
|
||||
VolumeInfo = default(VolumeInfo);
|
||||
return STATUS_INVALID_DEVICE_REQUEST;
|
||||
}
|
||||
public virtual Int32 SetVolumeLabel(
|
||||
String VolumeLabel,
|
||||
out VolumeInfo VolumeInfo)
|
||||
{
|
||||
VolumeInfo = default(VolumeInfo);
|
||||
return STATUS_INVALID_DEVICE_REQUEST;
|
||||
}
|
||||
public virtual Int32 GetSecurityByName(
|
||||
String FileName,
|
||||
out UInt32 FileAttributes/* or ReparsePointIndex */,
|
||||
ref Byte[] SecurityDescriptor)
|
||||
{
|
||||
FileAttributes = default(UInt32);
|
||||
return STATUS_INVALID_DEVICE_REQUEST;
|
||||
}
|
||||
public virtual Int32 Create(
|
||||
String FileName,
|
||||
UInt32 CreateOptions,
|
||||
UInt32 GrantedAccess,
|
||||
UInt32 FileAttributes,
|
||||
Byte[] SecurityDescriptor,
|
||||
UInt64 AllocationSize,
|
||||
out Object FileNode,
|
||||
out Object FileDesc,
|
||||
out FileInfo FileInfo,
|
||||
out String NormalizedName)
|
||||
{
|
||||
FileNode = default(Object);
|
||||
FileDesc = default(Object);
|
||||
FileInfo = default(FileInfo);
|
||||
NormalizedName = default(String);
|
||||
return STATUS_INVALID_DEVICE_REQUEST;
|
||||
}
|
||||
public virtual Int32 Open(
|
||||
String FileName,
|
||||
UInt32 CreateOptions,
|
||||
UInt32 GrantedAccess,
|
||||
out Object FileNode,
|
||||
out Object FileDesc,
|
||||
out FileInfo FileInfo,
|
||||
out String NormalizedName)
|
||||
{
|
||||
FileNode = default(Object);
|
||||
FileDesc = default(Object);
|
||||
FileInfo = default(FileInfo);
|
||||
NormalizedName = default(String);
|
||||
return STATUS_INVALID_DEVICE_REQUEST;
|
||||
}
|
||||
public virtual Int32 Overwrite(
|
||||
Object FileNode,
|
||||
Object FileDesc,
|
||||
UInt32 FileAttributes,
|
||||
Boolean ReplaceFileAttributes,
|
||||
UInt64 AllocationSize,
|
||||
out FileInfo FileInfo)
|
||||
{
|
||||
FileInfo = default(FileInfo);
|
||||
return STATUS_INVALID_DEVICE_REQUEST;
|
||||
}
|
||||
public virtual void Cleanup(
|
||||
Object FileNode,
|
||||
Object FileDesc,
|
||||
String FileName,
|
||||
UInt32 Flags)
|
||||
{
|
||||
}
|
||||
public virtual void Close(
|
||||
Object FileNode,
|
||||
Object FileDesc)
|
||||
{
|
||||
}
|
||||
public virtual Int32 Read(
|
||||
Object FileNode,
|
||||
Object FileDesc,
|
||||
IntPtr Buffer,
|
||||
UInt64 Offset,
|
||||
UInt32 Length,
|
||||
out UInt32 BytesTransferred)
|
||||
{
|
||||
BytesTransferred = default(UInt32);
|
||||
return STATUS_INVALID_DEVICE_REQUEST;
|
||||
}
|
||||
public virtual Int32 Write(
|
||||
Object FileNode,
|
||||
Object FileDesc,
|
||||
IntPtr Buffer,
|
||||
UInt64 Offset,
|
||||
UInt32 Length,
|
||||
Boolean WriteToEndOfFile,
|
||||
Boolean ConstrainedIo,
|
||||
out UInt32 BytesTransferred,
|
||||
out FileInfo FileInfo)
|
||||
{
|
||||
BytesTransferred = default(UInt32);
|
||||
FileInfo = default(FileInfo);
|
||||
return STATUS_INVALID_DEVICE_REQUEST;
|
||||
}
|
||||
public virtual Int32 Flush(
|
||||
Object FileNode,
|
||||
Object FileDesc,
|
||||
out FileInfo FileInfo)
|
||||
{
|
||||
FileInfo = default(FileInfo);
|
||||
return STATUS_INVALID_DEVICE_REQUEST;
|
||||
}
|
||||
public virtual Int32 GetFileInfo(
|
||||
Object FileNode,
|
||||
Object FileDesc,
|
||||
out FileInfo FileInfo)
|
||||
{
|
||||
FileInfo = default(FileInfo);
|
||||
return STATUS_INVALID_DEVICE_REQUEST;
|
||||
}
|
||||
public virtual Int32 SetBasicInfo(
|
||||
Object FileNode,
|
||||
Object FileDesc,
|
||||
UInt32 FileAttributes,
|
||||
UInt64 CreationTime,
|
||||
UInt64 LastAccessTime,
|
||||
UInt64 LastWriteTime,
|
||||
UInt64 ChangeTime,
|
||||
out FileInfo FileInfo)
|
||||
{
|
||||
FileInfo = default(FileInfo);
|
||||
return STATUS_INVALID_DEVICE_REQUEST;
|
||||
}
|
||||
public virtual Int32 SetFileSize(
|
||||
Object FileNode,
|
||||
Object FileDesc,
|
||||
UInt64 NewSize,
|
||||
Boolean SetAllocationSize,
|
||||
out FileInfo FileInfo)
|
||||
{
|
||||
FileInfo = default(FileInfo);
|
||||
return STATUS_INVALID_DEVICE_REQUEST;
|
||||
}
|
||||
public virtual Int32 CanDelete(
|
||||
Object FileNode,
|
||||
Object FileDesc,
|
||||
String FileName)
|
||||
{
|
||||
return STATUS_INVALID_DEVICE_REQUEST;
|
||||
}
|
||||
public virtual Int32 Rename(
|
||||
Object FileNode,
|
||||
Object FileDesc,
|
||||
String FileName,
|
||||
String NewFileName,
|
||||
Boolean ReplaceIfExists)
|
||||
{
|
||||
return STATUS_INVALID_DEVICE_REQUEST;
|
||||
}
|
||||
public virtual Int32 GetSecurity(
|
||||
Object FileNode,
|
||||
Object FileDesc,
|
||||
ref Byte[] SecurityDescriptor)
|
||||
{
|
||||
return STATUS_INVALID_DEVICE_REQUEST;
|
||||
}
|
||||
public virtual Int32 SetSecurity(
|
||||
Object FileNode,
|
||||
Object FileDesc,
|
||||
AccessControlSections Sections,
|
||||
Byte[] SecurityDescriptor)
|
||||
{
|
||||
return STATUS_INVALID_DEVICE_REQUEST;
|
||||
}
|
||||
public virtual Int32 ReadDirectory(
|
||||
Object FileNode,
|
||||
Object FileDesc,
|
||||
String Pattern,
|
||||
String Marker,
|
||||
IntPtr Buffer,
|
||||
UInt32 Length,
|
||||
out UInt32 BytesTransferred)
|
||||
{
|
||||
return SeekableReadDirectory(FileNode, FileDesc, Pattern, Marker, Buffer, Length,
|
||||
out BytesTransferred);
|
||||
}
|
||||
public virtual Boolean ReadDirectoryEntry(
|
||||
Object FileNode,
|
||||
Object FileDesc,
|
||||
String Pattern,
|
||||
String Marker,
|
||||
ref Object Context,
|
||||
out String FileName,
|
||||
out FileInfo FileInfo)
|
||||
{
|
||||
FileName = default(String);
|
||||
FileInfo = default(FileInfo);
|
||||
return false;
|
||||
}
|
||||
public virtual Int32 ResolveReparsePoints(
|
||||
String FileName,
|
||||
UInt32 ReparsePointIndex,
|
||||
Boolean ResolveLastPathComponent,
|
||||
out IoStatusBlock IoStatus,
|
||||
IntPtr Buffer,
|
||||
ref UIntPtr Size)
|
||||
{
|
||||
GCHandle Handle = GCHandle.Alloc(this, GCHandleType.Normal);
|
||||
try
|
||||
{
|
||||
return Api.FspFileSystemResolveReparsePoints(
|
||||
IntPtr.Zero,
|
||||
GetReparsePointByName,
|
||||
(IntPtr)Handle,
|
||||
FileName,
|
||||
ReparsePointIndex,
|
||||
ResolveLastPathComponent,
|
||||
out IoStatus,
|
||||
Buffer,
|
||||
ref Size);
|
||||
}
|
||||
finally
|
||||
{
|
||||
Handle.Free();
|
||||
}
|
||||
}
|
||||
public virtual Int32 GetReparsePointByName(
|
||||
String FileName,
|
||||
Boolean IsDirectory,
|
||||
IntPtr Buffer,
|
||||
ref UIntPtr Size)
|
||||
{
|
||||
return STATUS_INVALID_DEVICE_REQUEST;
|
||||
}
|
||||
public virtual Int32 GetReparsePoint(
|
||||
Object FileNode,
|
||||
Object FileDesc,
|
||||
String FileName,
|
||||
IntPtr Buffer,
|
||||
out UIntPtr Size)
|
||||
{
|
||||
Size = default(UIntPtr);
|
||||
return STATUS_INVALID_DEVICE_REQUEST;
|
||||
}
|
||||
public virtual Int32 SetReparsePoint(
|
||||
Object FileNode,
|
||||
Object FileDesc,
|
||||
String FileName,
|
||||
IntPtr Buffer,
|
||||
UIntPtr Size)
|
||||
{
|
||||
return STATUS_INVALID_DEVICE_REQUEST;
|
||||
}
|
||||
public virtual Int32 DeleteReparsePoint(
|
||||
Object FileNode,
|
||||
Object FileDesc,
|
||||
String FileName,
|
||||
IntPtr Buffer,
|
||||
UIntPtr Size)
|
||||
{
|
||||
return STATUS_INVALID_DEVICE_REQUEST;
|
||||
}
|
||||
public virtual Int32 GetStreamInfo(
|
||||
Object FileNode,
|
||||
Object FileDesc,
|
||||
IntPtr Buffer,
|
||||
UInt32 Length,
|
||||
out UInt32 BytesTransferred)
|
||||
{
|
||||
BytesTransferred = default(UInt32);
|
||||
return STATUS_INVALID_DEVICE_REQUEST;
|
||||
}
|
||||
|
||||
/* helpers */
|
||||
public static Int32 NtStatusFromWin32(UInt32 Error)
|
||||
{
|
||||
return Api.FspNtStatusFromWin32(Error);
|
||||
}
|
||||
public static UInt32 Win32FromNtStatus(Int32 Status)
|
||||
{
|
||||
return Api.FspWin32FromNtStatus(Status);
|
||||
}
|
||||
public Int32 SeekableReadDirectory(
|
||||
Object FileNode,
|
||||
Object FileDesc,
|
||||
String Pattern,
|
||||
String Marker,
|
||||
IntPtr Buffer,
|
||||
UInt32 Length,
|
||||
out UInt32 BytesTransferred)
|
||||
{
|
||||
Object Context = null;
|
||||
String FileName;
|
||||
DirInfo DirInfo = default(DirInfo);
|
||||
BytesTransferred = default(UInt32);
|
||||
while (ReadDirectoryEntry(FileNode, FileDesc, Pattern, Marker,
|
||||
ref Context, out FileName, out DirInfo.FileInfo))
|
||||
{
|
||||
DirInfo.SetFileNameBuf(FileName);
|
||||
if (!Api.FspFileSystemAddDirInfo(ref DirInfo, Buffer, Length,
|
||||
out BytesTransferred))
|
||||
break;
|
||||
}
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
public Int32 BufferedReadDirectory(
|
||||
DirectoryBuffer DirectoryBuffer,
|
||||
Object FileNode,
|
||||
Object FileDesc,
|
||||
String Pattern,
|
||||
String Marker,
|
||||
IntPtr Buffer,
|
||||
UInt32 Length,
|
||||
out UInt32 BytesTransferred)
|
||||
{
|
||||
Object Context = null;
|
||||
String FileName;
|
||||
DirInfo DirInfo = default(DirInfo);
|
||||
Int32 DirBufferResult = STATUS_SUCCESS;
|
||||
BytesTransferred = default(UInt32);
|
||||
if (Api.FspFileSystemAcquireDirectoryBuffer(ref DirectoryBuffer.DirBuffer, null == Marker,
|
||||
out DirBufferResult))
|
||||
try
|
||||
{
|
||||
while (ReadDirectoryEntry(FileNode, FileDesc, Pattern, Marker,
|
||||
ref Context, out FileName, out DirInfo.FileInfo))
|
||||
{
|
||||
DirInfo.SetFileNameBuf(FileName);
|
||||
if (!Api.FspFileSystemFillDirectoryBuffer(
|
||||
ref DirectoryBuffer.DirBuffer, ref DirInfo, out DirBufferResult))
|
||||
break;
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
Api.FspFileSystemReleaseDirectoryBuffer(ref DirectoryBuffer.DirBuffer);
|
||||
}
|
||||
if (0 > DirBufferResult)
|
||||
{
|
||||
BytesTransferred = default(UInt32);
|
||||
return DirBufferResult;
|
||||
}
|
||||
Api.FspFileSystemReadDirectoryBuffer(ref DirectoryBuffer.DirBuffer,
|
||||
Marker, Buffer, Length, out BytesTransferred);
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
public Int32 FindReparsePoint(
|
||||
String FileName,
|
||||
out UInt32 ReparsePointIndex)
|
||||
{
|
||||
GCHandle Handle = GCHandle.Alloc(this, GCHandleType.Normal);
|
||||
try
|
||||
{
|
||||
return Api.FspFileSystemFindReparsePoint(
|
||||
IntPtr.Zero,
|
||||
GetReparsePointByName,
|
||||
(IntPtr)Handle,
|
||||
FileName,
|
||||
out ReparsePointIndex);
|
||||
}
|
||||
finally
|
||||
{
|
||||
Handle.Free();
|
||||
}
|
||||
}
|
||||
private static Int32 GetReparsePointByName(
|
||||
IntPtr FileSystem,
|
||||
IntPtr Context,
|
||||
String FileName,
|
||||
Boolean IsDirectory,
|
||||
IntPtr Buffer,
|
||||
ref UIntPtr Size)
|
||||
{
|
||||
FileSystemBase self = (FileSystemBase)GCHandle.FromIntPtr(Context).Target;
|
||||
try
|
||||
{
|
||||
return self.GetReparsePointByName(
|
||||
FileName,
|
||||
IsDirectory,
|
||||
Buffer,
|
||||
ref Size);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return self.ExceptionHandler(ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
File diff suppressed because it is too large
Load Diff
@ -27,7 +27,7 @@ using FileInfo = Fsp.Interop.FileInfo;
|
||||
|
||||
namespace passthrough
|
||||
{
|
||||
class Ptfs : FileSystem
|
||||
class Ptfs : FileSystemBase
|
||||
{
|
||||
protected const int ALLOCATION_UNIT = 4096;
|
||||
|
||||
@ -277,40 +277,41 @@ namespace passthrough
|
||||
private static DirectoryEntryComparer _DirectoryEntryComparer =
|
||||
new DirectoryEntryComparer();
|
||||
|
||||
public Ptfs() : base()
|
||||
public Ptfs(String Path0)
|
||||
{
|
||||
SectorSize = ALLOCATION_UNIT;
|
||||
SectorsPerAllocationUnit = 1;
|
||||
MaxComponentLength = 255;
|
||||
FileInfoTimeout = 1000;
|
||||
CaseSensitiveSearch = false;
|
||||
CasePreservedNames = true;
|
||||
UnicodeOnDisk = true;
|
||||
PersistentAcls = true;
|
||||
PostCleanupWhenModifiedOnly = true;
|
||||
PassQueryDirectoryPattern = true;
|
||||
}
|
||||
public void SetPath(String value)
|
||||
{
|
||||
_Path = Path.GetFullPath(value);
|
||||
_Path = Path.GetFullPath(Path0);
|
||||
if (_Path.EndsWith("\\"))
|
||||
_Path = _Path.Substring(0, _Path.Length - 1);
|
||||
VolumeCreationTime = (UInt64)File.GetCreationTimeUtc(_Path).ToFileTimeUtc();
|
||||
VolumeSerialNumber = 0;
|
||||
}
|
||||
|
||||
protected override Int32 ExceptionHandler(Exception ex)
|
||||
public String ConcatPath(String FileName)
|
||||
{
|
||||
return _Path + FileName;
|
||||
}
|
||||
public override Int32 ExceptionHandler(Exception ex)
|
||||
{
|
||||
Int32 HResult = ex.HResult; /* needs Framework 4.5 */
|
||||
if (0x80070000 == (HResult & 0xFFFF0000))
|
||||
return NtStatusFromWin32((UInt32)HResult & 0xFFFF);
|
||||
return STATUS_UNEXPECTED_IO_ERROR;
|
||||
}
|
||||
protected String ConcatPath(String FileName)
|
||||
public override Int32 Init(Object Host0)
|
||||
{
|
||||
return _Path + FileName;
|
||||
FileSystemHost Host = (FileSystemHost)Host0;
|
||||
Host.SectorSize = ALLOCATION_UNIT;
|
||||
Host.SectorsPerAllocationUnit = 1;
|
||||
Host.MaxComponentLength = 255;
|
||||
Host.FileInfoTimeout = 1000;
|
||||
Host.CaseSensitiveSearch = false;
|
||||
Host.CasePreservedNames = true;
|
||||
Host.UnicodeOnDisk = true;
|
||||
Host.PersistentAcls = true;
|
||||
Host.PostCleanupWhenModifiedOnly = true;
|
||||
Host.PassQueryDirectoryPattern = true;
|
||||
Host.VolumeCreationTime = (UInt64)File.GetCreationTimeUtc(_Path).ToFileTimeUtc();
|
||||
Host.VolumeSerialNumber = 0;
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
protected override Int32 GetVolumeInfo(
|
||||
public override Int32 GetVolumeInfo(
|
||||
out VolumeInfo VolumeInfo)
|
||||
{
|
||||
VolumeInfo = default(VolumeInfo);
|
||||
@ -329,7 +330,7 @@ namespace passthrough
|
||||
}
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
protected override Int32 GetSecurityByName(
|
||||
public override Int32 GetSecurityByName(
|
||||
String FileName,
|
||||
out UInt32 FileAttributes/* or ReparsePointIndex */,
|
||||
ref Byte[] SecurityDescriptor)
|
||||
@ -341,7 +342,7 @@ namespace passthrough
|
||||
SecurityDescriptor = Info.GetAccessControl().GetSecurityDescriptorBinaryForm();
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
protected override Int32 Create(
|
||||
public override Int32 Create(
|
||||
String FileName,
|
||||
UInt32 CreateOptions,
|
||||
UInt32 GrantedAccess,
|
||||
@ -401,7 +402,7 @@ namespace passthrough
|
||||
throw;
|
||||
}
|
||||
}
|
||||
protected override Int32 Open(
|
||||
public override Int32 Open(
|
||||
String FileName,
|
||||
UInt32 CreateOptions,
|
||||
UInt32 GrantedAccess,
|
||||
@ -442,7 +443,7 @@ namespace passthrough
|
||||
throw;
|
||||
}
|
||||
}
|
||||
protected override Int32 Overwrite(
|
||||
public override Int32 Overwrite(
|
||||
Object FileNode,
|
||||
Object FileDesc0,
|
||||
UInt32 FileAttributes,
|
||||
@ -458,7 +459,7 @@ namespace passthrough
|
||||
FileDesc.Stream.SetLength(0);
|
||||
return FileDesc.GetFileInfo(out FileInfo);
|
||||
}
|
||||
protected override void Cleanup(
|
||||
public override void Cleanup(
|
||||
Object FileNode,
|
||||
Object FileDesc0,
|
||||
String FileName,
|
||||
@ -472,7 +473,7 @@ namespace passthrough
|
||||
FileDesc.Stream.Dispose();
|
||||
}
|
||||
}
|
||||
protected override void Close(
|
||||
public override void Close(
|
||||
Object FileNode,
|
||||
Object FileDesc0)
|
||||
{
|
||||
@ -480,7 +481,7 @@ namespace passthrough
|
||||
if (null != FileDesc.Stream)
|
||||
FileDesc.Stream.Dispose();
|
||||
}
|
||||
protected override Int32 Read(
|
||||
public override Int32 Read(
|
||||
Object FileNode,
|
||||
Object FileDesc0,
|
||||
IntPtr Buffer,
|
||||
@ -497,7 +498,7 @@ namespace passthrough
|
||||
Marshal.Copy(Bytes, 0, Buffer, Bytes.Length);
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
protected override Int32 Write(
|
||||
public override Int32 Write(
|
||||
Object FileNode,
|
||||
Object FileDesc0,
|
||||
IntPtr Buffer,
|
||||
@ -528,7 +529,7 @@ namespace passthrough
|
||||
PBytesTransferred = (UInt32)Bytes.Length;
|
||||
return FileDesc.GetFileInfo(out FileInfo);
|
||||
}
|
||||
protected override Int32 Flush(
|
||||
public override Int32 Flush(
|
||||
Object FileNode,
|
||||
Object FileDesc0,
|
||||
out FileInfo FileInfo)
|
||||
@ -543,7 +544,7 @@ namespace passthrough
|
||||
FileDesc.Stream.Flush(true);
|
||||
return FileDesc.GetFileInfo(out FileInfo);
|
||||
}
|
||||
protected override Int32 GetFileInfo(
|
||||
public override Int32 GetFileInfo(
|
||||
Object FileNode,
|
||||
Object FileDesc0,
|
||||
out FileInfo FileInfo)
|
||||
@ -551,7 +552,7 @@ namespace passthrough
|
||||
FileDesc FileDesc = (FileDesc)FileDesc0;
|
||||
return FileDesc.GetFileInfo(out FileInfo);
|
||||
}
|
||||
protected override Int32 SetBasicInfo(
|
||||
public override Int32 SetBasicInfo(
|
||||
Object FileNode,
|
||||
Object FileDesc0,
|
||||
UInt32 FileAttributes,
|
||||
@ -565,7 +566,7 @@ namespace passthrough
|
||||
FileDesc.SetBasicInfo(FileAttributes, CreationTime, LastAccessTime, LastWriteTime);
|
||||
return FileDesc.GetFileInfo(out FileInfo);
|
||||
}
|
||||
protected override Int32 SetFileSize(
|
||||
public override Int32 SetFileSize(
|
||||
Object FileNode,
|
||||
Object FileDesc0,
|
||||
UInt64 NewSize,
|
||||
@ -584,7 +585,7 @@ namespace passthrough
|
||||
}
|
||||
return FileDesc.GetFileInfo(out FileInfo);
|
||||
}
|
||||
protected override Int32 CanDelete(
|
||||
public override Int32 CanDelete(
|
||||
Object FileNode,
|
||||
Object FileDesc0,
|
||||
String FileName)
|
||||
@ -593,7 +594,7 @@ namespace passthrough
|
||||
FileDesc.SetDisposition(false);
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
protected override Int32 Rename(
|
||||
public override Int32 Rename(
|
||||
Object FileNode,
|
||||
Object FileDesc0,
|
||||
String FileName,
|
||||
@ -605,7 +606,7 @@ namespace passthrough
|
||||
FileDesc.Rename(FileName, NewFileName, ReplaceIfExists);
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
protected override Int32 GetSecurity(
|
||||
public override Int32 GetSecurity(
|
||||
Object FileNode,
|
||||
Object FileDesc0,
|
||||
ref Byte[] SecurityDescriptor)
|
||||
@ -614,7 +615,7 @@ namespace passthrough
|
||||
SecurityDescriptor = FileDesc.GetSecurityDescriptor();
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
protected override Int32 SetSecurity(
|
||||
public override Int32 SetSecurity(
|
||||
Object FileNode,
|
||||
Object FileDesc0,
|
||||
AccessControlSections Sections,
|
||||
@ -624,7 +625,7 @@ namespace passthrough
|
||||
FileDesc.SetSecurityDescriptor(Sections, SecurityDescriptor);
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
protected override Boolean ReadDirectoryEntry(
|
||||
public override Boolean ReadDirectoryEntry(
|
||||
Object FileNode,
|
||||
Object FileDesc0,
|
||||
String Pattern,
|
||||
@ -703,7 +704,6 @@ namespace passthrough
|
||||
|
||||
protected override void OnStart(String[] Args)
|
||||
{
|
||||
String FailMessage = null;
|
||||
try
|
||||
{
|
||||
String DebugLogFile = null;
|
||||
@ -712,6 +712,7 @@ namespace passthrough
|
||||
String PassThrough = null;
|
||||
String MountPoint = null;
|
||||
IntPtr DebugLogHandle = (IntPtr)(-1);
|
||||
FileSystemHost Host = null;
|
||||
Ptfs Ptfs = null;
|
||||
int I;
|
||||
|
||||
@ -770,18 +771,15 @@ namespace passthrough
|
||||
throw new CommandLineUsageException();
|
||||
|
||||
if (null != DebugLogFile)
|
||||
if (0 > FileSystem.SetDebugLogFile(DebugLogFile))
|
||||
if (0 > FileSystemHost.SetDebugLogFile(DebugLogFile))
|
||||
throw new CommandLineUsageException("cannot open debug log file");
|
||||
|
||||
FailMessage = "cannot create file system";
|
||||
Ptfs = new Ptfs();
|
||||
Ptfs.Prefix = VolumePrefix;
|
||||
Ptfs.SetPath(PassThrough);
|
||||
|
||||
FailMessage = "cannot mount file system";
|
||||
Ptfs.Mount(MountPoint, null, true, DebugFlags);
|
||||
MountPoint = Ptfs.MountPoint();
|
||||
_Ptfs = Ptfs;
|
||||
Host = new FileSystemHost(Ptfs = new Ptfs(PassThrough));
|
||||
Host.Prefix = VolumePrefix;
|
||||
if (0 > Host.Mount(MountPoint, null, true, DebugFlags))
|
||||
throw new IOException("cannot mount file system");
|
||||
MountPoint = Host.MountPoint();
|
||||
_Host = Host;
|
||||
|
||||
Log(EVENTLOG_INFORMATION_TYPE, String.Format("{0}{1}{2} -p {3} -m {4}",
|
||||
PROGNAME,
|
||||
@ -808,16 +806,14 @@ namespace passthrough
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log(EVENTLOG_ERROR_TYPE, String.Format("{0}{1}",
|
||||
null != FailMessage ? FailMessage + "\n" : "",
|
||||
ex.Message));
|
||||
Log(EVENTLOG_ERROR_TYPE, String.Format("{0}", ex.Message));
|
||||
throw;
|
||||
}
|
||||
}
|
||||
protected override void OnStop()
|
||||
{
|
||||
_Ptfs.Unmount();
|
||||
_Ptfs = null;
|
||||
_Host.Unmount();
|
||||
_Host = null;
|
||||
}
|
||||
|
||||
private static void argtos(String[] Args, ref int I, ref String V)
|
||||
@ -836,7 +832,7 @@ namespace passthrough
|
||||
throw new CommandLineUsageException();
|
||||
}
|
||||
|
||||
private Ptfs _Ptfs;
|
||||
private FileSystemHost _Host;
|
||||
}
|
||||
|
||||
class Program
|
||||
|
Loading…
x
Reference in New Issue
Block a user