コード例 #1
0
            private Fixture()
            {
                _operations = new ProxyGenerator().CreateInterfaceProxyWithTargetInterface <IDokanOperations>(null, _interceptor);

                var loggerMock = new Mock <ILogger>();

                loggerMock.Setup(l => l.Info(It.IsAny <string>())).Callback((string message) => Console.WriteLine(message));
                _logger = loggerMock.Object;

                Reset(null);
                SetupGetRoot();

                // DokanOptions.RemovableDrive
                // HACK: handle non-unique parameter set of DokanOperations.Mount() by explicitely specifying AllocationUnitSize and SectorSize
                var options = DokanOptions.DebugMode | DokanOptions.NetworkDrive | DokanOptions.MountManager | DokanOptions.CurrentSession | DokanOptions.UserModeLock;

                (_mounterThread = new Thread(new ThreadStart(() =>
                                                             _operations.Mount(MOUNT_POINT, options, 5, 121, TimeSpan.FromMinutes(5), null, 512, 512)))).Start();
                var mountedDrive = GetDriveInfo();

                while (!mountedDrive.IsReady)
                {
                    Thread.Sleep(50);
                }
            }
コード例 #2
0
ファイル: SettingForm.cs プロジェクト: kwikwag/dokan-sshfs
 public MountWorker(IDokanOperations sshfs, DokanOptions opt, string mountPoint, int threadCount)
 {
     sshfs_       = sshfs;
     opt_         = opt;
     mountPoint_  = mountPoint;
     threadCount_ = threadCount;
 }
コード例 #3
0
        NtStatus IDokanOperations.CreateFile(string fileName, FileAccess access, FileShare share, FileMode mode,
                                             FileOptions options,
                                             FileAttributes attributes, IDokanFileInfo info)
        {
            if (info.IsDirectory)
            {
                if (mode == FileMode.Open)
                {
                    return(OpenDirectory(fileName, info));
                }
                if (mode == FileMode.CreateNew)
                {
                    return(CreateDirectory(fileName, info));
                }

                return(NtStatus.NotImplemented);
            }

            if (fileName.EndsWith("desktop.ini", StringComparison.OrdinalIgnoreCase) ||
                fileName.EndsWith("autorun.inf", StringComparison.OrdinalIgnoreCase))
            {
                return(NtStatus.NoSuchFile);
            }

            SftpDrive drive = this.GetDriveByMountPoint(fileName, out fileName);

            LogFSActionInit("OpenFile", fileName, drive, "Mode:{0}", mode);
            if (drive != null)
            {
                LogFSActionSuccess("OpenFile", fileName, drive, "Mode:{0} NonVFS", mode);
                IDokanOperations idops = GetSubSystemOperations(drive);
                return(idops?.CreateFile(fileName, access, share, mode, options, attributes, info) ??
                       NtStatus.AccessDenied);                //AccessDenied happens if mounting failed
            }

            //check against mountpoints if virtual dir exists
            string path = fileName.Substring(1);

            if (path == "")
            {
                //info.IsDirectory = true;
                info.Context = null;
                LogFSActionSuccess("OpenFile", fileName, null, "VFS root");
                return(NtStatus.Success);
            }

            foreach (var drive2 in this._subsytems.Where(drive2 => drive2.MountPoint.Length > 0)
                     .Where(drive2 => drive2.MountPoint.IndexOf(path) == 0))
            {
                info.IsDirectory = true;
                info.Context     = drive2;
                LogFSActionSuccess("OpenFile", fileName, drive2, "VFS (sub)mountpoint");
                return(NtStatus.Success);
            }

            //pathnotfound detection?
            LogFSActionError("OpenFile", fileName, null, "File not found");
            return(NtStatus.NoSuchFile);
        }
コード例 #4
0
        private NtStatus OpenDirectory(string fileName, IDokanFileInfo info)
        {
            SftpDrive drive = this.GetDriveByMountPoint(fileName, out fileName);

            LogFSActionInit("OpenDir", fileName, drive, "");

            if (drive != null)
            {
                lastActiveSubsytem = drive;

                IDokanOperations ops = GetSubSystemOperations(drive);
                if (ops == null)
                {
                    LogFSActionError("OpenDir", fileName, drive, "Cannot open, mount failed?");
                    return(NtStatus.AccessDenied);
                }

                LogFSActionSuccess("OpenDir", fileName, drive, "Found, subsytem");
                return(ops.CreateFile(fileName, FileAccess.GenericRead, FileShare.None, FileMode.Open, FileOptions.None,
                                      FileAttributes.Directory, info));
            }

            if (fileName.Length == 1)            //root dir
            {
                LogFSActionSuccess("OpenDir", fileName, drive, "Found, VFS root");
                info.IsDirectory = true;
                return(NtStatus.Success);
            }

            //root test should keep lastactive if drag and drop(win8)
            lastActiveSubsytem = null;

            string path = fileName.Substring(1);             //cut leading \

            foreach (SftpDrive subdrive in _subsytems)
            {
                string mp = subdrive.MountPoint;                 //  mp1 || mp1\mp2 ...
                if (path == mp)
                {
                    info.Context     = subdrive;
                    info.IsDirectory = true;
                    LogFSActionSuccess("OpenDir", fileName, drive, "Found, final mountpoint");
                    return(NtStatus.Success);
                }

                if (mp.IndexOf(path + '\\') == 0)
                {
                    //path is part of mount point
                    info.Context     = subdrive;
                    info.IsDirectory = true;
                    LogFSActionSuccess("OpenDir", fileName, drive, "Found, part of mountpoint");
                    return(NtStatus.Success);
                }
            }

            LogFSActionError("OpenDir", fileName, drive, "Path not found");
            return(NtStatus.ObjectPathNotFound);
        }
