示例#1
0
        public static bool TryLoadFileList(Enlistment enlistment, string filesInput, List <string> fileListOutput, out string error)
        {
            fileListOutput.AddRange(
                filesInput.Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries)
                .Select(path => PrefetchHelper.ToAbsolutePath(enlistment, path, isFolder: false)));

            foreach (string file in fileListOutput)
            {
                if (file.IndexOf('*', 1) != -1)
                {
                    error = "Only prefix wildcards are supported. Invalid entry: " + file;
                    return(false);
                }

                if (file.EndsWith(GVFSConstants.GitPathSeparatorString) ||
                    file.EndsWith(pathSeparatorString))
                {
                    error = "Folders are not allowed in the file list. Invalid entry: " + file;
                    return(false);
                }
            }

            error = null;
            return(true);
        }
示例#2
0
        public static bool TryLoadFolderList(Enlistment enlistment, string foldersInput, string folderListFile, List <string> folderListOutput, out string error)
        {
            folderListOutput.AddRange(
                foldersInput.Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries)
                .Select(path => PrefetchHelper.ToAbsolutePath(enlistment, path, isFolder: true)));

            if (!string.IsNullOrWhiteSpace(folderListFile))
            {
                if (File.Exists(folderListFile))
                {
                    IEnumerable <string> allLines = File.ReadAllLines(folderListFile)
                                                    .Select(line => line.Trim())
                                                    .Where(line => !string.IsNullOrEmpty(line))
                                                    .Where(line => !line.StartsWith(GVFSConstants.GitCommentSign.ToString()))
                                                    .Select(path => PrefetchHelper.ToAbsolutePath(enlistment, path, isFolder: true));

                    folderListOutput.AddRange(allLines);
                }
                else
                {
                    error = string.Format("Could not find '{0}' for folder list.", folderListFile);
                    return(false);
                }
            }

            folderListOutput.RemoveAll(string.IsNullOrWhiteSpace);

            foreach (string folder in folderListOutput)
            {
                if (folder.Contains("*"))
                {
                    error = "Wildcards are not supported for folders. Invalid entry: " + folder;
                    return(false);
                }
            }

            error = null;
            return(true);
        }