示例#1
0
        FsDirectory GetDirectory(string filename)
        {
            if (filename == null)
            {
                return(this.rootdir);
            }
            string[]    names = filename.ToLower().Split(PathSeparators, System.StringSplitOptions.RemoveEmptyEntries);
            FsDirectory dir   = this.rootdir;

            foreach (string name in names)
            {
                FsNode node;
                if (!dir.files.TryGetValue(name, out node))
                {
                    return(null);
                }
                dir = node as FsDirectory;
                if (dir == null)
                {
                    return(null);
                }
            }

            return(dir);
        }
示例#2
0
        int DokanOperations.OpenDirectory(string filename, DokanFileInfo info)
        {
            FsMountPoint mnt = CheckMountPoint(ref filename);

            if (mnt != null)
            {
                return(mnt.FsOperation.OpenDirectory(filename, info));
            }

            FsDirectory dir = GetDirectory(filename);

            if (dir == null)
            {
                return(-WinErrorCode.ERROR_FILE_NOT_FOUND);
            }
            return(0);
        }
示例#3
0
        FsFile GetFile(string filename)
        {
            FsDirectory dir = GetDirectory(System.IO.Path.GetDirectoryName(filename));

            if (dir == null)
            {
                return(null);
            }
            string name = System.IO.Path.GetFileName(filename).ToLower();

            FsNode node;

            if (!dir.files.TryGetValue(name, out node))
            {
                return(null);
            }
            FsFile file = node as FsFile;

            return(file);

#if false
            int step = 0;
            try{
                step = 1;
                FsDirectory dir = GetDirectory(System.IO.Path.GetDirectoryName(filename));
                step = 2;
                string name = System.IO.Path.GetFileName(filename).ToLower();

                step = 3;
                FsNode node;
                step = 4;
                if (!dir.files.TryGetValue(name, out node))
                {
                    return(null);
                }
                step = 5;
                FsFile file = node as FsFile;
                return(file);
            }catch (System.NullReferenceException) {
                System.Console.WriteLine("#DEBUG NullReferenceException at GetFile(filename={0}) : step{1}", filename, step);
                return(null);
            }
#endif
        }
示例#4
0
        int DokanOperations.FindFiles(string filename, System.Collections.ArrayList files, DokanFileInfo info)
        {
            FsMountPoint mnt = CheckMountPoint(ref filename);

            if (mnt != null)
            {
                return(mnt.FsOperation.FindFiles(filename, files, info));
            }
            FsDirectory dir = GetDirectory(filename);

            if (dir == null)
            {
                return(-1);
            }

            // FindFiles
            foreach (Gen::KeyValuePair <string, FsNode> node in dir.files)
            {
                files.Add(node.Value.info);
            }
            return(0);
        }
示例#5
0
        public RootFsOperation(ProgramSetting setting)
        {
            rootdir = new FsDirectory("root");
            rootdir.info.Attributes |= System.IO.FileAttributes.System;
            rootdir.info.Attributes |= System.IO.FileAttributes.ReadOnly;

            FsFile file = rootdir.CreateFile("autorun.inf");

            file.info.Attributes |= System.IO.FileAttributes.ReadOnly;
            file.info.Attributes |= System.IO.FileAttributes.Hidden;
            file.info.Attributes |= System.IO.FileAttributes.System;
            file.SetContent("[autorun]\r\nicon=drive.ico\r\n");

            file = rootdir.CreateFile("desktop.ini");
            file.info.Attributes |= System.IO.FileAttributes.ReadOnly;
            file.info.Attributes |= System.IO.FileAttributes.Hidden;
            file.info.Attributes |= System.IO.FileAttributes.System;
            file.SetContent(GetDataFromResource("desktop.ini"));

            file = rootdir.CreateFile("drive.ico");
            file.info.Attributes |= System.IO.FileAttributes.ReadOnly;
            file.info.Attributes |= System.IO.FileAttributes.Hidden;
            file.info.Attributes |= System.IO.FileAttributes.System;
            file.SetContent(GetDataFromResource("DriveIcon.ico"));

            foreach (ISftpAccount acc in setting.accounts)
            {
                if (!acc.Enabled)
                {
                    continue;
                }

                FsMountPoint mnt = new FsMountSftp(acc);
                mnt.info.Attributes |= System.IO.FileAttributes.Offline;
                rootdir.files.Add(acc.Name, mnt);
                mntlist.Add("\\" + acc.Name, mnt);
            }
        }