コード例 #5
0
        DokanError IDokanOperations.CreateFile(string fileName, FileAccess access, FileShare share,
                                               FileMode mode, FileOptions options,
                                               FileAttributes attributes, DokanFileInfo info)
        {
            if (fileName.EndsWith("desktop.ini", StringComparison.OrdinalIgnoreCase) ||
                fileName.EndsWith("autorun.inf", StringComparison.OrdinalIgnoreCase)) //....
            {
                return(DokanError.ErrorFileNotFound);
            }

            SftpDrive drive = this.GetDriveByMountPoint(fileName, out fileName);

            LogFSActionInit("OpenFile", fileName, drive, "Mode:{0}", mode);
            if (drive != null)
            {
                LogFSActionSuccess("OpenFile", fileName, drive, "Mode:{0} NonVFS", mode);
                IDokanOperations idops = GetSubSystemOperations(drive);
                if (idops == null)
                {
                    //this happens if mounting failed
                    return(DokanError.ErrorAccessDenied);
                }
                return(idops.CreateFile(fileName, access, share, mode, options, attributes, info));
            }

            //check against mountpoints if virtual dir exists

            string path = fileName.Substring(1);

            if (path == "")
            {
                info.IsDirectory = true;
                info.Context     = null;
                LogFSActionSuccess("OpenFile", fileName, null, "VFS root");
                return(DokanError.ErrorSuccess);
            }
            foreach (SftpDrive drive2 in this._subsytems)
            {
                if (drive2.MountPoint.Length > 0)
                {
                    if (drive2.MountPoint.IndexOf(path) == 0)
                    {
                        info.IsDirectory = true;
                        info.Context     = drive2;
                        LogFSActionSuccess("OpenFile", fileName, drive2, "VFS (sub)mountpoint");
                        return(DokanError.ErrorSuccess);
                    }
                }
            }

            //pathnotfound detection?

            LogFSActionError("OpenFile", fileName, null, "File not found");
            return(DokanError.ErrorFileNotFound);
        }
コード例 #6
0
ファイル: Dokan.cs プロジェクト: jokalee/Liquesce
#pragma warning restore 169
// ReSharper restore InconsistentNaming



        public static int DokanMain(DokanOptions options, IDokanOperations operations)
        {
            Log.Info("Start DokanMain");
            if (String.IsNullOrEmpty(options.VolumeLabel))
            {
                options.VolumeLabel = "DOKAN";
            }

            Proxy proxy = new Proxy(options, operations);

            var dokanOptions = new DOKAN_OPTIONS
            {
                Version     = options.Version != 0 ? options.Version : DOKAN_VERSION,
                MountPoint  = options.MountPoint,
                ThreadCount = options.ThreadCount
            };

            dokanOptions.Options |= options.RemovableDrive ? DOKAN_OPTION_REMOVABLE : 0;
            dokanOptions.Options |= options.DebugMode ? DOKAN_OPTION_DEBUG : 0;
            dokanOptions.Options |= options.UseStdErr ? DOKAN_OPTION_STDERR : 0;
            dokanOptions.Options |= options.UseAltStream ? DOKAN_OPTION_ALT_STREAM : 0;
            dokanOptions.Options |= options.UseKeepAlive ? DOKAN_OPTION_KEEP_ALIVE : 0;
            dokanOptions.Options |= options.NetworkDrive ? DOKAN_OPTION_NETWORK : 0;

            var dokanOperations = new DOKAN_OPERATIONS
            {
                CreateFile           = proxy.CreateFileProxy,
                OpenDirectory        = proxy.OpenDirectoryProxy,
                CreateDirectory      = proxy.CreateDirectoryProxy,
                Cleanup              = proxy.CleanupProxy,
                CloseFile            = proxy.CloseFileProxy,
                ReadFile             = proxy.ReadFileProxy,
                WriteFile            = proxy.WriteFileProxy,
                FlushFileBuffers     = proxy.FlushFileBuffersProxy,
                GetFileInformation   = proxy.GetFileInformationProxy,
                FindFiles            = proxy.FindFilesProxy,
                FindFilesWithPattern = proxy.FindFilesWithPatternProxy,
                SetFileAttributes    = proxy.SetFileAttributesProxy,
                SetFileTime          = proxy.SetFileTimeProxy,
                DeleteFile           = proxy.DeleteFileProxy,
                DeleteDirectory      = proxy.DeleteDirectoryProxy,
                MoveFile             = proxy.MoveFileProxy,
                SetEndOfFile         = proxy.SetEndOfFileProxy,
                SetAllocationSize    = proxy.SetAllocationSizeProxy,
                LockFile             = proxy.LockFileProxy,
                UnlockFile           = proxy.UnlockFileProxy,
                GetDiskFreeSpace     = proxy.GetDiskFreeSpaceProxy,
                GetVolumeInformation = proxy.GetVolumeInformationProxy,
                Unmount              = proxy.UnmountProxy,
                GetFileSecurity      = proxy.GetFileSecurity,
                SetFileSecurity      = proxy.SetFileSecurity
            };

            return(DokanDll.DokanMain(ref dokanOptions, ref dokanOperations));
        }
コード例 #7
0
        DokanError IDokanOperations.OpenDirectory(string fileName, DokanFileInfo info)
        {
            SftpDrive drive = this.GetDriveByMountPoint(fileName, out fileName);

            LogFSActionInit("OpenDir", fileName, drive, "");

            if (drive != null)
            {
                lastActiveSubsytem = drive;

                IDokanOperations ops = GetSubSystemOperations(drive);
                if (ops == null)
                {
                    LogFSActionError("OpenDir", fileName, drive, "Cannot open, mount failed?");
                    return(DokanError.ErrorAccessDenied);
                }
                LogFSActionSuccess("OpenDir", fileName, drive, "Found, subsytem");
                return(ops.OpenDirectory(fileName, info));
            }

            lastActiveSubsytem = null;
            info.IsDirectory   = true;

            if (fileName.Length == 1) //root dir
            {
                LogFSActionSuccess("OpenDir", fileName, drive, "Found, VFS root");
                return(DokanError.ErrorSuccess);
            }

            string path = fileName.Substring(1);//cut leading \

            foreach (SftpDrive subdrive in _subsytems)
            {
                string mp = subdrive.MountPoint; //  mp1 || mp1\mp2 ...
                if (path == mp)
                {
                    info.Context = subdrive;
                    LogFSActionSuccess("OpenDir", fileName, drive, "Found, final mountpoint");
                    return(DokanError.ErrorSuccess);
                }

                if (mp.IndexOf(path + '\\') == 0)
                { //path is part of mount point
                    info.Context = subdrive;
                    LogFSActionSuccess("OpenDir", fileName, drive, "Found, part of mountpoint");
                    return(DokanError.ErrorSuccess);
                }
            }
            LogFSActionError("OpenDir", fileName, drive, "Path not found");
            return(DokanError.ErrorPathNotFound);
        }
