Beispiel #1
0
        public RootDirectory AddDirectory(string path)
        {
            RootDirectory result = new RootDirectory();

            RootDirectories.AddValue(result, path);
            return(result);
        }
Beispiel #2
0
        /// <summary>
        /// Call this method to force PathManager to create folders that it
        /// is referring to. This method call throws exception if any creation
        /// fails.
        /// </summary>
        /// <param name="exceptions">The output list of exception, if any of
        /// the target directories cannot be created during this call.</param>
        internal void EnsureDirectoryExistence(List <Exception> exceptions)
        {
            if (!RootDirectories.Any())
            {
                throw new InvalidOperationException(
                          "At least one custom package directory must be specified");
            }

            if (exceptions == null)
            {
                throw new ArgumentNullException("exceptions");
            }

            exceptions.Clear();

            // User specific data folders.
            exceptions.Add(PathHelper.CreateFolderIfNotExist(userDataDir));
            exceptions.Add(PathHelper.CreateFolderIfNotExist(DefaultUserDefinitions));
            exceptions.Add(PathHelper.CreateFolderIfNotExist(logDirectory));
            exceptions.Add(PathHelper.CreateFolderIfNotExist(DefaultPackagesDirectory));
            exceptions.Add(PathHelper.CreateFolderIfNotExist(backupDirectory));

            // Common data folders for all users.
            exceptions.Add(PathHelper.CreateFolderIfNotExist(commonDataDir));
            exceptions.Add(PathHelper.CreateFolderIfNotExist(commonDefinitions));

            exceptions.RemoveAll(x => x == null); // Remove all null entries.
        }
Beispiel #3
0
        internal void method7()
        {
            if (File.Exists("ignoreCode.txt"))
            {
                string str;

                using (StreamReader streamReader = new StreamReader("ignoreCode.txt"))
                {
                    str = streamReader.ReadToEnd();
                }

                List <CodeFile> list = method8(str);

                foreach (CodeFile current in list)
                {
                    foreach (CodeFile file in Files)
                    {
                        AllSequences allSequences = Analysis.smethod1(current, file, current.Hashes.Length - 1);
                        method9(file, allSequences);
                    }
                }

                method2(RootDirectories.First <CodeDir>());
                method3();
            }
        }
Beispiel #4
0
        public Item CreateFile(string path, ItemType type)
        {
            var dirs     = path.Split('/', '\\');
            var fname    = dirs.Last();                              //File name
            var fullName = Project.CurrentProject._Directory + path; //Complete file path

            Array.Resize(ref dirs, dirs.Length - 1);                 //Remove filename
            var fullDirs = new string[dirs.Length];

            fullDirs[0] = Project.CurrentProject._Directory + dirs[0];
            for (int x = 1; x < dirs.Length; x++)
            {
                fullDirs[x] = fullDirs[x - 1] + "/" + dirs[x];
            }

            int  i = 0;
            Item d = (from it in RootDirectories where it.Name == dirs[i] select it).FirstOrDefault();

            if (d == null)
            {
                //New Root Directory
                Project.Directory dir = new Project.Directory(dirs[i], fullDirs[i]);
                Project.CurrentProject.ProjectFiles.SubDirectories.Add(dir);
                RootDirectories.Add(d = new Item(null, this, ItemTypes.Directory, dirs[i], fullDirs[i], Item.ItemState.NORMAL, dir));
            }
            i++;

            Directory.CreateDirectory(fullDirs.Last());
            File.Create(fullName)?.Close();

            //Go through all existing directories
            for (; i < dirs.Length; i++)
            {
                d.MakeStateNormal();
                Item d2 = (from it in d.DirectoryChildren where it.Name == dirs[i] select it).FirstOrDefault();
                if (d2 != null)
                {
                    d = d2;
                }
                else
                {
                    return(CreateItems(d, type, fname, fullName, dirs, fullDirs, i));
                }
            }
            d.MakeStateNormal();
            //Create file
            var f = new Project.File(fname);

            (d.FileObject as Project.Directory).Files.Add(f);
            var result = new FileBrowser.Item(d, this, type, fname, fullName, Item.ItemState.NORMAL, f);

            d.AddChild(result);
            return(result);
        }
