Exemplo n.º 1
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
        }
Exemplo n.º 2
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);
            }
        }
Exemplo n.º 3
0
        int DokanOperations.GetFileInformation(string filename, FileInformation fileinfo, DokanFileInfo info)
        {
            FsMountPoint mnt = CheckMountPoint(ref filename);

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

            FsFile file = GetFile(filename);

            if (file == null)
            {
                return(-1);
            }
            fileinfo.FileName       = file.info.FileName;
            fileinfo.Length         = file.info.Length;
            fileinfo.Attributes     = file.info.Attributes;
            fileinfo.CreationTime   = file.info.CreationTime;
            fileinfo.LastAccessTime = file.info.LastAccessTime;
            fileinfo.LastWriteTime  = file.info.LastWriteTime;
            return(0);
        }