コード例 #8
0
 public HostedMongoFsService
 (
     ILogger logger,
     CommandLineArguments commandLineArguments,
     IHostApplicationLifetime lifetime,
     IDokanOperations dokanOperations,
     DokanNet.Logging.ILogger dokanLogger
 )
 {
     _logger = logger.ForContext <HostedMongoFsService>();
     _commandLineArguments = commandLineArguments;
     _lifetime             = lifetime;
     _dokanOperations      = dokanOperations;
     _dokanLogger          = dokanLogger;
 }
コード例 #9
0
        DokanError IDokanOperations.GetDiskFreeSpace(out long free, out long total,
                                                     out long used, DokanFileInfo info)
        {
            if (lastActiveSubsytem != null)
            {
                IDokanOperations ops = GetSubSystemOperations(lastActiveSubsytem);
                if (ops != null)
                {
                    return(ops.GetDiskFreeSpace(out free, out total, out used, info));
                }
            }


            free  = 0;
            total = 1024;
            used  = 4;
            free  = total - used;

            return(DokanError.ErrorSuccess);
        }
コード例 #10
0
        NtStatus IDokanOperations.GetDiskFreeSpace(out long free, out long total, out long used, IDokanFileInfo info)
        {
            Log("VFS GetDiskFreeSpace");
            if (lastActiveSubsytem != null)
            {
                IDokanOperations ops = GetSubSystemOperations(lastActiveSubsytem);
                if (ops != null)
                {
                    return(ops.GetDiskFreeSpace(out free, out total, out used, info));
                }
            }

            long terabyte = (long)1024 * 1024 * 1024 * 1024;

            total = 10 * terabyte;             //1TB for Explorer to see space
            used  = terabyte;
            free  = total - used;

            return(NtStatus.Success);
        }
コード例 #11
0
            private Fixture()
            {
                operations = new ProxyGenerator().CreateInterfaceProxyWithTargetInterface <IDokanOperations>(null, interceptor);

                var loggerMock = new Mock <NLog.ILogger>();

                loggerMock.Setup(l => l.Trace(It.IsAny <string>())).Callback((string message) => Console.WriteLine(message));
                logger = loggerMock.Object;

                Reset();
                SetupGetRoot();

                (mounterThread = new Thread(new ThreadStart(() => operations.Mount(MOUNT_POINT, DokanOptions.DebugMode | DokanOptions.RemovableDrive, 5, 1000, TimeSpan.FromMinutes(5))))).Start();
                var mountedDrive = GetDriveInfo();

                while (!mountedDrive.IsReady)
                {
                    Thread.Sleep(50);
                }
            }
コード例 #12
0
ファイル: Cache.cs プロジェクト: Jektt/dokan-sshfs
 public CacheOperations(IDokanOperations ope)
 {
     ope_ = ope;
     cache_ = new CacheEntry(null);
 }
コード例 #13
0
 /// <summary>
 /// Mount a new %Dokan Volume.
 /// It is mandatory to have called <see cref="DokanInit"/> previously to use this API.
 /// This function returns directly on device mount or on failure.
 /// <see cref="WaitForFileSystemClosed"/> can be used to wait until the device is unmount.
 /// </summary>
 /// <param name="operations">Instance of <see cref="IDokanOperations"/> that will be called for each request made by the kernel.</param>
 /// <param name="mountPoint">Mount point. Can be <c>M:\\</c> (drive letter) or <c>C:\\mount\\dokan</c> (path in NTFS).</param>
 /// <param name="mountOptions"><see cref="DokanOptions"/> features enable for the mount.</param>
 /// <param name="singleThread">Number of threads to be used internally by %Dokan library. More thread will handle more event at the same time.</param>
 /// <param name="version">Version of the dokan features requested (Version "123" is equal to %Dokan version 1.2.3).</param>
 /// <param name="timeout">Max timeout in ms of each request before dokan give up.</param>
 /// <param name="uncName">UNC name used for network volume.</param>
 /// <param name="logger"><see cref="ILogger"/> that will log all DokanNet debug informations.</param>
 /// <exception cref="DokanException">If the mount fails.</exception>
 /// <returns>Dokan mount instance context that can be used for related instance calls like <see cref="IsFileSystemRunning"/></returns>
 public static DokanInstance CreateFileSystem(this IDokanOperations operations, string mountPoint, DokanOptions mountOptions,
                                              bool singleThread, int version, TimeSpan timeout, string uncName, ILogger logger = null)
 {
     return(CreateFileSystem(operations, mountPoint, mountOptions, singleThread, version, timeout, uncName, 512, 512, logger));
 }
