示例#1
1
 public Proxy(DokanOptions options, DokanOperations operations)
 {
     operations_ = operations;
     options_ = options;
     array_ = new ArrayList();
     infoTable_ = new Dictionary<ulong, DokanFileInfo>();
 }
示例#2
0
 public Proxy(DokanOptions options, DokanOperations operations)
 {
     operations_ = operations;
     options_    = options;
     array_      = new ArrayList();
     infoTable_  = new Dictionary <ulong, DokanFileInfo>();
 }
示例#3
0
 private static bool MountFS(DokanOperations dok, string driveLetter, string driveLabel, out string errorMessage)
 {
     DokanOptions opt = new DokanOptions();
     opt.DebugMode = true;
     opt.MountPoint = driveLetter + ":\\";
     opt.VolumeLabel = driveLabel;
     opt.ThreadCount = 5;
     int status = DokanNet.DokanMain(opt, new LoggingFS(dok, true));
     switch (status)
     {
         case DokanNet.DOKAN_DRIVE_LETTER_ERROR:
             errorMessage = "Drvie letter error";
             return false;
         case DokanNet.DOKAN_DRIVER_INSTALL_ERROR:
             errorMessage = "Driver install error";
             return false;
         case DokanNet.DOKAN_MOUNT_ERROR:
             errorMessage = "Mount error";
             return false;
         case DokanNet.DOKAN_START_ERROR:
             errorMessage = "Start error";
             return false;
         case DokanNet.DOKAN_ERROR:
             errorMessage = "Unknown error";
             return false;
         case DokanNet.DOKAN_SUCCESS:
             errorMessage = "";
             return true;
         default:
             errorMessage = "Unknown status: " + status;
             return false;
     }
 }
示例#4
0
        public static void Main()
        {
            string basePath    = Dir(@"c:\projects\Testing\test\Base");
            string minePath    = Dir(@"c:\projects\Testing\test\Mine");
            string workingPath = Dir(@"c:\projects\Testing\test\Working");

            DokanOperations mirror = new DokanOperations(basePath, minePath);

            Task.Factory.StartNew(() => { mirror.Mount(workingPath, DokanOptions.DebugMode | DokanOptions.EnableNotificationAPI, 1, new NullLogger()); });

            Console.WriteLine(@"Mounted");

            string line;

            do
            {
                line = Console.ReadLine();
                Console.Clear();
            } while (line != "q");

            Dokan.RemoveMountPoint(workingPath);
            Directory.Delete(workingPath);
            Console.WriteLine(@"Success");

            //MainAsync().Wait();
            //Console.WriteLine(@"DONE");
            //Console.ReadLine();
        }
示例#5
0
        public static int DokanMain(DokanOptions options, DokanOperations operations)
        {
            if (options == null)
            {
                return;
            }

            DOKAN_OPTIONS dokanOptions = new DOKAN_OPTIONS();

            if (dokanOptions.Version == 0)
            {
                dokanOptions.Version = DOKAN_VERSION;
            }

            if (options.VolumeLabel == null)
            {
                options.VolumeLabel = "DOKAN-NET";
            }

            dokanOptions.Version = options.Version;
            Proxy proxy = new Proxy(options, operations);

            dokanOptions.MountPoint  = options.MountPoint;
            dokanOptions.ThreadCount = options.ThreadCount;
            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;
            dokanOptions.Options    |= options.RemovableDrive ? DOKAN_OPTION_REMOVABLE : 0;

            DOKAN_OPERATIONS dokanOperations = new DOKAN_OPERATIONS();

            dokanOperations.CreateFile           = proxy.CreateFileProxy;
            dokanOperations.OpenDirectory        = proxy.OpenDirectoryProxy;
            dokanOperations.CreateDirectory      = proxy.CreateDirectoryProxy;
            dokanOperations.Cleanup              = proxy.CleanupProxy;
            dokanOperations.CloseFile            = proxy.CloseFileProxy;
            dokanOperations.ReadFile             = proxy.ReadFileProxy;
            dokanOperations.WriteFile            = proxy.WriteFileProxy;
            dokanOperations.FlushFileBuffers     = proxy.FlushFileBuffersProxy;
            dokanOperations.FindFiles            = proxy.FindFilesProxy;
            dokanOperations.SetFileAttributes    = proxy.SetFileAttributesProxy;
            dokanOperations.SetFileTime          = proxy.SetFileTimeProxy;
            dokanOperations.DeleteFile           = proxy.DeleteFileProxy;
            dokanOperations.DeleteDirectory      = proxy.DeleteDirectoryProxy;
            dokanOperations.MoveFile             = proxy.MoveFileProxy;
            dokanOperations.SetEndOfFile         = proxy.SetEndOfFileProxy;
            dokanOperations.SetAllocationSize    = proxy.SetAllocationSizeProxy;
            dokanOperations.LockFile             = proxy.LockFileProxy;
            dokanOperations.UnlockFile           = proxy.UnlockFileProxy;
            dokanOperations.GetDiskFreeSpace     = proxy.GetDiskFreeSpaceProxy;
            dokanOperations.GetVolumeInformation = proxy.GetVolumeInformationProxy;
            dokanOperations.Unmount              = proxy.UnmountProxy;

            return(Dokan.DokanMain(ref dokanOptions, ref dokanOperations));
        }