Beispiel #5
0
        private IReadOnlyList <AbsolutePath> GetConvertedRootDirectories(PathTable pathTable)
        {
            if (m_convertedRootDirectories == null)
            {
                lock (m_lazyBxlWriter)
                {
                    if (m_convertedRootDirectories == null)
                    {
                        m_convertedRootDirectories = RootDirectories.Select(dir => AbsolutePath.Create(pathTable, dir)).ToList();
                    }
                }
            }

            return(m_convertedRootDirectories);
        }
        private void UpdateDirectoriesTree(string path)
        {
            if (Path.GetPathRoot(path) != path)
            {
                path = path.TrimEnd('\\');
            }
            Debug.WriteLine(path);
            if (!Directory.Exists(path))
            {
                _snackbarMessageQueue.Enqueue("Wrong Path!", "OK", () => Trace.WriteLine("Actioned"));
                return;
            }
            ConfigsPath = path;
            var selectedDir = new TreeViewDirectory(path, path)
            {
                Directories = Directory.GetDirectories(path).Select(p => new TreeViewDirectory(p)).ToList(),
                Files       = Directory.GetFiles(path).Select(p => new TreeViewFile(p)).ToList(),
                IsExpanded  = true,
                BackToPreviousMenuItemEnabled = true
            };

            //EVENTS
            selectedDir.OpenDirectoryEvent  += OpenDirectory;
            selectedDir.BackToPreviousEvent += BackToPrevious;
            selectedDir.ShowInExplorerEvent += ShowInExplorer;
            foreach (var dir in selectedDir.Directories)
            {
                dir.OpenDirectoryEvent  += OpenDirectory;
                dir.ShowInExplorerEvent += ShowInExplorer;
            }
            foreach (var file in selectedDir.Files)
            {
                file.ShowInExplorerEvent += ShowInExplorer;
            }

            RootDirectories.Clear();
            RootDirectories.Add(selectedDir);

            IsDirectoryInitialized = true;
        }
Beispiel #7
0
        private void method10()
        {
            try
            {
                DirectoryInfo directoryInfo           = new DirectoryInfo(Path);
                int           minSimilarityLineLength = Options.MinSimilarityLineLength;
                FileInfo[]    files          = directoryInfo.GetFiles(Options.FileSearchPattern, SearchOption.AllDirectories);
                int           num            = 0;
                List <Regex>  excludeRegexes = Options.GetExcludeRegexes();
                FileInfo[]    array          = files;
                int           i = 0;
IL_98:

                while (i < array.Length)
                {
                    FileInfo fileInfo = array[i];
                    bool     flag     = false;

                    for (int j = 0; j < excludeRegexes.Count; j++)
                    {
                        if (excludeRegexes[j].IsMatch(fileInfo.FullName))
                        {
                            flag = true;
                            //IL_87:
                            if (!flag)
                            {
                                num++;
                            }
                            i++;
                            goto IL_98;
                        }
                    }
                    //goto IL_87;
                }

                if (num == 0)
                {
                    AlertAction("No " + Options.FileSearchPattern + " Files Found");
                    Done();
                }
                else
                {
                    UpdateProgressAction(0, num, "Loading Files...");
                    CodeDir codeDir = method4(directoryInfo, Options.MinSimilarityLineLength, "");
                    RootDirectories.Add(codeDir);
                    ObservableCollection <CodeFile> codeFiles = Files;
                    UpdateProgressAction(0, codeFiles.Count * codeFiles.Count / 2, "Comparing Files...");
                    int           num2          = 0;
                    StringBuilder stringBuilder = new StringBuilder();

                    for (int j = 0; j < codeFiles.Count; j++)
                    {
                        CodeFile codeFile = codeFiles[j];

                        for (int k = j; k < codeFiles.Count; k++)
                        {
                            num2++;

                            if (num2 % 500 == 0)
                            {
                                this.UpdateProgressValue(num2);
                            }

                            try
                            {
                                CodeFile     codeFile_    = codeFiles[k];
                                AllSequences allSequences = Analysis.smethod1(codeFile, codeFile_, minSimilarityLineLength);

                                foreach (Sequence sequence in allSequences.Sequences)
                                {
                                    Analysis.smethod4(codeFile, codeFile_, sequence);
                                }
                                goto IL_24D;
                            }
                            catch (Exception ex)
                            {
                                stringBuilder.AppendLine(codeFile.Name + " - " + codeFiles[k].Name);
                                goto IL_24D;
                            }
                            break;
                            IL_24D :;
                        }

                        codeFile.method1();
                        codeFile.Similarities.Sort(new Comparison <Similarity>(Analysis.CompareSimilarities));
                    }

                    method2(codeDir);
                    method3();
                    method7();

                    if (stringBuilder.Length > 0)
                    {
                        this.AlertAction("Atomiq experienced an error with the following file combinations: " + stringBuilder.ToString());
                    }

                    bool0 = true;
                    Done();
                }
            }
            catch (Exception ex)
            {
                if (!(ex is ThreadAbortException))
                {
                    CaughtException = ex;
                }

                Done();
            }
        }