コード例 #14
0
 /// <summary>
 /// Mount a new %Dokan Volume.
 /// It is mandatory to have called <see cref="DokanInit"/> previously to use this API.
 /// This function returns directly on device mount or on failure.
 /// <see cref="WaitForFileSystemClosed"/> can be used to wait until the device is unmount.
 /// </summary>
 /// <param name="operations">Instance of <see cref="IDokanOperations"/> that will be called for each request made by the kernel.</param>
 /// <param name="mountPoint">Mount point. Can be <c>M:\\</c> (drive letter) or <c>C:\\mount\\dokan</c> (path in NTFS).</param>
 /// <param name="mountOptions"><see cref="DokanOptions"/> features enable for the mount.</param>
 /// <param name="singleThread">Number of threads to be used internally by %Dokan library. More thread will handle more event at the same time.</param>
 /// <param name="version">Version of the dokan features requested (Version "123" is equal to %Dokan version 1.2.3).</param>
 /// <param name="logger"><see cref="ILogger"/> that will log all DokanNet debug informations.</param>
 /// <exception cref="DokanException">If the mount fails.</exception>
 /// <returns>Dokan mount instance context that can be used for related instance calls like <see cref="IsFileSystemRunning"/></returns>
 public static DokanInstance CreateFileSystem(this IDokanOperations operations, string mountPoint, DokanOptions mountOptions,
                                              bool singleThread, int version, ILogger logger = null)
 {
     return(CreateFileSystem(operations, mountPoint, mountOptions, singleThread, version, TimeSpan.FromSeconds(20), string.Empty,
                             512, 512, logger));
 }
コード例 #15
0
 public DokanOperationProxy(IDokanOperations operations)
 {
     this.operations = operations;
     serialNumber    = (uint)this.operations.GetHashCode();
 }
コード例 #16
0
        /// <summary>
        /// Mount a new %Dokan Volume.
        /// It is mandatory to have called <see cref="DokanInit"/> previously to use this API.
        /// This function returns directly on device mount or on failure.
        /// <see cref="WaitForFileSystemClosed"/> can be used to wait until the device is unmount.
        /// </summary>
        /// <param name="operations">Instance of <see cref="IDokanOperations"/> that will be called for each request made by the kernel.</param>
        /// <param name="mountPoint">Mount point. Can be <c>M:\\</c> (drive letter) or <c>C:\\mount\\dokan</c> (path in NTFS).</param>
        /// <param name="mountOptions"><see cref="DokanOptions"/> features enable for the mount.</param>
        /// <param name="singleThread">Number of threads to be used internally by %Dokan library. More thread will handle more event at the same time.</param>
        /// <param name="version">Version of the dokan features requested (Version "123" is equal to %Dokan version 1.2.3).</param>
        /// <param name="timeout">Max timeout in ms of each request before dokan give up.</param>
        /// <param name="uncName">UNC name used for network volume.</param>
        /// <param name="allocationUnitSize">Allocation Unit Size of the volume. This will behave on the file size.</param>
        /// <param name="sectorSize">Sector Size of the volume. This will behave on the file size.</param>
        /// <param name="logger"><see cref="ILogger"/> that will log all DokanNet debug informations.</param>
        /// <exception cref="DokanException">If the mount fails.</exception>
        /// <returns>Dokan mount instance context that can be used for related instance calls like <see cref="IsFileSystemRunning"/></returns>
        public static DokanInstance CreateFileSystem(this IDokanOperations operations, string mountPoint, DokanOptions mountOptions,
                                                     bool singleThread, int version, TimeSpan timeout, string uncName = null, int allocationUnitSize = 512,
                                                     int sectorSize = 512, ILogger logger = null)
        {
            if (logger == null)
            {
#if TRACE
                logger = new ConsoleLogger("[DokanNet] ");
#else
                logger = new NullLogger();
#endif
            }

            DokanInstance instance = new DokanInstance();

            var dokanOperationProxy = new DokanOperationProxy(operations, logger);

            var dokanOptions = new DOKAN_OPTIONS
            {
                Version                        = (ushort)version,
                MountPoint                     = mountPoint,
                UNCName                        = string.IsNullOrEmpty(uncName) ? null : uncName,
                SingleThread                   = singleThread,
                Options                        = (uint)mountOptions,
                Timeout                        = (uint)timeout.TotalMilliseconds,
                AllocationUnitSize             = (uint)allocationUnitSize,
                SectorSize                     = (uint)sectorSize,
                VolumeSecurityDescriptorLength = 0
            };

            instance.DokanOptions = new NativeStructWrapper <DOKAN_OPTIONS>(dokanOptions);

            var dokanOperations = new DOKAN_OPERATIONS
            {
                ZwCreateFile         = dokanOperationProxy.ZwCreateFileProxy,
                Cleanup              = dokanOperationProxy.CleanupProxy,
                CloseFile            = dokanOperationProxy.CloseFileProxy,
                ReadFile             = dokanOperationProxy.ReadFileProxy,
                WriteFile            = dokanOperationProxy.WriteFileProxy,
                FlushFileBuffers     = dokanOperationProxy.FlushFileBuffersProxy,
                GetFileInformation   = dokanOperationProxy.GetFileInformationProxy,
                FindFiles            = dokanOperationProxy.FindFilesProxy,
                FindFilesWithPattern = dokanOperationProxy.FindFilesWithPatternProxy,
                SetFileAttributes    = dokanOperationProxy.SetFileAttributesProxy,
                SetFileTime          = dokanOperationProxy.SetFileTimeProxy,
                DeleteFile           = dokanOperationProxy.DeleteFileProxy,
                DeleteDirectory      = dokanOperationProxy.DeleteDirectoryProxy,
                MoveFile             = dokanOperationProxy.MoveFileProxy,
                SetEndOfFile         = dokanOperationProxy.SetEndOfFileProxy,
                SetAllocationSize    = dokanOperationProxy.SetAllocationSizeProxy,
                LockFile             = dokanOperationProxy.LockFileProxy,
                UnlockFile           = dokanOperationProxy.UnlockFileProxy,
                GetDiskFreeSpace     = dokanOperationProxy.GetDiskFreeSpaceProxy,
                GetVolumeInformation = dokanOperationProxy.GetVolumeInformationProxy,
                Mounted              = dokanOperationProxy.MountedProxy,
                Unmounted            = dokanOperationProxy.UnmountedProxy,
                GetFileSecurity      = dokanOperationProxy.GetFileSecurityProxy,
                SetFileSecurity      = dokanOperationProxy.SetFileSecurityProxy,
                FindStreams          = dokanOperationProxy.FindStreamsProxy
            };

            instance.DokanOperations = new NativeStructWrapper <DOKAN_OPERATIONS>(dokanOperations);

            DokanStatus status = NativeMethods.DokanCreateFileSystem(instance.DokanOptions, instance.DokanOperations, out instance.DokanHandle);
            if (status != DokanStatus.Success)
            {
                throw new DokanException(status);
            }

            return(instance);
        }
