Пример #1
0
 public void Init()
 {
     _fileSystem = new MockFileSystem(new Dictionary <string, MockFileData>
     {
         { @"c:\myfile.txt", new MockFileData("Testing is meh.") },
         { @"c:\picture.jpg", new MockFileData("") },
         { @"c:\anotherfile.txt", new MockFileData("Lorem Ipsum") },
         { @"c:\Dir\", new MockDirectoryData() },
         { @"c:\Dir\Subdir1\Subdir4\Subdir6\", new MockDirectoryData() },
         { @"c:\Dir\Subdir2\Subdir5\", new MockDirectoryData() },
         { @"c:\Dir\Subdir3\", new MockDirectoryData() },
         { @"c:\demo\jQuery.js", new MockFileData("some js") },
         { @"c:\demo\sample.txt", new MockFileData("text blub") }
     });
     _tree = new DirectoryTree(@"c:\");
     _tree.SubDirectories.Add(new DirectoryTree(@"c:\Dir"));
     _tree.SubDirectories[0].SubDirectories.Add(new DirectoryTree(@"c:\Dir\Subdir1"));
     _tree.SubDirectories[0].SubDirectories.Add(new DirectoryTree(@"c:\Dir\Subdir2"));
     _tree.SubDirectories[0].SubDirectories.Add(new DirectoryTree(@"c:\Dir\Subdir3"));
     _tree.SubDirectories[0].SubDirectories[0].SubDirectories.Add(new DirectoryTree(@"c:\Dir\Subdir1\Subdir4"));
     _tree.SubDirectories[0].SubDirectories[0].SubDirectories[0].SubDirectories.Add(
         new DirectoryTree(@"c:\Dir\Subdir1\Subdir4\Subdir6"));
     _tree.SubDirectories[0].SubDirectories[1].SubDirectories.Add(new DirectoryTree(@"c:\Dir\Subdir2\Subdir5"));
     _tree.SubDirectories.Add(new DirectoryTree(@"c:\demo"));
 }
Пример #2
0
        private HierarchicalLibraryItem CreateDirectoryBranchNodesRecursively(Directory directory, IDictionary <Directory, HierarchicalLibraryItem> directoryLookup)
        {
            HierarchicalLibraryItem result = null;

            if (directory.Parent == null)
            {
                if (directoryLookup.TryGetValue(directory, out var item))
                {
                    return(item);
                }
                result = new HierarchicalLibraryItem(directory, DirectoryTreeController);
                DirectoryTree.Add(result);
            }
            else if (directoryLookup.ContainsKey(directory.Parent))
            {
                result = new HierarchicalLibraryItem(directory, directoryLookup[directory.Parent]);
            }
            else
            {
                result = new HierarchicalLibraryItem(directory, CreateDirectoryBranchNodesRecursively(directory.Parent, directoryLookup));
            }

            directoryLookup[directory] = result;
            return(result);
        }
Пример #3
0
        public async Task <DirectoryTree> GetblobsInContainer(string sasKey)
        {
            CloudBlobContainer    container         = new CloudBlobContainer(new Uri(sasKey));
            BlobContinuationToken continuationToken = null;
            //List<IListBlobItem> blobItems = new List<IListBlobItem>();
            DirectoryTree tree = new DirectoryTree();

            do
            {
                BlobResultSegment blobSegment = await container.ListBlobsSegmentedAsync(continuationToken);

                continuationToken = blobSegment.ContinuationToken;
                foreach (IListBlobItem item in blobSegment.Results)
                {
                    Node newRoot = tree.AddNode(item);
                    if (item is CloudBlobDirectory)
                    {
                        Debug.WriteLine($"{((CloudBlobDirectory)item).Prefix} is a directory");
                        //directories.Add((CloudBlobDirectory)item);
                        await RecursiveFolderSearch(newRoot, (CloudBlobDirectory)item);
                    }
                }
            }while (continuationToken != null);

            {}          return(tree);
        }
Пример #4
0
        private void PopulateDirectoryTree()
        {
            DirectoryTreeController.Clear();
            DirectoryTree.Clear();

            IDictionary <Directory, HierarchicalLibraryItem> directoryLookup = new SortedDictionary <Directory, HierarchicalLibraryItem>();

            foreach (Directory directory in m_DataModel.Database.Directories.Values)
            {
                CreateDirectoryBranchNodesRecursively(directory, directoryLookup);
            }

            foreach (Song song in m_DataModel.Database.Songs.Values)
            {
                if (song.Directory == null)
                {
                    DirectoryTree.Add(new HierarchicalLibraryItem(song, DirectoryTreeController));
                }
                else
                {
                    new HierarchicalLibraryItem(song, directoryLookup[song.Directory]);
                }
            }

            DirectoryTreeController.ResetNodeIds();
        }
Пример #5
0
        public void CreateTree()
        {
            DirectoryInfo dir     = Directory.GetParent("..\\..\\TestDirectory");
            DirectoryTree dirTree = new DirectoryTree(dir.FullName + "\\TestDirectory");

            Assert.IsNotNull(dirTree);
        }
Пример #6
0
        private void PopulateDirectoryTree()
        {
            DirectoryTreeController.ClearMultiSelection();
            DirectoryTree.Clear();

            DirectoryTreeViewNode rootNode = new DirectoryTreeViewNode("/", null, DirectoryTreeController);
            IDictionary <string, TreeViewNode> directoryLookup = new SortedDictionary <string, TreeViewNode>();

            directoryLookup[rootNode.DisplayString] = rootNode;

            foreach (SongMetadata song in m_DataModel.Database.Songs)
            {
                TreeViewNode             parent = FindDirectoryNode(song.Directory, directoryLookup, rootNode);
                SongMetadataTreeViewNode leaf   = new SongMetadataTreeViewNode(song.Filename, song, parent, DirectoryTreeController);
                parent.AddChild(leaf);
            }

            AssignTreeViewNodeIDs(rootNode, 0);

            if (rootNode.Children.Count > 0)
            {
                DirectoryTree.Add(rootNode);
                rootNode.IsExpanded = true;
            }
        }
    static void WalkDirectoryTree(DirectoryInfo root, DirectoryTree folderTree, Folder currentFolder)
    {
        FileInfo[] files = null;
        DirectoryInfo[] subDirs = null;

        try
        {
            files = root.GetFiles("*.*");
        }

        catch (UnauthorizedAccessException e)
        {
            log.Add(e.Message);
        }

        catch (DirectoryNotFoundException e)
        {
            Console.WriteLine(e.Message);
        }

        if (files != null)
        {
            currentFolder.Files = files.Select(f => new File(f.Name, f.Length)).ToList();

            subDirs = root.GetDirectories();

            currentFolder.ChildFolders = subDirs.Select(d => new Folder(d.Name)).ToList();
            var i = 0;
            foreach (DirectoryInfo dirInfo in subDirs)
            {
                WalkDirectoryTree(dirInfo, folderTree, currentFolder.ChildFolders[i]);
                i++;
            }
        }
    }
Пример #8
0
 public override void Setup()
 {
     base.Setup();
     _listOfSelectedDirs         = new List <DirectoryInfo>();
     _dirTree                    = new DirectoryTree();
     _dirTree.DirectorySelected += LogDirectorySelected;// listOfSelectedDirs.Add;
 }
Пример #9
0
            private void CreateTreeData(DirectoryInfo rootFolder)
            {
                // 기존에 작업 중인 경우에는 시도조차 X
                if (isCalculating == TRUE)
                {
                    return;
                }

                // 작업 시작 예약
                onGuiChangedQueue.Enqueue(() =>
                {
                    calculatingIndex = 0;
                    isCalculating    = TRUE;
                    Repaint();
                });

                var newTreeRoot = new DirectoryTree(rootFolder, 0); // 실제 처리

                // 변경 사항 적용 예약
                onGuiChangedQueue.Enqueue(() =>
                {
                    treeRoot      = newTreeRoot;
                    isCalculating = FALSE;
                });
            }
Пример #10
0
        public void CorrectRootFolder()
        {
            DirectoryInfo dir     = Directory.GetParent("..\\..\\TestDirectory");
            DirectoryTree dirTree = new DirectoryTree(dir.FullName + "\\TestDirectory");
            Folder        folder  = dirTree.RootFolder;

            Assert.AreEqual("TestDirectory", folder.Name);
        }
Пример #11
0
        public void RootFilesFound()
        {
            DirectoryInfo dir     = Directory.GetParent("..\\..\\TestDirectory");
            DirectoryTree dirTree = new DirectoryTree(dir.FullName + "\\TestDirectory");
            Folder        folder  = dirTree.RootFolder;

            Assert.AreEqual(3, folder.Files.Count);
        }
Пример #12
0
        public void RootSize()
        {
            DirectoryInfo dir     = Directory.GetParent("..\\..\\TestDirectory");
            DirectoryTree dirTree = new DirectoryTree(dir.FullName + "\\TestDirectory");
            double        size    = dirTree.CalculateSizeOfTree();

            Assert.AreEqual(5, (int)size);
        }
Пример #13
0
        public void FolderSize()
        {
            DirectoryInfo dir     = Directory.GetParent("..\\..\\TestDirectory");
            DirectoryTree dirTree = new DirectoryTree(dir.FullName + "\\TestDirectory");
            double        size    = dirTree.CalculateSizeOfFolder("4");

            Assert.IsTrue(size >= 2d && size < 2.1d);
        }
Пример #14
0
    static void Main(string[] args)
    {
        string directoryName = @"C:\Program Files\Intel\TVWiz2ft";
        Folder folder        = new Folder(directoryName);

        DirectoryTree.CreateTree(folder);
        DirectoryTree.PrintTree(folder, string.Empty);
        Console.WriteLine(DirectoryTree.GetAllFileSize(folder));
    }
        public IExplorerViewModel OpenTab(IEntryModel model = null)
        {
            var initializer = _initializer.Clone();

            if (initializer is ExplorerInitializer)
            {
                ExplorerInitializer eInit = initializer as ExplorerInitializer;
                if (model != null)
                {
                    eInit.Initializers.Add(ExplorerInitializers.StartupDirectory(model));
                }
            }
            else
            if (initializer is ScriptCommandInitializer)
            {
                ScriptCommandInitializer sInit = initializer as ScriptCommandInitializer;

                sInit.OnViewAttached = (model != null) ?
                                       ScriptCommands.Assign("{StartupPath}", model.FullPath, false,
                                                             UIScriptCommands.ExplorerGotoStartupPathOrFirstRoot()) :
                                       UIScriptCommands.ExplorerGotoStartupPathOrFirstRoot();

                sInit.OnModelCreated = ScriptCommands.Assign("{TabbedExplorer}", this, false,
                                                             UIScriptCommands.ExplorerAssignScriptParameters("{Explorer}", "{TabbedExplorer}",
                                                                                                             sInit.OnModelCreated));
            }


            ExplorerViewModel expvm = new ExplorerViewModel(_windowManager, _events)
            {
                Initializer = initializer
            };

            //expvm.Commands.ParameterDicConverter.AddAdditionalParameters(new ParameterDic()
            //    {
            //        {"TabbedExplorer", this }
            //    });
            expvm.DropHelper = new TabDropHelper <IExplorerViewModel>(expvm, this);

            //expvm.FileList.Commands.CommandDictionary.CloseTab =
            //    UIScriptCommands.TabExplorerCloseTab("{TabbedExplorer}", "{Explorer}");
            ////ScriptCommands.ReassignToParameter("{Explorer}", TabbedExplorer.CloseTab(this));
            expvm.FileList.Commands.CommandDictionary.OpenTab =
                ScriptCommands.Assign("{TabbedExplorer}", this, false,
                                      FileList.AssignSelectionToParameter(
                                          UIScriptCommands.TabExplorerNewTab("{TabbedExplorer}", "{Parameter}", null)));
            expvm.DirectoryTree.Commands.CommandDictionary.OpenTab =
                ScriptCommands.Assign("{TabbedExplorer}", this, false,
                                      DirectoryTree.AssignSelectionToParameter(
                                          UIScriptCommands.TabExplorerNewTab("{TabbedExplorer}", "{Parameter}", null)));

            ActivateItem(expvm);
            checkTabs();

            return(expvm);
        }
Пример #16
0
        public void GetRoot_RootDirectory_HasDirectories()
        {
            string rootDirectory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
            DirectoryTree tree = new DirectoryTree();
            tree.Name = DirectoryTreePopulator.GetName(rootDirectory);
            tree.Location = rootDirectory;
            tree.PopulateTree();

            Assert.IsTrue(tree.Directories.Count > 0);
        }
Пример #17
0
 public void GetAllTextFiles()
 {
     var fileViewer = new FileViewer(_fileSystem);
     var files = fileViewer.GetAllTextFiles(_tree);
     var tree = new DirectoryTree(_tree);
     tree.Files.Add(@"c:\myfile.txt");
     tree.Files.Add(@"c:\anotherfile.txt");
     tree.SubDirectories[1].Files.Add(@"c:\demo\sample.txt");
     Assert.AreEqual(tree, files);
 }
Пример #18
0
        public void GetAllTextFiles()
        {
            var fileViewer = new FileViewer(_fileSystem);
            var files      = fileViewer.GetAllTextFiles(_tree);
            var tree       = new DirectoryTree(_tree);

            tree.Files.Add(@"c:\myfile.txt");
            tree.Files.Add(@"c:\anotherfile.txt");
            tree.SubDirectories[1].Files.Add(@"c:\demo\sample.txt");
            Assert.AreEqual(tree, files);
        }
Пример #19
0
 private void BuildTreeRecursion(DirectoryTree tree)
 {
     foreach (var str in _fileSystem.Directory.GetDirectories(tree.Name)
         .Select(str => new DirectoryTree(_fileSystem.Path.GetDirectoryName(str))))
     {
         if (str.Name == tree.Name)
             continue;
         tree.SubDirectories.Add(str);
         BuildTreeRecursion(str);
     }
 }
        /// <summary>
        /// Построить дерево папок.
        /// </summary>
        /// <returns>Дерево папок.</returns>
        private ObservableCollection <DirectoryTree> BuildDirectoryTree()
        {
            string driveName = Directory.GetDirectoryRoot(AppDomain.CurrentDomain.BaseDirectory);

            var root = new DirectoryTree(driveName);
            var ret  = new ObservableCollection <DirectoryTree> {
                root
            };

            return(ret);
        }
Пример #21
0
 public DirectoryTreeWatcher(DirectoryTree target, int side, string path, System.Windows.Threading.Dispatcher disp, ChangeHandler Change,
     HashSet<string> fullTextExtensions,
     PleaseWait initProgress)
 {
     this.target = target;
     this.side = side;
     this.path = path;
     this.Change += Change;
     this.disp = disp;
     this.fullTextExtensions = fullTextExtensions;
     init(initProgress);
 }
Пример #22
0
        private void Form1_Load(object sender, EventArgs e)
        {
            var dirTree = new DirectoryTree
            {
                Size     = new Size(this.Width - 30, this.Height - 50),
                Location = new Point(5, 5),
                Drive    = char.Parse("C"),
                Anchor   = AnchorStyles.Left | AnchorStyles.Top | AnchorStyles.Right | AnchorStyles.Bottom
            };

            this.Controls.Add(dirTree);
        }
Пример #23
0
        public void SearchedFolderFound()
        {
            DirectoryInfo dir     = Directory.GetParent("..\\..\\TestDirectory");
            DirectoryTree dirTree = new DirectoryTree(dir.FullName + "\\TestDirectory");
            Folder        folder  = dirTree.FindFolder("1");

            Assert.AreEqual("1", folder.Name);

            Assert.AreEqual(1, folder.Files.Count);

            Assert.AreEqual(2, folder.Folders.Count);
        }
Пример #24
0
        public static void Build()
        {
            PlayerSettings.SplashScreen.showUnityLogo = false;
            // LevelSetAddressablePreBuildProcessor.PreExport();

            var scenes      = EditorBuildSettings.scenes.Where(s => s.enabled).Select(s => s.path).ToArray();
            var args        = Environment.GetCommandLineArgs();
            var buildTarget = BuildTarget.NoTarget;
            var outputPath  = "";

            for (var i = 0; i < args.Length; i++)
            {
                if (args[i] == "-buildTarget")
                {
                    switch (args[i + 1])
                    {
                    case "Android":
                        buildTarget = BuildTarget.Android;
                        break;

                    case "iOS":
                        buildTarget = BuildTarget.iOS;
                        break;

                    case "Mac":
                        buildTarget = BuildTarget.StandaloneOSX;
                        break;

                    case "Windows":
                        buildTarget = BuildTarget.StandaloneWindows;
                        break;

                    case "WebGL":
                        buildTarget = BuildTarget.WebGL;
                        break;

                    default:
                        Debug.LogError($"{args[i + 1]} is not supported.");
                        EditorApplication.Exit(1);
                        break;
                    }
                }
                if (args[i] == "-outputPath")
                {
                    outputPath = args[i + 1];
                }
            }
            BuildPipeline.BuildPlayer(scenes, outputPath, buildTarget, BuildOptions.None);
            Debug.Log("Build Completed!");
            Debug.Log($"Output Path: {outputPath}");
            DirectoryTree.PrintDirectoryTree(outputPath);
        }
Пример #25
0
        public async Task <bool> Refresh()
        {
            DateTime start = DateTime.Now;

            AddLog("Refreshing Directory: " + Directory);
            repository_tab_.EnterLoadingScreen();

            if (RefreshBranch() == false)
            {// invalid repository
                repository_tab_.LeaveLoadingScreen();
                repository_tab_.EnterFailedScreen();
                git_ = null;
                return(false);
            }

            DirectoryTree.ReloadTreeView();

            Task <List <string> > git_porcelain_result = git_.GetGitStatusPorcelainAllAsync();
            Task <int>            stashTabResult       = _stashTabViewModel.RefreshAndGetStashCount();
            Task branchTabResult = _branchTabViewModel.Refresh();
            Task tagTabResult    = _tagTabViewModel.Refresh();
            Task remoteTabResult = _remoteTabViewModel.Refresh();

            _pendingTabViewModel.RefreshPending(await git_porcelain_result);

            int stashListCount = await stashTabResult;

            if (stashListCount > 0)
            {
                StashTabHeader = $"Stash [{stashListCount}]";
            }
            else
            {
                StashTabHeader = "Stash";
            }
            NotifyPropertyChanged("StashTabHeader");
            await branchTabResult;
            await remoteTabResult;
            await tagTabResult;

            AddLog("Refreshed");

            repository_tab_.LeaveLoadingScreen();

            if (System.Diagnostics.Debugger.IsAttached)
            {
                TimeSpan elapsed = DateTime.Now - start;
                AddLog($"Refresh elapsed: {elapsed.TotalMilliseconds}");
            }

            return(true);
        }
    static void Main()
    {
        DirectoryInfo rootDir = new DirectoryInfo(@"C:\WINDOWS");
        var rootFolder = new Folder(rootDir.Name);
        var folderTree = new DirectoryTree(rootFolder);
        WalkDirectoryTree(rootDir, folderTree, rootFolder);
        foreach (string s in log)
        {
            Console.WriteLine(s);
        }

        Console.WriteLine("The directory {0} size is: {1} MB ( {2} bytes ).", rootDir.FullName, folderTree.Root.GetFolderSize() / 1024 / 1024, folderTree.Root.GetFolderSize());
    }
Пример #27
0
        private TreeNode RefreshTreeView(TreeNodeCollection parentNodes, DirectoryTree <TREInfoFile> item, bool isRoot)
        {
            var node = new TreeNode();

            node.Text = isRoot ? "Resources" : item.DirectoryName;
            node.Tag  = item;
            parentNodes.Add(node);
            foreach (var childDirectory in item.Directories)
            {
                RefreshTreeView(node.Nodes, childDirectory, false);
            }
            return(node);
        }
Пример #28
0
        public async Task GoAsync(IEntryModel entryModel)
        {
            entryModel = entryModel ?? RootModels.FirstOrDefault();
            if (entryModel != null)
            {
                await Task.WhenAll(
                    FileList.SetCurrentDirectoryAsync(entryModel),
                    DirectoryTree.SelectAsync(entryModel),
                    Breadcrumb.Selection.AsRoot().SelectAsync(entryModel));

                NotifyOfPropertyChange(() => CurrentDirectory);
                NotifyOfPropertyChange(() => CurrentDirectory);
            }
        }
Пример #29
0
        private void AppendTreeRecursion(DirectoryTree tree, bool isTextSearch)
        {
            if (isTextSearch)
                foreach (var file in ConfigurationManager.AppSettings["TextFileFormats"].Split('|')
                    .SelectMany(str => _fileSystem.Directory.GetFiles(tree.Name, str)))
                    tree.Files.Add(file);

            else
                foreach (var file in _fileSystem.Directory.GetFiles(tree.Name))
                    tree.Files.Add(file);

            foreach (var dir in tree.SubDirectories)
                AppendTreeRecursion(dir, isTextSearch);
        }
Пример #30
0
    private void Awake()
    {
        //workspacePath = GameObject.Find("DataCache").GetComponent<DataCache>().Find("WorkspaceName");
        var    dataPath      = FileAndDirectory.Instance.WorkspacePath;
        string workspacePath = "Demo";

        //folderList = new List<GameObject>();
        //fileList = new List<GameObject>();
        FileAndDirectory.Instance.ProjectName = workspacePath;
        //UpdateDictionaryTree(FileAndDictionary.Instance.FolderPath, transform);
        dt = new DirectoryTree(FileAndDirectory.Instance.FolderPath, transform);
        dt.ScanFolder(folderObj, fileObj);
        dt.Extend();
    }
Пример #31
0
        void renameTree(DirectoryTree node)
        {
            foreach (var c in node.Children)
                renameTree(c as DirectoryTree);

            if (node.FullName.EndsWith(".prop.xml"))
            {
                if (node.LeftPresent)
                    foreach (var oldName in oldNames)
                        if (node.LeftContains(oldName))
                        {
                            if ((new RebuildPropertyFile(leftPath + node.Path)).Failed)
                                errors.Add(leftPath + node.Path);
                            break;
                        }
                if (node.RightPresent)
                    foreach (var oldName in oldNames)
                        if (node.RightContains(oldName))
                        {
                            if ((new RebuildPropertyFile(rightPath + node.Path)).Failed)
                                errors.Add(rightPath + node.Path);
                            break;
                        }
            }

            try
            {
                var hash = NameRegistry.Files.toHash(node.BaseName);
                if (hashes.Contains(hash))
                {
                    string newPath = node.Parent.Path + "\\" +
                                     NameRegistry.Files.toName(hash);
                    string ext = node.FileType;
                    if (ext != "") newPath += "." + ext;
                    if (newPath != node.Path)
                    {
                        if (node.LeftPresent)
                            System.IO.Directory.Move(leftPath + node.Path, leftPath + newPath);
                        if (node.RightPresent)
                            System.IO.Directory.Move(rightPath + node.Path, rightPath + newPath);
                    }
                }
            }
            catch (Exception)
            {
                if (node.LeftPresent) errors.Add(leftPath + node.Path);
                if (node.RightPresent) errors.Add(rightPath + node.Path);
            }
        }
Пример #32
0
            /// <summary> 하위 폴더 트리 생성 </summary>
            private void InitFolders(DirectoryInfo folderInfo)
            {
                DirectoryInfo[] subFolders     = folderInfo.GetDirectories();
                int             subFolderCount = subFolders.Length;

                if (subFolderCount > 0)
                {
                    folders = new DirectoryTree[subFolderCount];

                    for (int i = 0; i < subFolderCount; i++)
                    {
                        folders[i] = new DirectoryTree(subFolders[i], this.depth + 1, this);
                    }
                }
            }
        public async Task <string> Get(string resourceReferrence)
        {
            string userId     = HttpContext.User.Claims.FirstOrDefault(c => c.Type == "userId").Value;
            string oAuthToken = Startup.userTokenCache[userId];
            string resourceId = resourceReferrence.Substring(resourceReferrence.Length - Guid.NewGuid().ToString().Length);
            string sasKey     = await _dataApiRepo.GetSasKey(oAuthToken, resourceId);

            DirectoryTree tree = await _azureblobStorageRepo.GetblobsInContainer(sasKey);


            string treeInStringFormat = JsonConvert.SerializeObject(tree);

            Debug.WriteLine("\n\n\n\n" + treeInStringFormat + "\n\n\n\n");
            return(treeInStringFormat);
        }
Пример #34
0
        public void RootFoldersFound()
        {
            DirectoryInfo dir     = Directory.GetParent("..\\..\\TestDirectory");
            DirectoryTree dirTree = new DirectoryTree(dir.FullName + "\\TestDirectory");
            Folder        folder  = dirTree.RootFolder;

            List <Folder> folders = folder.Folders;

            Assert.AreEqual(4, folders.Count);

            for (int i = 0; i < folders.Count; i++)
            {
                Assert.AreEqual((i + 1).ToString(), folders[i].Name);
            }
        }
Пример #35
0
            public DirectoryTree(DirectoryInfo folderInfo, int depth, DirectoryTree parent = null)
            {
                //this.folderInfo = folderInfo;
                this.folderName     = folderInfo.Name;
                this.depth          = depth;
                this.totalLineCount = 0;

                InitFolders(folderInfo);
                InitCsFiles(folderInfo);

                // 라인 수 집계를 부모에 가산
                if (parent != null)
                {
                    parent.totalFileCount += this.totalFileCount;
                    parent.totalLineCount += this.totalLineCount;
                }
            }
    static void Main()
    {
        Console.WriteLine("Wait a minute:");
            DirectoryTree dirTree = new DirectoryTree("C:\\Windows");

            Console.WriteLine("Done.");

            Console.WriteLine("\nTree size: ");
            double sizeInMB = dirTree.CalculateSizeOfTree();
            Console.WriteLine("{0} megabytes", sizeInMB);
            Console.WriteLine("{0} or gigabytes", sizeInMB / 1024);

            Console.WriteLine();
            Console.WriteLine("Calculate size of tree folder and subfolders: ");
            sizeInMB = dirTree.CalculateSizeOfFolder("AppCompat");
            Console.WriteLine("{0} megabytes", sizeInMB);
            Console.WriteLine("{0} or gigabytes", sizeInMB / 1024);
    }
Пример #37
0
        private bool ValidatePath(string p_Path, Procedimento p_Proc)
        {
            bool v_Success = false;

            if (VerifyResultsDirectory())
            {
                GlobalVar.v_Name_OK  = GenerateFilePath(Constantes.FileNames.OK);
                GlobalVar.v_Name_Err = GenerateFilePath(Constantes.FileNames.ERROR);

                string[] v_Lines = p_Path.Split(
                    new[] { "\r\n", "\r", "\n" },
                    StringSplitOptions.None
                    );

                switch (p_Proc)
                {
                case Procedimento.WEB:
                    v_Success = ValidateWEB(v_Lines);
                    break;

                case Procedimento.Varredura:
                {
                    DirectoryTree FolderTree = new DirectoryTree(this.tb_DiretorioPai.Text);
                    Output.Print(FolderTree.FolderTreeStats.FinalReport);
                    v_Success = true;
                }
                break;

                case Procedimento.Arquivo:
                default:
                    v_Success = ValidateFileDirectories(v_Lines);
                    break;
                }

                return(v_Success);
            }
            else
            {
                return(false);
            }
        }
Пример #38
0
    public void OpenFolder(GameObject obj)
    {
        List <string> path = new List <string>
        {
            obj.name
        };
        Transform t = obj.transform;

        t = t.parent;
        while (t != transform)
        {
            path.Add(t.name);
            t = t.parent;
        }
        DirectoryTree dtt = dt;

        for (int i = path.Count - 1; i >= 0; i--)
        {
            dtt = dtt.Find(path[i]);
        }
        dtt.Extend();
    }
Пример #39
0
        public void GetRoot_RootDirectory_EachNodeHasFiles()
        {
            string rootDirectory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
            DirectoryTree tree = new DirectoryTree();
            tree.Name = DirectoryTreePopulator.GetName(rootDirectory);
            tree.Location = rootDirectory;
            tree.PopulateTree();

            List<DirectoryTree> badTrees = new List<DirectoryTree>();

            foreach (DirectoryTree file in tree.Directories)
            {
                if (file.Files.Count > 0 || file.Directories.Count > 0)
                    continue;

                badTrees.Add(file);
            }

            foreach (DirectoryTree badTree in badTrees)
            {
                Console.WriteLine(badTree.Location);
            }
        }
Пример #40
0
        private void LoadRepository(string directoryName, out IRepository repository, out DirectoryTree <TREInfoFile> directoryTree)
        {
            this.Cursor = Cursors.WaitCursor;
            try
            {
                repository    = null;
                directoryTree = null;

                if (string.IsNullOrEmpty(directoryName))
                {
                    return;
                }

                var localRepository = Wxv.Swg.Common.Repository.Load(directoryName);

                IEnumerable <TREInfoFile> treInfoFiles;
                if (localRepository != null)
                {
                    treInfoFiles = localRepository.Files
                                   .SelectMany(tf => tf.TREFile.InfoFiles, (tf, tfif) => new TREInfoFile(localRepository, tf.FileName, tfif))
                                   .OrderBy(tif => tif.Path)
                                   .ToList();
                }
                else
                {
                    treInfoFiles = new TREInfoFile[] { }
                };

                repository    = localRepository;
                directoryTree = DirectoryTree <TREInfoFile> .Get("", treInfoFiles, tif => tif.Path, "/");
            }
            finally
            {
                this.Cursor = Cursors.Default;
            }
        }
Пример #41
0
 private DirectoryTree BuildTree(string path)
 {
     var tree = new DirectoryTree(path);
     BuildTreeRecursion(tree);
     return tree;
 }
Пример #42
0
 void update()
 {
     files.Search( new SearchSpec(FileSearch.Text) );
     if (ShowRightOnly.IsChecked == true)
         files.SearchRightPresent();
     DirTree.Data.ClearAll();
     DirTree.Data.AddRootItem(files);
     if (IsVisible)
     {
         if (lastSelectedFile != null && lastSelectedFile.Parent != null &&
             !lastSelectedFile.LeftPresent && !lastSelectedFile.RightPresent)
         {
             // File has been deleted or renamed.  Check for renaming
             UInt32 instance = NameRegistry.Files.toHash(lastSelectedFile.BaseName);
             UInt32 group = NameRegistry.Groups.toHash(lastSelectedFile.Parent.Path);
             UInt32 ext = NameRegistry.Types.toHash(lastSelectedFile.FileType);
             string newpath = NameRegistry.Groups.toName(group) + "\\" + NameRegistry.Files.toName(instance) + "." + NameRegistry.Types.toName(ext);
             lastSelectedFile = files.getFile(newpath, false);
         }
         DirTree.SelectedItem = lastSelectedFile;
         if (DirTree.SelectedItem != null)
         {
             DirTree.ScrollIntoView(DirTree.SelectedItem);
         }
         /*if (editing != null && DirTree.SelectedItem != null &&
             editing == RightPath + "\\" + (DirTree.SelectedItem as DirectoryTree).Path)
         {
             if (System.IO.File.GetLastWriteTimeUtc(editing) >
         }*/
         updateEditorSearch();
     }
 }
Пример #43
0
        private void LoadRepository(string directoryName, out IRepository repository, out DirectoryTree<TREInfoFile> directoryTree)
        {
            this.Cursor = Cursors.WaitCursor;
            try
            {
                repository = null;
                directoryTree = null;

                if (string.IsNullOrEmpty(directoryName))
                    return;

                var localRepository = Wxv.Swg.Common.Repository.Load(directoryName);

                IEnumerable<TREInfoFile> treInfoFiles;
                if (localRepository != null)
                    treInfoFiles = localRepository.Files
                        .SelectMany(tf => tf.TREFile.InfoFiles, (tf, tfif) => new TREInfoFile(localRepository, tf.FileName, tfif))
                        .OrderBy(tif => tif.Path)
                        .ToList();
                else
                    treInfoFiles = new TREInfoFile[] { };

                repository = localRepository;
                directoryTree = DirectoryTree<TREInfoFile>.Get("", treInfoFiles, tif => tif.Path, "/");
            }
            finally
            {
                this.Cursor = Cursors.Default;
            }
        }
Пример #44
0
 public DirectoryTree GetAllFiles(DirectoryTree tree)
 {
     return AppendTree(tree, false);
 }
Пример #45
0
    protected override void OnInit(EventArgs e)
    {
        if (!WAFContext.Session.Access.IsAdmin()) throw new AccessViolationException("Only admins has access to this module. ");
        _tree = new DirectoryTree();
        _tree.RootFolder = WAFContext.PathFromRootToAppFolder;
        _tree.PostOnClick = false;
        _tree.DblClick += new EventHandler(tree_DblClick);
        _tree.Drop += new EventHandler(_tree_Drop);
        _tree.Remove += new EventHandler(_tree_Remove);
        _tree.AllowDropBetweenElements = false;
        _tree.AllowDropOnElements = true;
        _tree.AllowRemoveDrag = true;
        ddlEncoding.AutoPostBack = true;
        ddlEncoding.SelectedIndexChanged += new EventHandler(ddlEncoding_SelectedIndexChanged);

        leftPanel.Controls.Add(_tree);
        folderIcon.ImageUrl = WAFContext.GetUrlFromHostToClassIcon(FileFolder.ContentClassId);
        //btnFolderSave.Click += new EventHandler(btnFolderSave_Click);
        btnFolderNewFile.WorkflowMethodCompleted += new EventHandler<WorkflowMethodArgs>(newPath_WorkflowMethodCompleted);
        btnFolderCompress.WorkflowMethodCompleted += new EventHandler<WorkflowMethodArgs>(newPath_WorkflowMethodCompleted);
        btnFolderCopy.WorkflowMethodCompleted += new EventHandler<WorkflowMethodArgs>(newPath_WorkflowMethodCompleted);
        btnFolderCreateFolder.WorkflowMethodCompleted += new EventHandler<WorkflowMethodArgs>(newPath_WorkflowMethodCompleted);
        btnFileOpenFolder.Click += new EventHandler(btnFileOpenFolder_Click);
        btnNativeEdit.Click += new EventHandler(btnNativeEdit_Click);
        //btnFileSaveName.Click += new EventHandler(btnFileSaveName_Click);
        btnSaveContent.Click += new EventHandler(btnSaveContent_Click);
        MainMenu menu = WAFMaster.EditModule.Menu;
        menu.SetMenu(this.GetMenuItems());
        menu.SetItemCheckStatus("Options_StopMonitorNonSpecialChanges", WAFContext.HasStoppedFSMonitoringNonSpecialFolders);
        menu.SetItemCheckStatus("Options_StopMonitorAllChanges", WAFContext.HasStoppedFSMonitoringAllFolders);
        menu.Click += new EventHandler<MainMenuItem>(menu_Click);
        _editor = new CodeEditor();
        _editor.Height = Unit.Percentage(100);
        _editor.Width = Unit.Percentage(100);
        pnlEditor.Controls.Add(_editor);
        _tree.ShowFiles = WAFMaster.EditModule.Menu.IsItemChecked("View_ShowFilesInTree");
        fileList.DblClick += new EventHandler(fileList_DblClick);
        fileList.Remove += new EventHandler(fileList_Remove);
        fileList.AllowRemoveDrag = true;
        fileList.AllowDrop = false;
        if (!IsPostBack) {
            ddlEncoding.Items.Add(new ListItem("", "0"));
            foreach (EncodingInfo enc in from f in Encoding.GetEncodings() orderby f.DisplayName select f) {
                ddlEncoding.Items.Add(new ListItem(enc.DisplayName, enc.CodePage.ToString()));
            }
        }
        base.OnInit(e);
    }
Пример #46
0
 private void Tree_SelectedItemChanged(object sender, SelectionChangedEventArgs e)
 {
     var s = (sender as VTreeView.VTreeView).SelectedItem as DirectoryTree;
     SelectedFilePanel.IsEnabled = (s != null);
     if (s != null)
     {
         lastSelectedFile = s;
         SelectedFileLabel.Text = s.Path;
         SelectedFile_Open.IsEnabled = s.LeftPresent;
         SelectedFile_Erase.IsEnabled = s.RightPresent;
         var f = s.IsFolder ? s : s.Parent;
         SelectedFile_ExploreLeft.IsEnabled = f.LeftPresent;
         SelectedFile_ExploreRight.IsEnabled = f.RightPresent;
         SelectedFile_Save.IsEnabled = false;
         if (!s.LeftPresent && !s.RightPresent)
         {
             editDocument(null, true);
         }
         else if (s.RightPresent)
         {
             editDocument(this.RightPath + "\\" + s.Path + (s.IsFolder?"\\":""), false);
         }
         else
         {
             editDocument(this.LeftPath + "\\" + s.Path + (s.IsFolder ? "\\" : ""), true);
             if (!s.IsFolder)
                 SelectedFile_Save.IsEnabled = true;
         }
         DirTree.ScrollIntoView(s);
     }
     else
     {
         if (!lastSelectedFile.IsSelected)
             lastSelectedFile = null;
         //SelectedFileLabel.Text = "";
     }
 }
Пример #47
0
 private DirectoryTree AppendTree(DirectoryTree tree, bool isTextSearch)
 {
     var result = new DirectoryTree(tree);
     AppendTreeRecursion(result, isTextSearch);
     return result;
 }
Пример #48
0
 public DirectoryTree GetAllTextFiles(DirectoryTree tree)
 {
     return AppendTree(tree, true);
 }
Пример #49
0
 public void Init()
 {
     _fileSystem = new MockFileSystem(new Dictionary<string, MockFileData>
     {
         {@"c:\myfile.txt", new MockFileData("Testing is meh.")},
         {@"c:\picture.jpg", new MockFileData("")},
         {@"c:\anotherfile.txt", new MockFileData("Lorem Ipsum")},
         {@"c:\Dir\", new MockDirectoryData()},
         {@"c:\Dir\Subdir1\Subdir4\Subdir6\", new MockDirectoryData()},
         {@"c:\Dir\Subdir2\Subdir5\", new MockDirectoryData()},
         {@"c:\Dir\Subdir3\", new MockDirectoryData()},
         {@"c:\demo\jQuery.js", new MockFileData("some js")},
         {@"c:\demo\sample.txt", new MockFileData("text blub")}
     });
     _tree = new DirectoryTree(@"c:\");
     _tree.SubDirectories.Add(new DirectoryTree(@"c:\Dir"));
     _tree.SubDirectories[0].SubDirectories.Add(new DirectoryTree(@"c:\Dir\Subdir1"));
     _tree.SubDirectories[0].SubDirectories.Add(new DirectoryTree(@"c:\Dir\Subdir2"));
     _tree.SubDirectories[0].SubDirectories.Add(new DirectoryTree(@"c:\Dir\Subdir3"));
     _tree.SubDirectories[0].SubDirectories[0].SubDirectories.Add(new DirectoryTree(@"c:\Dir\Subdir1\Subdir4"));
     _tree.SubDirectories[0].SubDirectories[0].SubDirectories[0].SubDirectories.Add(
         new DirectoryTree(@"c:\Dir\Subdir1\Subdir4\Subdir6"));
     _tree.SubDirectories[0].SubDirectories[1].SubDirectories.Add(new DirectoryTree(@"c:\Dir\Subdir2\Subdir5"));
     _tree.SubDirectories.Add(new DirectoryTree(@"c:\demo"));
 }
Пример #50
0
 public void Setup() {
     window = new MainWindow();
     sut = window.DirectoryTree;
 }
Пример #51
0
 private TreeNode RefreshTreeView(TreeNodeCollection parentNodes, DirectoryTree<TREInfoFile> item, bool isRoot)
 {
     var node = new TreeNode();
     node.Text = isRoot ? "Resources" : item.DirectoryName;
     node.Tag = item;
     parentNodes.Add(node);
     foreach (var childDirectory in item.Directories)
         RefreshTreeView(node.Nodes, childDirectory, false);
     return node;
 }