Exemplo n.º 1
0
        public void TexoPath_RelativePathTwo_MultipleFilesAndDirectories()
        {
            Environment.CurrentDirectory = "d:/working";
            TexoPath path        = new TexoPath("texu.ui.test.dir/**b**");
            var      files       = path.GetFiles();
            var      directories = path.GetDirectories();

            Assert.NotEmpty(files);
            Assert.NotEmpty(directories);
        }
Exemplo n.º 2
0
        public void TexoPath_AbsoluteComplexFilePath_OneFile()
        {
            TexoPath path        = new TexoPath("C:/windows/sy**32/Win32_DeviceGuard.dll");
            var      files       = path.GetFiles();
            var      directories = path.GetDirectories();

            Assert.Single(files);
            Assert.Empty(directories);
            Assert.Equal("Win32_DeviceGuard.dll", new FileInfo(files.First()).Name);
        }
Exemplo n.º 3
0
        public void Remove(TexoPath toRemove)
        {
            var updatedPaths = paths.ToBuilder();

            foreach (string path in paths)
            {
                if (toRemove.IsMatch(path))
                {
                    updatedPaths.Remove(path);
                }
            }

            paths = updatedPaths.ToImmutable();
        }
Exemplo n.º 4
0
        private static void ProcessDirectories(TexoPath path, Action <string> projectAction, ISet <string> visitedFiles)
        {
            foreach (string directory in path.GetDirectories())
            {
                foreach (string solutionFile in TexoDirectory.GetFiles(directory, PathConstants.ANY_PATH_WILDCARD + FILE_EXTENSION_SOLUTION, SearchOption.AllDirectories))
                {
                    ProcessSolution(solutionFile, projectAction, visitedFiles);
                }

                foreach (string projectFile in TexoDirectory.GetFiles(directory, PathConstants.ANY_PATH_WILDCARD + FILE_EXTENSION_PROJECT, SearchOption.AllDirectories))
                {
                    ProcessProjectFile(projectFile, projectAction, visitedFiles);
                }
            }
        }
Exemplo n.º 5
0
        private static void ProcessTexoPaths(IEnumerable <string> paths, Action <string> projectAction)
        {
            ISet <string> visitedFiles = new HashSet <string>(new InsensitiveFullPathComparer());

            foreach (string stringPath in paths)
            {
                TexoPath path = new TexoPath(stringPath);
                ProcessDirectories(path, projectAction, visitedFiles);

                foreach (string filePath in path.GetFiles())
                {
                    ProcessFile(filePath, projectAction, visitedFiles);
                }
            }
        }
Exemplo n.º 6
0
        public IEnumerable <IItem> Help(string currentPath)
        {
            string filter = PathConstants.SEARCH_TERM_ALL;

            if (string.IsNullOrWhiteSpace(currentPath) ||
                currentPath == PathConstants.RELATIVE_CURRENT_DIRECTORY)
            {
                return(BuildFromDirectory(PathConstants.RELATIVE_CURRENT_DIRECTORY, filter));
            }

            if (!currentPath.IsValidPath())
            {
                return(new IItem[0]);
            }

            if (currentPath[currentPath.Length - 1].IsDirectorySeparator() &&
                currentPath.GetPathType() == PathTypeEnum.Directory)
            {
                return(BuildFromDirectory(currentPath, filter));
            }

            string parentDirectory = currentPath.GetParentDirectoryPath();

            if (string.IsNullOrEmpty(parentDirectory))
            {
                if (currentPath.IsDriveRelativePath())
                {
                    parentDirectory = $"{currentPath}.";
                }
                else
                {
                    parentDirectory = PathConstants.RELATIVE_CURRENT_DIRECTORY;
                    filter          = currentPath + PathConstants.WILDCARD_ANY_CHARACTER;
                }
            }
            else
            {
                TexoPath texoPath    = new TexoPath(currentPath);
                string   lastSegment = texoPath.Segments.Last().Value;

                if (lastSegment != PathConstants.RELATIVE_CURRENT_DIRECTORY)
                {
                    filter = lastSegment + PathConstants.WILDCARD_ANY_CHARACTER;
                }
            }

            return(BuildFromDirectory(parentDirectory, filter));
        }
Exemplo n.º 7
0
        public ICommandResult Execute(CommandContext context)
        {
            var result = ImmutableList <Item> .Empty.ToBuilder();

            var paths = context.GetParameterValues(ParameterKeys.PATH);

            foreach (string strPath in paths)
            {
                TexoPath path = new TexoPath(strPath);

                foreach (string directory in path.GetDirectories())
                {
                    result.AddRange(ProcessFolder(directory));
                }
            }

            if (paths.Count < 1)
            {
                result.AddRange(ProcessFolder("."));
            }

            return(new ItemsResult(result.ToImmutable()));
        }