コード例 #17
0
 public Proxy(DokanOptions options, IDokanOperations operations)
 {
     this.operations = operations;
     this.options    = options;
 }
コード例 #18
0
 /// <summary>
 /// Mount a new %Dokan Volume.
 /// It is mandatory to have called <see cref="DokanInit"/> previously to use this API.
 /// This function returns directly on device mount or on failure.
 /// <see cref="WaitForFileSystemClosed"/> can be used to wait until the device is unmount.
 /// </summary>
 /// <param name="operations">Instance of <see cref="IDokanOperations"/> that will be called for each request made by the kernel.</param>
 /// <param name="mountPoint">Mount point. Can be <c>M:\\</c> (drive letter) or <c>C:\\mount\\dokan</c> (path in NTFS).</param>
 /// <param name="mountOptions"><see cref="DokanOptions"/> features enable for the mount.</param>
 /// <param name="singleThread">Number of threads to be used internally by %Dokan library. More thread will handle more event at the same time.</param>
 /// <param name="logger"><see cref="ILogger"/> that will log all DokanNet debug informations.</param>
 /// <exception cref="DokanException">If the mount fails.</exception>
 /// <returns>Dokan mount instance context that can be used for related instance calls like <see cref="IsFileSystemRunning"/></returns>
 public static DokanInstance CreateFileSystem(this IDokanOperations operations, string mountPoint, DokanOptions mountOptions,
                                              bool singleThread, ILogger logger = null)
 {
     return(CreateFileSystem(operations, mountPoint, mountOptions, singleThread, DOKAN_VERSION, logger));
 }
コード例 #19
0
        /// <summary>
        /// Mount a new %Dokan Volume.
        /// This function block until the device is unmount.
        /// </summary>
        /// <param name="operations">Instance of <see cref="IDokanOperations"/> that will be called for each request made by the kernel.</param>
        /// <param name="mountPoint">Mount point. Can be <c>M:\\</c> (drive letter) or <c>C:\\mount\\dokan</c> (path in NTFS).</param>
        /// <param name="mountOptions"><see cref="DokanOptions"/> features enable for the mount.</param>
        /// <param name="threadCount">Number of threads to be used internally by %Dokan library. More thread will handle more event at the same time.</param>
        /// <param name="version">Version of the dokan features requested (Version "123" is equal to %Dokan version 1.2.3).</param>
        /// <param name="timeout">Max timeout in ms of each request before dokan give up.</param>
        /// <param name="uncName">UNC name used for network volume.</param>
        /// <param name="allocationUnitSize">Allocation Unit Size of the volume. This will behave on the file size.</param>
        /// <param name="sectorSize">Sector Size of the volume. This will behave on the file size.</param>
        /// <param name="logger"><see cref="ILogger"/> that will log all DokanNet debug informations.</param>
        /// <exception cref="DokanException">If the mount fails.</exception>
        public static void Mount(this IDokanOperations operations, string mountPoint, DokanOptions mountOptions,
                                 int threadCount, int version, TimeSpan timeout, string uncName = null, int allocationUnitSize = 512,
                                 int sectorSize = 512, ILogger logger = null)
        {
            if (logger == null)
            {
#if TRACE
                logger = new ConsoleLogger("[DokanNet] ");
#else
                logger = new NullLogger();
#endif
            }

            var dokanOperationProxy = new DokanOperationProxy(operations, logger);

            var dokanOptions = new DOKAN_OPTIONS
            {
                Version            = (ushort)version,
                MountPoint         = mountPoint,
                UNCName            = string.IsNullOrEmpty(uncName) ? null : uncName,
                ThreadCount        = (ushort)threadCount,
                Options            = (uint)mountOptions,
                Timeout            = (uint)timeout.TotalMilliseconds,
                AllocationUnitSize = (uint)allocationUnitSize,
                SectorSize         = (uint)sectorSize
            };

            var dokanOperations = new DOKAN_OPERATIONS
            {
                ZwCreateFile         = dokanOperationProxy.ZwCreateFileProxy,
                Cleanup              = dokanOperationProxy.CleanupProxy,
                CloseFile            = dokanOperationProxy.CloseFileProxy,
                ReadFile             = dokanOperationProxy.ReadFileProxy,
                WriteFile            = dokanOperationProxy.WriteFileProxy,
                FlushFileBuffers     = dokanOperationProxy.FlushFileBuffersProxy,
                GetFileInformation   = dokanOperationProxy.GetFileInformationProxy,
                FindFiles            = dokanOperationProxy.FindFilesProxy,
                FindFilesWithPattern = dokanOperationProxy.FindFilesWithPatternProxy,
                SetFileAttributes    = dokanOperationProxy.SetFileAttributesProxy,
                SetFileTime          = dokanOperationProxy.SetFileTimeProxy,
                DeleteFile           = dokanOperationProxy.DeleteFileProxy,
                DeleteDirectory      = dokanOperationProxy.DeleteDirectoryProxy,
                MoveFile             = dokanOperationProxy.MoveFileProxy,
                SetEndOfFile         = dokanOperationProxy.SetEndOfFileProxy,
                SetAllocationSize    = dokanOperationProxy.SetAllocationSizeProxy,
                LockFile             = dokanOperationProxy.LockFileProxy,
                UnlockFile           = dokanOperationProxy.UnlockFileProxy,
                GetDiskFreeSpace     = dokanOperationProxy.GetDiskFreeSpaceProxy,
                GetVolumeInformation = dokanOperationProxy.GetVolumeInformationProxy,
                Mounted              = dokanOperationProxy.MountedProxy,
                Unmounted            = dokanOperationProxy.UnmountedProxy,
                GetFileSecurity      = dokanOperationProxy.GetFileSecurityProxy,
                SetFileSecurity      = dokanOperationProxy.SetFileSecurityProxy,
                FindStreams          = dokanOperationProxy.FindStreamsProxy
            };

            var status = NativeMethods.DokanMain(ref dokanOptions, ref dokanOperations);

            switch (status)
            {
            case DOKAN_ERROR:
                throw new DokanException(status, Resources.ErrorDokan);

            case DOKAN_DRIVE_LETTER_ERROR:
                throw new DokanException(status, Resources.ErrorBadDriveLetter);

            case DOKAN_DRIVER_INSTALL_ERROR:
                throw new DokanException(status, Resources.ErrorDriverInstall);

            case DOKAN_MOUNT_ERROR:
                throw new DokanException(status, Resources.ErrorAssignDriveLetter);

            case DOKAN_START_ERROR:
                throw new DokanException(status, Resources.ErrorStart);

            case DOKAN_MOUNT_POINT_ERROR:
                throw new DokanException(status, Resources.ErrorMountPointInvalid);

            case DOKAN_VERSION_ERROR:
                throw new DokanException(status, Resources.ErrorVersion);

            default:
                throw new DokanException(status, Resources.ErrorUnknown);
            }
        }