示例#6
0
        static void Main(string[] args)
        {
            // TODO parse args to set working dir and drive letter
            configuration = new Configuration(@"C:\PaniniFS");

            try
            {
                var pfs = new DokanOperations();
                pfs.Mount(@"P:\", DokanOptions.DebugMode | DokanOptions.StderrOutput);
                Console.WriteLine(@"Success");
            }
            catch (DokanException ex)
            {
                Console.WriteLine(@"Error: " + ex.Message);
            }
        }
示例#7
0
 public CacheOperations(DokanOperations ope)
 {
     ope_ = ope;
     cache_ = new CacheEntry(null);
 }
示例#8
0
        public static int DokanMain(DokanOptions options, DokanOperations operations)
        {
            if (options.VolumeLabel == null)
            {
                options.VolumeLabel = "DOKAN";
            }
            
            Proxy proxy = new Proxy(options, operations);

            DOKAN_OPTIONS dokanOptions = new DOKAN_OPTIONS();

            dokanOptions.Version = options.Version;
            if (dokanOptions.Version == 0)
            {
                dokanOptions.Version = DOKAN_VERSION;
            }
            dokanOptions.ThreadCount = options.ThreadCount;
            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;
            dokanOptions.Options |= options.RemovableDrive ? DOKAN_OPTION_REMOVABLE : 0;
            dokanOptions.MountPoint = options.MountPoint;

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

            return Dokan.DokanMain(ref dokanOptions, ref dokanOperations);
        }
示例#9
0
 public MountWorker(DokanOperations sshfs, DokanOptions opt)
 {
     sshfs_ = sshfs;
     opt_ = opt;
 }
示例#10
0
 public CacheOperations(DokanOperations ope)
 {
     ope_   = ope;
     cache_ = new CacheEntry(null);
 }
示例#11
0
        private void MountDrive()
        {
            if (mNFS == null)
                throw new ApplicationException("NFS object is null!");

            string strDev = (string)cboxRemoteDevices.SelectedItem;
            if (cboxLocalDrive.SelectedItem == null)
                throw new Exception("You must select a local drive!");
            char cDrive = ((string)cboxLocalDrive.SelectedItem).ToCharArray()[0];
            MountPoint = String.Format(@"{0}:\", cDrive);
            string Folder = btnSelectFolder.Text;
            bool DiskOrFolder = rbDisk.Checked;
            string strDriveLabel = tbDriveLabel.Text;
            MainForm.In.mNFS.MountDevice(strDev);
            cboxLocalDrive.Enabled = false;
            cboxRemoteDevices.Enabled = false;
            btnMount.Enabled = false;
            btnUnmount.Enabled = true;
            tbDriveLabel.Enabled = false;
            rbDisk.Enabled = false;
            rbFolder.Enabled = false;
            btnSelectFolder.Enabled = false;
            chkAutoMount.Enabled = false;
            chkUsePrivilegedPorts.Enabled = false;
            chkNoCache.Enabled = false;
            btnClearCache.Enabled = true;

            if (!DiskOrFolder)
            {
                if (!Directory.Exists(Folder))
                    throw new ApplicationException(String.Format("{0} not found.", Folder));
                else
                    MountPoint = Folder;
            }

            bool NoCache = chkNoCache.Checked;

            ThreadPool.QueueUserWorkItem(new WaitCallback(
                delegate
                {
                    try
                    {
                        System.IO.Directory.SetCurrentDirectory(Application.StartupPath);
                        DokanOptions dokanOptions = new DokanOptions();
                        dokanOptions.DebugMode = DebugMode;
                        dokanOptions.NetworkDrive = DiskOrFolder;
                        dokanOptions.MountPoint = MountPoint;
                        dokanOptions.UseKeepAlive = true;
                        dokanOptions.UseAltStream = true;
                        dokanOptions.VolumeLabel = strDriveLabel;
                        dokanOptions.ThreadCount = 1;
                        
                        if (NoCache)
                            dokanOperation = new Operations();
                        else
                            dokanOperation = new CacheOperations(new Operations());
                        int status = DokanNet.DokanMain(dokanOptions, dokanOperation);
                        switch (status)
                        {
                            case DokanNet.DOKAN_DRIVE_LETTER_ERROR:
                                throw new ApplicationException("Drvie letter error");
                            case DokanNet.DOKAN_DRIVER_INSTALL_ERROR:
                                throw new ApplicationException("Driver install error");
                            case DokanNet.DOKAN_MOUNT_ERROR:
                                throw new ApplicationException("Mount error");
                            case DokanNet.DOKAN_START_ERROR:
                                throw new ApplicationException("Start error");
                            case DokanNet.DOKAN_ERROR:
                                throw new ApplicationException("Unknown error");
                            case DokanNet.DOKAN_SUCCESS:
                                break;
                            default:
                                throw new ApplicationException("Unknown status: " + status);
                        }
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message);
                    }
                }));

            ThreadPool.QueueUserWorkItem(new WaitCallback(
                delegate
                {
                    Thread.Sleep(2000);
                    Process.Start("explorer.exe", " " + MountPoint);
                }));
        }
示例#12
0
 public MountWorker(DokanOperations sshfs, DokanOptions opt)
 {
     sshfs_ = sshfs;
     opt_   = opt;
 }
示例#13
0
 public LoggingFS(DokanOperations oFS, bool logging)
 {
     this._fileSystem = oFS;
     this._logging = logging;
 }
示例#14
0
        private void MountDrive()
        {
            if (!connected)
            {
                MessageBox.Show("Client not connected!");
            }

            if (nfsClient == null)
                throw new ApplicationException("NFS object is null!");


            MountPoint = String.Format(@"{0}:\", "Z");


            /*
            if (!DiskOrFolder)
            {
                if (!Directory.Exists(Folder))
                    throw new ApplicationException(String.Format("{0} not found.", Folder));
                else
                    MountPoint = Folder;
            } */

            bool NoCache = true;

            ThreadPool.QueueUserWorkItem(new WaitCallback(
                delegate
                {
                    try
                    {
                        System.IO.Directory.SetCurrentDirectory(Application.StartupPath);
                        DokanOptions dokanOptions = new DokanOptions();
                        dokanOptions.DebugMode = false;
                        dokanOptions.NetworkDrive = false;
                        dokanOptions.RemovableDrive = true;
                        dokanOptions.MountPoint = MountPoint;
                        dokanOptions.UseKeepAlive = true;
                        dokanOptions.UseAltStream = true;
                        dokanOptions.VolumeLabel = this.Text;
                        dokanOptions.ThreadCount = 1;

                        if (NoCache)
                            dokanOperation = new Operations(nfsClient,this);
                        else
                            dokanOperation = new CacheOperations(new Operations(nfsClient,this));
                        int status = DokanNet.DokanMain(dokanOptions, dokanOperation);
                        switch (status)
                        {
                            case DokanNet.DOKAN_DRIVE_LETTER_ERROR:
                                throw new ApplicationException("Drvie letter error");
                            case DokanNet.DOKAN_DRIVER_INSTALL_ERROR:
                                throw new ApplicationException("Driver install error");
                            case DokanNet.DOKAN_MOUNT_ERROR:
                                throw new ApplicationException("Mount error");
                            case DokanNet.DOKAN_START_ERROR:
                                throw new ApplicationException("Start error");
                            case DokanNet.DOKAN_ERROR:
                                throw new ApplicationException("Unknown error");
                            case DokanNet.DOKAN_SUCCESS:
                                break;
                            default:
                                throw new ApplicationException("Unknown status: " + status);
                        }
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message);
                    }
                }));

            ThreadPool.QueueUserWorkItem(new WaitCallback(
                delegate
                {
                    Thread.Sleep(2000);
                    Process.Start("explorer.exe", " " + MountPoint);
                }));

            mountedDrive = true;
        }
示例#15
0
        private void MountDrive()
        {
            if (mNFS == null)
            {
                throw new ApplicationException("NFS object is null!");
            }

            string strDev = (string)cboxRemoteDevices.SelectedItem;

            if (cboxLocalDrive.SelectedItem == null)
            {
                throw new Exception("You must select a local drive!");
            }
            char cDrive = ((string)cboxLocalDrive.SelectedItem).ToCharArray()[0];

            MountPoint = String.Format(@"{0}:\", cDrive);
            string Folder        = btnSelectFolder.Text;
            bool   DiskOrFolder  = rbDisk.Checked;
            string strDriveLabel = tbDriveLabel.Text;

            MainForm.In.mNFS.MountDevice(strDev);
            cboxLocalDrive.Enabled        = false;
            cboxRemoteDevices.Enabled     = false;
            btnMount.Enabled              = false;
            btnUnmount.Enabled            = true;
            tbDriveLabel.Enabled          = false;
            rbDisk.Enabled                = false;
            rbFolder.Enabled              = false;
            btnSelectFolder.Enabled       = false;
            chkAutoMount.Enabled          = false;
            chkUsePrivilegedPorts.Enabled = false;
            chkNoCache.Enabled            = false;
            btnClearCache.Enabled         = true;

            if (!DiskOrFolder)
            {
                if (!Directory.Exists(Folder))
                {
                    throw new ApplicationException(String.Format("{0} not found.", Folder));
                }
                else
                {
                    MountPoint = Folder;
                }
            }

            bool NoCache = chkNoCache.Checked;

            ThreadPool.QueueUserWorkItem(new WaitCallback(
                                             delegate
            {
                try
                {
                    System.IO.Directory.SetCurrentDirectory(Application.StartupPath);
                    DokanOptions dokanOptions = new DokanOptions();
                    dokanOptions.DebugMode    = DebugMode;
                    dokanOptions.NetworkDrive = DiskOrFolder;
                    dokanOptions.MountPoint   = MountPoint;
                    dokanOptions.UseKeepAlive = true;
                    dokanOptions.UseAltStream = true;
                    dokanOptions.VolumeLabel  = strDriveLabel;
                    dokanOptions.ThreadCount  = 1;

                    if (NoCache)
                    {
                        dokanOperation = new Operations();
                    }
                    else
                    {
                        dokanOperation = new CacheOperations(new Operations());
                    }
                    int status = DokanNet.DokanMain(dokanOptions, dokanOperation);
                    switch (status)
                    {
                    case DokanNet.DOKAN_DRIVE_LETTER_ERROR:
                        throw new ApplicationException("Drvie letter error");

                    case DokanNet.DOKAN_DRIVER_INSTALL_ERROR:
                        throw new ApplicationException("Driver install error");

                    case DokanNet.DOKAN_MOUNT_ERROR:
                        throw new ApplicationException("Mount error");

                    case DokanNet.DOKAN_START_ERROR:
                        throw new ApplicationException("Start error");

                    case DokanNet.DOKAN_ERROR:
                        throw new ApplicationException("Unknown error");

                    case DokanNet.DOKAN_SUCCESS:
                        break;

                    default:
                        throw new ApplicationException("Unknown status: " + status);
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }));

            ThreadPool.QueueUserWorkItem(new WaitCallback(
                                             delegate
            {
                Thread.Sleep(2000);
                Process.Start("explorer.exe", " " + MountPoint);
            }));
        }