Пример #1
0
        public override VFSFolder[] GetFolders(string path)
        {
            if (!Visible)
                return null;
            DirectoryInfo currentDirectory = new DirectoryInfo(mappedDirectory.FullName + "/" + path);
            string fullVirtualPath = name + (path == "" ? "" : "/" + path);
            if (currentDirectory.Exists)
            {
                DirectoryInfo[] dirs = currentDirectory.GetDirectories();
                VFSFolder[] result = new VFSFolder[dirs.Length];

                for (int i = 0; i < dirs.Length; i++)
                {
                    result[i] = new VFSFolder(dirs[i].Name, fullVirtualPath + "/" + dirs[i].Name, dirs[i].LastWriteTime);
                }
                return result;
            }
            else
            {
                return null;
            }
        }
Пример #2
0
        public void ReturnFolderPage(VFSFile[] files, VFSFolder[] folders, string path, string args)
        {
            SortMode sortMode = SortMode.Name;

            string[] splittedArgs = args.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
            for (int i = 0; i < splittedArgs.Length; i++)
            {
                if (FabulousFileServer.sortArgRegex.IsMatch(splittedArgs[i]))
                {
                    string sortModeString = FabulousFileServer.sortArgRegex.Replace(splittedArgs[i], "$1");
                    switch (sortModeString.ToLower())
                    {
                        case "n":
                            sortMode = SortMode.Name;
                            break;
                        case "t":
                            sortMode = SortMode.Time;
                            break;
                        case "e":
                            sortMode = SortMode.Extention;
                            break;
                        case "s":
                            sortMode = SortMode.Size;
                            break;
                        case "~n":
                            sortMode = SortMode.RName;
                            break;
                        case "~t":
                            sortMode = SortMode.RTime;
                            break;
                        case "~e":
                            sortMode = SortMode.RExtention;
                            break;
                        case "~s":
                            sortMode = SortMode.RSize;
                            break;
                    }
                }
            }

            switch (sortMode)
            {
                case SortMode.Name:
                    ReturnSortedPage(files.OrderBy(x => x.name), folders.OrderBy(x => x.name));
                    break;
                case SortMode.Extention:
                    ReturnSortedPage(files.OrderBy(x => x.extention), folders.OrderBy(x => x.name));
                    break;
                case SortMode.Time:
                    ReturnSortedPage(files.OrderBy(x => x.date), folders.OrderBy(x => x.date));
                    break;
                case SortMode.Size:
                    ReturnSortedPage(files.OrderBy(x => x.size), folders.OrderBy(x => x.name));
                    break;
                case SortMode.RName:
                    ReturnSortedPage(files.OrderByDescending(x => x.name), folders.OrderByDescending(x => x.name));
                    break;
                case SortMode.RExtention:
                    ReturnSortedPage(files.OrderByDescending(x => x.extention), folders.OrderByDescending(x => x.name));
                    break;
                case SortMode.RTime:
                    ReturnSortedPage(files.OrderByDescending(x => x.date), folders.OrderByDescending(x => x.date));
                    break;
                case SortMode.RSize:
                    ReturnSortedPage(files.OrderByDescending(x => x.size), folders.OrderByDescending(x => x.name));
                    break;
            }
        }