コード例 #20
0
 /// <summary>
 /// Mount a new %Dokan Volume.
 /// This function block until the device is unmount.
 /// </summary>
 /// <param name="operations">Instance of <see cref="IDokanOperations"/> that will be called for each request made by the kernel.</param>
 /// <param name="mountPoint">Mount point. Can be <c>M:\\</c> (drive letter) or <c>C:\\mount\\dokan</c> (path in NTFS).</param>
 /// <param name="mountOptions"><see cref="DokanOptions"/> features enable for the mount.</param>
 /// <param name="threadCount">Number of threads to be used internally by %Dokan library. More thread will handle more event at the same time.</param>
 /// <param name="version">Version of the dokan features requested (Version "123" is equal to %Dokan version 1.2.3).</param>
 /// <param name="logger"><see cref="ILogger"/> that will log all DokanNet debug informations.</param>
 /// <exception cref="DokanException">If the mount fails.</exception>
 public static void Mount(this IDokanOperations operations, string mountPoint, DokanOptions mountOptions,
                          int threadCount, int version, ILogger logger = null)
 {
     Mount(operations, mountPoint, mountOptions, threadCount, version, TimeSpan.FromSeconds(20), string.Empty,
           512, 512, logger);
 }
コード例 #21
0
 /// <summary>
 /// Mount a new %Dokan Volume.
 /// This function block until the device is unmount.
 /// </summary>
 /// <param name="operations">Instance of <see cref="IDokanOperations"/> that will be called for each request made by the kernel.</param>
 /// <param name="mountPoint">Mount point. Can be <c>M:\\</c> (drive letter) or <c>C:\\mount\\dokan</c> (path in NTFS).</param>
 /// <param name="mountOptions"><see cref="DokanOptions"/> features enable for the mount.</param>
 /// <param name="logger"><see cref="ILogger"/> that will log all DokanNet debug informations.</param>
 /// <exception cref="DokanException">If the mount fails.</exception>
 public static void Mount(this IDokanOperations operations, string mountPoint, DokanOptions mountOptions,
                          ILogger logger = null)
 {
     Mount(operations, mountPoint, mountOptions, 0, logger);
 }
コード例 #22
0
        public static void Mount(this IDokanOperations operations, string mountPoint, DokanOptions mountOptions, int threadCount, int version)
        {
            var dokanOperationProxy = new DokanOperationProxy(operations);

            var dokanOptions = new DOKAN_OPTIONS
            {
                Version     = (ushort)version,
                MountPoint  = mountPoint,
                ThreadCount = (ushort)threadCount,
                Options     = (uint)mountOptions,
            };

            /*    dokanOptions.Options |= options.RemovableDrive ? DOKAN_OPTION_REMOVABLE : 0;
             *  dokanOptions.Options |= options.DebugMode ? DOKAN_OPTION_DEBUG : 0;
             *  dokanOptions.Options |= options.UseStandardError ? DOKAN_OPTION_STDERR : 0;
             *  dokanOptions.Options |= options.UseAlternativeStreams ? DOKAN_OPTION_ALT_STREAM : 0;
             *  dokanOptions.Options |= options.UseKeepAlive ? DOKAN_OPTION_KEEP_ALIVE : 0;
             *  dokanOptions.Options |= options.NetworkDrive ? DOKAN_OPTION_NETWORK : 0;*/

            var dokanOperations = new DOKAN_OPERATIONS
            {
                CreateFile           = dokanOperationProxy.CreateFileProxy,
                OpenDirectory        = dokanOperationProxy.OpenDirectoryProxy,
                CreateDirectory      = dokanOperationProxy.CreateDirectoryProxy,
                Cleanup              = dokanOperationProxy.CleanupProxy,
                CloseFile            = dokanOperationProxy.CloseFileProxy,
                ReadFile             = dokanOperationProxy.ReadFileProxy,
                WriteFile            = dokanOperationProxy.WriteFileProxy,
                FlushFileBuffers     = dokanOperationProxy.FlushFileBuffersProxy,
                GetFileInformation   = dokanOperationProxy.GetFileInformationProxy,
                FindFiles            = dokanOperationProxy.FindFilesProxy,
                FindFilesWithPattern = dokanOperationProxy.FindFilesWithPatternProxy,
                SetFileAttributes    = dokanOperationProxy.SetFileAttributesProxy,
                SetFileTime          = dokanOperationProxy.SetFileTimeProxy,
                DeleteFile           = dokanOperationProxy.DeleteFileProxy,
                DeleteDirectory      = dokanOperationProxy.DeleteDirectoryProxy,
                MoveFile             = dokanOperationProxy.MoveFileProxy,
                SetEndOfFile         = dokanOperationProxy.SetEndOfFileProxy,
                SetAllocationSize    = dokanOperationProxy.SetAllocationSizeProxy,
                //  LockFile = dokanOperationProxy.LockFileProxy,
                //  UnlockFile = dokanOperationProxy.UnlockFileProxy,
                GetDiskFreeSpace     = dokanOperationProxy.GetDiskFreeSpaceProxy,
                GetVolumeInformation = dokanOperationProxy.GetVolumeInformationProxy,
                Unmount         = dokanOperationProxy.UnmountProxy,
                GetFileSecurity = dokanOperationProxy.GetFileSecurityProxy,
                SetFileSecurity = dokanOperationProxy.SetFileSecurityProxy,
            };


            int status = NativeMethods.DokanMain(ref dokanOptions, ref dokanOperations);

            switch (status)
            {
            case DOKAN_ERROR:
                throw new DokanException(status, "Dokan error");

            case DOKAN_DRIVE_LETTER_ERROR:
                throw new DokanException(status, "Bad drive letter");

            case DOKAN_DRIVER_INSTALL_ERROR:
                throw new DokanException(status, "Can't install driver");

            case DOKAN_MOUNT_ERROR:
                throw new DokanException(status, "Can't assign a drive letter or mount point");

            case DOKAN_START_ERROR:
                throw new DokanException(status, "Something's wrong with Dokan driver");

            case DOKAN_MOUNT_POINT_ERROR:
                throw new DokanException(status, "Mount point is invalid ");
            }
        }
