diff --git a/DokanNet/Dokan.cs b/DokanNet/Dokan.cs index 4a97778d..baec1d65 100644 --- a/DokanNet/Dokan.cs +++ b/DokanNet/Dokan.cs @@ -17,7 +17,7 @@ public class Dokan : IDisposable /// /// Initialize all required Dokan internal resources. /// - /// This needs to be called only once before trying to use or for the first time. + /// This needs to be called only once before trying to use for the first time. /// Otherwise both will fail and raise an exception. /// /// that will log all DokanNet debug informations. @@ -64,7 +64,7 @@ public bool RemoveMountPoint(string mountPoint) /// /// Dokan User FS file-change notifications /// - /// If is passed to , + /// If is passed to , /// the application implementing the user file system can notify /// the Dokan kernel driver of external file- and directory-changes. /// @@ -84,7 +84,7 @@ public class Notify /// /// Notify Dokan that a file or directory has been created. /// - /// The dokan mount context created by + /// The dokan mount context created by /// Absolute path to the file or directory, including the mount-point of the file system. /// Indicates if the path is a directory. /// true if the notification succeeded. @@ -96,7 +96,7 @@ public static bool Create(DokanInstance dokanInstance, string filePath, bool isD /// /// Notify Dokan that a file or directory has been deleted. /// - /// The dokan mount context created by + /// The dokan mount context created by /// Absolute path to the file or directory, including the mount-point of the file system. /// Indicates if the path is a directory. /// true if notification succeeded. @@ -109,7 +109,7 @@ public static bool Delete(DokanInstance dokanInstance, string filePath, bool isD /// /// Notify Dokan that file or directory attributes have changed. /// - /// The dokan mount context created by + /// The dokan mount context created by /// Absolute path to the file or directory, including the mount-point of the file system. /// true if notification succeeded. /// must be set in the mount options for this to succeed. @@ -121,7 +121,7 @@ public static bool Update(DokanInstance dokanInstance, string filePath) /// /// Notify Dokan that file or directory extended attributes have changed. /// - /// The dokan mount context created by + /// The dokan mount context created by /// Absolute path to the file or directory, including the mount-point of the file system. /// true if notification succeeded. /// must be set in the mount options for this to succeed. @@ -134,7 +134,7 @@ public static bool XAttrUpdate(DokanInstance dokanInstance, string filePath) /// Notify Dokan that a file or directory has been renamed. /// This method supports in-place rename for file/directory within the same parent. /// - /// The dokan mount context created by + /// The dokan mount context created by /// Old, absolute path to the file or directory, including the mount-point of the file system. /// New, absolute path to the file or directory, including the mount-point of the file system. /// Indicates if the path is a directory. @@ -150,6 +150,10 @@ public static bool Rename(DokanInstance dokanInstance, string oldPath, string ne } } + /// + /// Dispose the native Dokan Library resources + /// + /// Whether this was called from protected virtual void Dispose(bool disposing) { if (!_disposed) @@ -165,6 +169,9 @@ protected virtual void Dispose(bool disposing) } } + /// + /// Dispose the native Dokan Library resources + /// public void Dispose() { // Do not change this code. Put cleanup code in 'Dispose(bool disposing)' method @@ -172,7 +179,9 @@ public void Dispose() GC.SuppressFinalize(this); } - // override finalizer only if 'Dispose(bool disposing)' has code to free unmanaged resources + /// + /// Override finalizer only if 'Dispose(bool disposing)' has code to free unmanaged resources + /// ~Dokan() { // Do not change this code. Put cleanup code in 'Dispose(bool disposing)' method diff --git a/DokanNet/DokanInstance.cs b/DokanNet/DokanInstance.cs index bb5cc6e4..81d9d0f8 100644 --- a/DokanNet/DokanInstance.cs +++ b/DokanNet/DokanInstance.cs @@ -5,7 +5,7 @@ namespace DokanNet { /// - /// Created by . + /// Created by . /// It holds all the resources required to be alive for the time of the mount. /// public class DokanInstance : IDisposable @@ -49,6 +49,10 @@ private static DOKAN_OPERATIONS PrepareOperations(ILogger logger, IDokanOperatio internal DokanHandle DokanHandle { get; private set; } private readonly object _disposeLock; private bool _disposed = false; + + /// + /// Whether the object was already disposed. + /// public bool IsDisposed { get { lock (_disposeLock) return _disposed; } @@ -68,6 +72,10 @@ internal DokanInstance(ILogger logger, DOKAN_OPTIONS options, IDokanOperations o DokanHandle = handle; } + /// + /// Dispose the native Dokan Library resources + /// + /// Whether this was called from protected virtual void Dispose(bool disposing) { lock (_disposeLock) @@ -76,7 +84,6 @@ protected virtual void Dispose(bool disposing) { if (disposing) { - // Dispose managed state (managed objects) DokanHandle?.Dispose(); // This calls DokanCloseHandle and waits for dismount DokanOptions?.Dispose(); // After that, it is safe to free unmanaged memory DokanOperations?.Dispose(); @@ -94,12 +101,18 @@ protected virtual void Dispose(bool disposing) } } + /// + /// Destructor that force dispose + /// ~DokanInstance() { // Do not change this code. Put cleanup code in 'Dispose(bool disposing)' method Dispose(disposing: false); } + /// + /// Dispose the native Dokan Library resources + /// public void Dispose() { // Do not change this code. Put cleanup code in 'Dispose(bool disposing)' method diff --git a/DokanNet/DokanInstanceBuilder.cs b/DokanNet/DokanInstanceBuilder.cs index 89ddb845..346ea48d 100644 --- a/DokanNet/DokanInstanceBuilder.cs +++ b/DokanNet/DokanInstanceBuilder.cs @@ -9,19 +9,32 @@ namespace DokanNet { + /// + /// Dokan FileSystem build helper. Allows to create one or multiple based on a given configuration. + /// public class DokanInstanceBuilder { + /// + /// Delegate used by to customize th internal . + /// public delegate void OptionsConfigurationDelegate(DOKAN_OPTIONS options); + /// /// The Dokan version that DokanNet is compatible with. /// /// public const ushort DOKAN_VERSION = 200; + private readonly DOKAN_OPTIONS _options; + [SuppressMessage("CodeQuality", "IDE0052:Remove unread private members", Justification = "Dokan instance isn't really needed, a reference is kept to enforce a workflow")] private readonly Dokan _dokan; + private ILogger _logger; + /// + /// Constructure an object with a and default that will use the given . + /// public DokanInstanceBuilder(Dokan dokan) { _logger = new NullLogger(); @@ -40,21 +53,40 @@ public DokanInstanceBuilder(Dokan dokan) }; _dokan = dokan; } + + /// + /// Allows to set a custom like , to be used + /// for the instance created by . + /// public DokanInstanceBuilder ConfigureLogger(Func IlogegrFactory) { _logger = IlogegrFactory(); return this; } + + /// + /// Allows to personalize the use for . + /// public DokanInstanceBuilder ConfigureOptions(OptionsConfigurationDelegate optionsConfigurationDelegate) { optionsConfigurationDelegate(_options); return this; } + + /// + /// Verify that the provided configuration is valid. + /// Note: Has no effect for now. + /// public DokanInstanceBuilder Validate() { // throw on errors return this; } + + /// + /// Create a based on the previously provided information + /// through and . + /// public DokanInstance Build(IDokanOperations operations) { return new DokanInstance(_logger, _options, operations); diff --git a/DokanNet/DokanNet.csproj b/DokanNet/DokanNet.csproj index 54b650e4..9232fc3a 100644 --- a/DokanNet/DokanNet.csproj +++ b/DokanNet/DokanNet.csproj @@ -8,11 +8,12 @@ This is a .NET wrapper over Dokan, and allows you to create your own file systems in Windows. Copyright (C) 2022 - 2.0.5.1 - 2.0.5.1 - 2.0.5.1 + 2.0.5.2 + 2.0.5.2 + 2.0.5.2 True true + README.md Dokan-dev AdrienJ, MaximeC, Hiroki Asakawa https://dokan-dev.github.io/ @@ -34,6 +35,7 @@ This is a .NET wrapper over Dokan, and allows you to create your own file system + diff --git a/DokanNet/DokanOperationProxy.cs b/DokanNet/DokanOperationProxy.cs index 5ed8b902..2558662e 100644 --- a/DokanNet/DokanOperationProxy.cs +++ b/DokanNet/DokanOperationProxy.cs @@ -155,16 +155,6 @@ public delegate NtStatus SetFileSecurityDelegate( uint rawSecurityDescriptorLength, [MarshalAs(UnmanagedType.LPStruct), In /*, Out*/] DokanFileInfo rawFileInfo); - /// - /// Retrieve all FileStreams informations on the file. - /// This is only called if is enabled. - /// - /// Supported since 0.8.0. - /// You must specify the version at . - /// Filename - /// A to a . - /// A . - /// public delegate NtStatus FindStreamsDelegate( [MarshalAs(UnmanagedType.LPWStr)] string rawFileName, IntPtr rawFillFindData, @@ -781,7 +771,7 @@ public NtStatus FindStreamsProxy(string rawFileName, IntPtr rawFillFindData, Int /// A instance of the specified delegate type. /// The unmanaged function pointer to convert. /// The type of the delegate to return. - /// The generic parameter is not a delegate, or it is an open generic type. + /// The generic parameter is not a delegate, or it is an open generic type. /// The parameter is null. private static TDelegate GetDataFromPointer(IntPtr rawDelegate) where TDelegate : class { @@ -793,10 +783,10 @@ private static TDelegate GetDataFromPointer(IntPtr rawDelegate) where } /// - /// Call the delegate using data in and . + /// Call the delegate using data in and . /// /// The delegate of type to be called. - /// A to be used when calling . + /// A to be used when calling . /// A with information to be used when calling . /// Whether the buffer is full or not. private static bool AddTo(FILL_FIND_STREAM_DATA fill, IntPtr findStreamContext, FileInformation fi) diff --git a/DokanNet/Extensions.cs b/DokanNet/Extensions.cs index 8838b199..b59aeb8e 100644 --- a/DokanNet/Extensions.cs +++ b/DokanNet/Extensions.cs @@ -5,12 +5,15 @@ namespace DokanNet { + /// + /// extensions allowing to check whether it is running or to wait until it is unmount. + /// public static class Extensions { /// /// Check if the FileSystem is still running or not. /// - /// The dokan mount context created by . + /// The dokan mount context created by . /// Whether the FileSystem is still running or not. public static Boolean IsFileSystemRunning(this DokanInstance dokanInstance) { @@ -20,9 +23,9 @@ public static Boolean IsFileSystemRunning(this DokanInstance dokanInstance) /// /// Wait until the FileSystem is unmount. /// - /// The dokan mount context created by . - /// The time-out interval, in milliseconds. If a nonzero value is specified, the function waits until the object is signaled or the interval elapses. If is zero, - /// the function does not enter a wait state if the object is not signaled; it always returns immediately. If is INFINITE, the function will return only when the object is signaled. + /// The dokan mount context created by . + /// The time-out interval, in milliseconds. If a nonzero value is specified, the function waits until the object is signaled or the interval elapses. If set to zero, + /// the function does not enter a wait state if the object is not signaled; it always returns immediately. If set to INFINITE, the function will return only when the object is signaled. /// See WaitForSingleObject for a description of return values. public static UInt32 WaitForFileSystemClosed(this DokanInstance dokanInstance, UInt32 milliSeconds) { diff --git a/DokanNet/FileAccess.cs b/DokanNet/FileAccess.cs index 57076f9a..4c46ff09 100644 --- a/DokanNet/FileAccess.cs +++ b/DokanNet/FileAccess.cs @@ -27,7 +27,7 @@ public enum FileAccess : long /// /// \native /// \table - /// \nativeconst{FILE_READ_DATA,0x00000001,File & pipe} + /// \nativeconst{FILE_READ_DATA,0x00000001,File & pipe} /// \nativeconst{FILE_LIST_DIRECTORY,0x00000001,Directory} /// \endtable /// \endnative @@ -38,7 +38,7 @@ public enum FileAccess : long /// /// \native /// \table - /// \nativeconst{FILE_WRITE_DATA,0x00000002,File & pipe} + /// \nativeconst{FILE_WRITE_DATA,0x00000002,File & pipe} /// \nativeconst{FILE_ADD_FILE,0x00000002,Directory} /// \endtable /// \endnative @@ -61,7 +61,7 @@ public enum FileAccess : long /// /// \native /// \table - /// \nativeconst{FILE_READ_EA,0x00000008,File & directory} + /// \nativeconst{FILE_READ_EA,0x00000008,File & directory} /// \endtable /// \endnative ReadExtendedAttributes = 1L << 3, @@ -71,7 +71,7 @@ public enum FileAccess : long /// /// \native /// \table - /// \nativeconst{FILE_WRITE_EA,0x00000010,File & directory} + /// \nativeconst{FILE_WRITE_EA,0x00000010,File & directory} /// \endtable /// \endnative WriteExtendedAttributes = 1L << 4, diff --git a/DokanNet/IDokanOperations.cs b/DokanNet/IDokanOperations.cs index 60789668..8599a95a 100644 --- a/DokanNet/IDokanOperations.cs +++ b/DokanNet/IDokanOperations.cs @@ -3,9 +3,6 @@ using System.IO; using System.Security.AccessControl; -/// -/// Base namespace for %Dokan. -/// namespace DokanNet { /// @@ -354,7 +351,7 @@ NtStatus GetVolumeInformation( /// If is returned, dokan library will handle the request by /// building a sddl of the current process user with authenticate user rights for context menu. /// - /// \since Supported since version 0.6.0. You must specify the version in . + /// \since Supported since version 0.6.0. You must specify the during . /// /// File or directory name. /// A with security information to return. @@ -372,7 +369,7 @@ NtStatus GetFileSecurity( /// /// Sets the security of a file or directory object. /// - /// \since Supported since version 0.6.0. You must specify the version in . + /// \since Supported since version 0.6.0. You must specify the during . /// /// File path requested by the Kernel on the FileSystem. /// A with security information to set. @@ -413,7 +410,7 @@ NtStatus SetFileSecurity( /// /// For files, the first item in is information about the /// default data stream "::$DATA". - /// \since Supported since version 0.8.0. You must specify the version in . + /// \since Supported since version 0.8.0. You must specify the during . /// /// File path requested by the Kernel on the FileSystem. /// List of for each streams present on the file. @@ -423,12 +420,4 @@ NtStatus SetFileSecurity( /// \see About KTM (MSDN) NtStatus FindStreams(string fileName, out IList streams, IDokanFileInfo info); } -} - -/// -/// Namespace for AssemblyInfo and resource strings -/// -namespace DokanNet.Properties -{ - // This is only for documentation of the DokanNet.Properties namespace. -} +} \ No newline at end of file diff --git a/DokanNet/IDokanOperationsUnsafe.cs b/DokanNet/IDokanOperationsUnsafe.cs index cdcb4405..153ba577 100644 --- a/DokanNet/IDokanOperationsUnsafe.cs +++ b/DokanNet/IDokanOperationsUnsafe.cs @@ -15,7 +15,7 @@ namespace DokanNet public interface IDokanOperationsUnsafe : IDokanOperations { /// - /// ReadFile callback on the file previously opened in . + /// ReadFile callback on the file previously opened in . /// It can be called by different thread at the same time, /// therefore the read has to be thread safe. /// @@ -31,7 +31,7 @@ public interface IDokanOperationsUnsafe : IDokanOperations NtStatus ReadFile(string fileName, IntPtr buffer, uint bufferLength, out int bytesRead, long offset, IDokanFileInfo info); /// - /// WriteFile callback on the file previously opened in + /// WriteFile callback on the file previously opened in /// It can be called by different thread at the same time, /// therefore the write/context has to be thread safe. /// diff --git a/DokanNet/Logging/ConsoleLogger.cs b/DokanNet/Logging/ConsoleLogger.cs index 0526a9e6..2021de5c 100644 --- a/DokanNet/Logging/ConsoleLogger.cs +++ b/DokanNet/Logging/ConsoleLogger.cs @@ -83,6 +83,10 @@ private void WriteMessage(string message, ConsoleColor newColor) } } + /// + /// Dispose the object from the native resources. + /// + /// Whether it was call by protected virtual void Dispose(bool disposing) { if (!_disposed) @@ -100,13 +104,9 @@ protected virtual void Dispose(bool disposing) } } - // override finalizer only if 'Dispose(bool disposing)' has code to free unmanaged resources - // ~ConsoleLogger() - // { - // // Do not change this code. Put cleanup code in 'Dispose(bool disposing)' method - // Dispose(disposing: false); - // } - + /// + /// Dispose the object from the native resources. + /// public void Dispose() { // Do not change this code. Put cleanup code in 'Dispose(bool disposing)' method diff --git a/DokanNet/Logging/ILogger.cs b/DokanNet/Logging/ILogger.cs index 85535bd1..1fba8207 100644 --- a/DokanNet/Logging/ILogger.cs +++ b/DokanNet/Logging/ILogger.cs @@ -1,6 +1,3 @@ -/// -/// Namespace for interface and classes related to logging. -/// namespace DokanNet.Logging { /// diff --git a/DokanNet/MockDokanFileInfo.cs b/DokanNet/MockDokanFileInfo.cs index 455418a4..88e230b8 100644 --- a/DokanNet/MockDokanFileInfo.cs +++ b/DokanNet/MockDokanFileInfo.cs @@ -22,12 +22,8 @@ namespace DokanNet /// public sealed class MockDokanFileInfo : IDokanFileInfo { - public MockDokanFileInfo() - { - } - /// - /// A structure used to help the kernel notification functions work. + /// A structure used to help the kernel notification functions work. /// private DOKAN_OPTIONS _dokanOptions = new DOKAN_OPTIONS(); diff --git a/DokanNet/Native/BY_HANDLE_FILE_INFORMATION.cs b/DokanNet/Native/BY_HANDLE_FILE_INFORMATION.cs index 59d3bb28..4c4d80d5 100644 --- a/DokanNet/Native/BY_HANDLE_FILE_INFORMATION.cs +++ b/DokanNet/Native/BY_HANDLE_FILE_INFORMATION.cs @@ -26,7 +26,7 @@ namespace DokanNet.Native /// 10 milliseconds, write time has a resolution of 2 seconds, and access time has a resolution of /// 1 day (the access date). On the NTFS file system, access time has a resolution of 1 hour. /// - /// \see BY_HANDLE_FILE_INFORMATION structure (MSDN) + /// \see BY_HANDLE_FILE_INFORMATION structure (MSDN) [StructLayout(LayoutKind.Sequential, Pack = 4)] internal struct BY_HANDLE_FILE_INFORMATION { diff --git a/DokanNet/Native/DOKAN_OPTIONS.cs b/DokanNet/Native/DOKAN_OPTIONS.cs index dc3a1d8e..f870443f 100644 --- a/DokanNet/Native/DOKAN_OPTIONS.cs +++ b/DokanNet/Native/DOKAN_OPTIONS.cs @@ -45,10 +45,10 @@ public sealed class DOKAN_OPTIONS [MarshalAs(UnmanagedType.LPWStr)] public string UNCName; + private uint Timeout; /// /// Max timeout in milliseconds of each request before Dokan give up. /// - private uint Timeout; public System.TimeSpan TimeOut { get => System.TimeSpan.FromMilliseconds(Timeout); @@ -66,12 +66,12 @@ public System.TimeSpan TimeOut public uint SectorSize; /// /// Length of the optional VolumeSecurityDescriptor provided. Set 0 will disable the option. - /// + /// public uint VolumeSecurityDescriptorLength; /// /// Optional Volume Security descriptor. See InitializeSecurityDescriptor - /// + /// [MarshalAs(UnmanagedType.ByValArray, SizeConst = 16384, ArraySubType = UnmanagedType.U1)] public byte[] VolumeSecurityDescriptor; } diff --git a/DokanNet/Native/NativeMethods.cs b/DokanNet/Native/NativeMethods.cs index 6b24f18b..57e651f9 100644 --- a/DokanNet/Native/NativeMethods.cs +++ b/DokanNet/Native/NativeMethods.cs @@ -1,9 +1,6 @@ using System; using System.Runtime.InteropServices; -/// -/// Namespace for structures and classes related to native API. -/// namespace DokanNet.Native { /// @@ -68,8 +65,8 @@ internal static class NativeMethods /// Wait until the FileSystem is unmount. /// /// The dokan mount context created by . - /// The time-out interval, in milliseconds. If a nonzero value is specified, the function waits until the object is signaled or the interval elapses. If is zero, - /// the function does not enter a wait state if the object is not signaled; it always returns immediately. If is INFINITE, the function will return only when the object is signaled. + /// The time-out interval, in milliseconds. If a nonzero value is specified, the function waits until the object is signaled or the interval elapses. If set to zero, + /// the function does not enter a wait state if the object is not signaled; it always returns immediately. If set to INFINITE, the function will return only when the object is signaled. /// See WaitForSingleObject for a description of return values. [DllImport(DOKAN_DLL, ExactSpelling = true)] public static extern uint DokanWaitForFileSystemClosed(DokanHandle dokanInstance, uint milliSeconds); diff --git a/DokanNet/Native/WIN32_FIND_DATA.cs b/DokanNet/Native/WIN32_FIND_DATA.cs index 1a430197..23beb878 100644 --- a/DokanNet/Native/WIN32_FIND_DATA.cs +++ b/DokanNet/Native/WIN32_FIND_DATA.cs @@ -20,7 +20,7 @@ namespace DokanNet.Native /// 2 seconds, and access time has a resolution of 1 day. The NTFS file system delays updates to the last access time for /// a file by up to 1 hour after the last access.For more information, see File Times (MSDN). /// - /// \see WIN32_FIND_DATA structure (MSDN) + /// \see WIN32_FIND_DATA structure (MSDN) [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode, Pack = 4)] internal struct WIN32_FIND_DATA {