コード例 #23
0
 public static void Mount(this IDokanOperations operations, string mountPoint)
 {
     Mount(operations, mountPoint, DokanOptions.FixedDrive, 0, DOKAN_VERSION);
 }
コード例 #24
0
 public static void Mount(this IDokanOperations operations, string mountPoint, DokanOptions mountOptions, int threadCount)
 {
     Mount(operations, mountPoint, mountOptions, threadCount, DOKAN_VERSION);
 }
コード例 #25
0
 public DokanOperationProxy(IDokanOperations operations, ILogger logger)
 {
     this.operations = operations;
     this.logger = logger;
     serialNumber = (uint)this.operations.GetHashCode();
 }
コード例 #26
0
 public DokanOperationProxy(IDokanOperations operations, ILogger logger)
 {
     this.operations = operations;
     this.logger     = logger;
     serialNumber    = (uint)this.operations.GetHashCode();
 }
コード例 #27
0
ファイル: Cache.cs プロジェクト: xiechaoyi/dokan-sshfs
 public CacheOperations(IDokanOperations ope)
 {
     ope_   = ope;
     cache_ = new CacheEntry(null);
 }
コード例 #28
0
 /// <summary>
 /// Mount a new %Dokan Volume.
 /// This function block until the device is unmount.
 /// </summary>
 /// <param name="operations">Instance of <see cref="IDokanOperations"/> that will be called for each request made by the kernel.</param>
 /// <param name="mountPoint">Mount point. Can be <c>M:\\</c> (drive letter) or <c>C:\\mount\\dokan</c> (path in NTFS).</param>
 /// <param name="mountOptions"><see cref="DokanOptions"/> features enable for the mount.</param>
 /// <param name="threadCount">Number of threads to be used internally by %Dokan library. More thread will handle more event at the same time.</param>
 /// <param name="logger"><see cref="ILogger"/> that will log all DokanNet debug informations.</param>
 /// <exception cref="DokanException">If the mount fails.</exception>
 public static void Mount(this IDokanOperations operations, string mountPoint, DokanOptions mountOptions,
                          int threadCount, ILogger logger = null)
 {
     Mount(operations, mountPoint, mountOptions, threadCount, DOKAN_VERSION, logger);
 }
コード例 #29
0
ファイル: SettingForm.cs プロジェクト: Jektt/dokan-sshfs
 public MountWorker(IDokanOperations sshfs, DokanOptions opt, string mountPoint, int threadCount)
 {
     sshfs_ = sshfs;
     opt_ = opt;
     mountPoint_ = mountPoint;
     threadCount_ = threadCount;
 }
コード例 #30
0
 /// <summary>
 /// Mount a new %Dokan Volume.
 /// This function block until the device is unmount.
 /// </summary>
 /// <param name="operations">Instance of <see cref="IDokanOperations"/> that will be called for each request made by the kernel.</param>
 /// <param name="mountPoint">Mount point. Can be <c>M:\\</c> (drive letter) or <c>C:\\mount\\dokan</c> (path in NTFS).</param>
 /// <param name="mountOptions"><see cref="DokanOptions"/> features enable for the mount.</param>
 /// <param name="threadCount">Number of threads to be used internally by %Dokan library. More thread will handle more event at the same time.</param>
 /// <param name="version">Version of the dokan features requested (Version "123" is equal to %Dokan version 1.2.3).</param>
 /// <param name="timeout">Max timeout in ms of each request before dokan give up.</param>
 /// <param name="uncName">UNC name used for network volume.</param>
 /// <param name="logger"><see cref="ILogger"/> that will log all DokanNet debug informations.</param>
 /// <exception cref="DokanException">If the mount fails.</exception>
 public static void Mount(this IDokanOperations operations, string mountPoint, DokanOptions mountOptions,
                          int threadCount, int version, TimeSpan timeout, string uncName, ILogger logger = null)
 {
     Mount(operations, mountPoint, mountOptions, threadCount, version, timeout, uncName, 512, 512, logger);
 }
コード例 #31
0
ファイル: Dokan.cs プロジェクト: yoshy3/dokan-dotnet
        /// <summary>
        /// Mount a new %Dokan Volume.
        /// This function block until the device is unmount.
        /// </summary>
        /// <param name="operations">Instance of <see cref="IDokanOperations"/> that will be called for each request made by the kernel.</param>
        /// <param name="mountPoint">Mount point. Can be <c>M:\\</c> (drive letter) or <c>C:\\mount\\dokan</c> (path in NTFS).</param>
        /// <param name="mountOptions"><see cref="DokanOptions"/> features enable for the mount.</param>
        /// <param name="threadCount">Number of threads to be used internally by %Dokan library. More thread will handle more event at the same time.</param>
        /// <param name="version">Version of the dokan features requested (Version "123" is equal to %Dokan version 1.2.3).</param>
        /// <param name="timeout">Max timeout in ms of each request before dokan give up.</param>
        /// <param name="uncName">UNC name used for network volume.</param>
        /// <param name="allocationUnitSize">Allocation Unit Size of the volume. This will behave on the file size.</param>
        /// <param name="sectorSize">Sector Size of the volume. This will behave on the file size.</param>
        /// <param name="logger"><see cref="ILogger"/> that will log all DokanNet debug informations.</param>
        /// <exception cref="DokanException">If the mount fails.</exception>
        public static void Mount(this IDokanOperations operations, string mountPoint, DokanOptions mountOptions,
                                 int threadCount, int version, TimeSpan timeout, string uncName = null, int allocationUnitSize = 512,
                                 int sectorSize = 512, ILogger logger = null)
        {
            if (logger == null)
            {
#if TRACE
                logger = new ConsoleLogger("[DokanNet] ");
#else
                logger = new NullLogger();
#endif
            }

            var dokanOperationProxy = new DokanOperationProxy(operations, logger);

            var dokanOptions = new DOKAN_OPTIONS
            {
                Version            = (ushort)version,
                MountPoint         = mountPoint,
                UNCName            = string.IsNullOrEmpty(uncName) ? null : uncName,
                ThreadCount        = (ushort)threadCount,
                Options            = (uint)mountOptions,
                Timeout            = (uint)timeout.TotalMilliseconds,
                AllocationUnitSize = (uint)allocationUnitSize,
                SectorSize         = (uint)sectorSize
            };

            var dokanOperations = new DOKAN_OPERATIONS
            {
                ZwCreateFile         = dokanOperationProxy.ZwCreateFileProxy,
                Cleanup              = dokanOperationProxy.CleanupProxy,
                CloseFile            = dokanOperationProxy.CloseFileProxy,
                ReadFile             = dokanOperationProxy.ReadFileProxy,
                WriteFile            = dokanOperationProxy.WriteFileProxy,
                FlushFileBuffers     = dokanOperationProxy.FlushFileBuffersProxy,
                GetFileInformation   = dokanOperationProxy.GetFileInformationProxy,
                FindFiles            = dokanOperationProxy.FindFilesProxy,
                FindFilesWithPattern = dokanOperationProxy.FindFilesWithPatternProxy,
                SetFileAttributes    = dokanOperationProxy.SetFileAttributesProxy,
                SetFileTime          = dokanOperationProxy.SetFileTimeProxy,
                DeleteFile           = dokanOperationProxy.DeleteFileProxy,
                DeleteDirectory      = dokanOperationProxy.DeleteDirectoryProxy,
                MoveFile             = dokanOperationProxy.MoveFileProxy,
                SetEndOfFile         = dokanOperationProxy.SetEndOfFileProxy,
                SetAllocationSize    = dokanOperationProxy.SetAllocationSizeProxy,
                LockFile             = dokanOperationProxy.LockFileProxy,
                UnlockFile           = dokanOperationProxy.UnlockFileProxy,
                GetDiskFreeSpace     = dokanOperationProxy.GetDiskFreeSpaceProxy,
                GetVolumeInformation = dokanOperationProxy.GetVolumeInformationProxy,
                Mounted              = dokanOperationProxy.MountedProxy,
                Unmounted            = dokanOperationProxy.UnmountedProxy,
                GetFileSecurity      = dokanOperationProxy.GetFileSecurityProxy,
                SetFileSecurity      = dokanOperationProxy.SetFileSecurityProxy,
                FindStreams          = dokanOperationProxy.FindStreamsProxy
            };

            DokanStatus status = (DokanStatus)NativeMethods.DokanMain(ref dokanOptions, ref dokanOperations);
            if (status != DokanStatus.Success)
            {
                throw new DokanException(status);
            }
        }
コード例 #32
0
        /** @} */
        #endregion Dokan Driver Errors

        /// <summary>
        /// Mount a new %Dokan Volume.
        /// This function block until the device is unmount.
        /// </summary>
        /// <param name="operations">Instance of <see cref="IDokanOperations"/> that will be called for each request made by the kernel.</param>
        /// <param name="mountPoint">Mount point. Can be <c>M:\\</c> (drive letter) or <c>C:\\mount\\dokan</c> (path in NTFS).</param>
        /// <param name="logger"><see cref="ILogger"/> that will log all DokanNet debug informations</param>
        /// <exception cref="DokanException">If the mount fails.</exception>
        public static void Mount(this IDokanOperations operations, string mountPoint, ILogger logger = null)
        {
            Mount(operations, mountPoint, DokanOptions.FixedDrive, logger);
        }
コード例 #33
0
 public DokanOperationProxy(IDokanOperations operations)
 {
     this.operations = operations;
     serialNumber = (uint)this.operations.GetHashCode();
 }
コード例 #34
0
 public DokanOperationProxy(IDokanOperations operations)
 {
     _operations = operations;
     _serialNumber = (uint)_operations.GetHashCode();
 }
コード例 #35
0
ファイル: Proxy.cs プロジェクト: zmshan2008/MediaPortal-2
 public Proxy(IDokanOperations operations)
 {
     _operations   = operations;
     _serialNumber = (uint)this._operations.GetHashCode();
 }