예제 #1
0
 internal static string GetLongPathName(string path, FileMatcher.GetFileSystemEntries getFileSystemEntries)
 {
     string empty;
     if (path.IndexOf("~", StringComparison.Ordinal) == -1)
     {
         return path;
     }
  
     string[] strArrays = path.Split(FileMatcher.directorySeparatorCharacters);
     int num = 0;
     if (path.StartsWith(string.Concat(FileMatcher.directorySeparator, FileMatcher.directorySeparator), StringComparison.Ordinal))
     {
         empty = string.Concat(FileMatcher.directorySeparator, FileMatcher.directorySeparator);
         empty = string.Concat(empty, strArrays[2]);
         empty = string.Concat(empty, FileMatcher.directorySeparator);
         empty = string.Concat(empty, strArrays[3]);
         empty = string.Concat(empty, FileMatcher.directorySeparator);
         num = 4;
     }
     else if (path.Length <= 2 || path[1] != ':')
     {
         empty = string.Empty;
         num = 0;
     }
     else
     {
         empty = string.Concat(strArrays[0], FileMatcher.directorySeparator);
         num = 1;
     }
     string[] fileName = new string[(int)strArrays.Length - num];
     string str = empty;
     for (int i = num; i < (int)strArrays.Length; i++)
     {
         if (strArrays[i].Length == 0)
         {
             fileName[i - num] = string.Empty;
         }
         else if (strArrays[i].IndexOf("~", StringComparison.Ordinal) != -1)
         {
             string[] strArrays1 = getFileSystemEntries(FileSystemEntity.FilesAndDirectories, str, strArrays[i], null, false);
             if ((int)strArrays1.Length != 0)
             {
               
                 str = strArrays1[0];
                 fileName[i - num] = Path.GetFileName(str);
             }
             else
             {
                 for (int j = i; j < (int)strArrays.Length; j++)
                 {
                     fileName[j - num] = strArrays[j];
                 }
                 break;
             }
         }
         else
         {
             fileName[i - num] = strArrays[i];
             str = Path.Combine(str, strArrays[i]);
         }
     }
     return string.Concat(empty, string.Join(FileMatcher.directorySeparator, fileName));
 }
예제 #2
0
 internal static void SplitFileSpec(string filespec, out string fixedDirectoryPart, out string wildcardDirectoryPart, out string filenamePart, FileMatcher.GetFileSystemEntries getFileSystemEntries)
 {
     FileMatcher.PreprocessFileSpecForSplitting(filespec, out fixedDirectoryPart, out wildcardDirectoryPart, out filenamePart);
     if ("**" == filenamePart)
     {
         wildcardDirectoryPart = string.Concat(wildcardDirectoryPart, "**");
         wildcardDirectoryPart = string.Concat(wildcardDirectoryPart, FileMatcher.directorySeparator);
         filenamePart = "*.*";
     }
     fixedDirectoryPart = FileMatcher.GetLongPathName(fixedDirectoryPart, getFileSystemEntries);
 }
예제 #3
0
        private static void GetFilesRecursive(IList listOfFiles, string baseDirectory, string remainingWildcardDirectory, string filespec, int extensionLengthToEnforce, Regex regexFileMatch, bool needsRecursion, string projectDirectory, bool stripProjectDirectory, FileMatcher.GetFileSystemEntries getFileSystemEntries)
        {
            bool flag;
            bool flag1;
            flag = (filespec == null ? true : regexFileMatch == null);

            flag1 = (filespec != null ? true : regexFileMatch != null);

            bool flag2 = false;
            if (remainingWildcardDirectory.Length == 0)
            {
                flag2 = true;
            }
            else if (remainingWildcardDirectory.IndexOf("**", StringComparison.Ordinal) == 0)
            {
                flag2 = true;
            }
            if (flag2)
            {
                string[] strArrays = getFileSystemEntries(0, baseDirectory, filespec, projectDirectory, stripProjectDirectory);
                for (int i = 0; i < (int)strArrays.Length; i++)
                {
                    string str = strArrays[i];
                    if ((filespec != null || regexFileMatch.IsMatch(str)) && (filespec == null || extensionLengthToEnforce == 0 || Path.GetExtension(str).Length == extensionLengthToEnforce))
                    {
                        listOfFiles.Add(str);
                    }
                }
            }
            if (needsRecursion && remainingWildcardDirectory.Length > 0)
            {
                string str1 = null;
                if (remainingWildcardDirectory != "**")
                {
                    int num = remainingWildcardDirectory.IndexOfAny(FileMatcher.directorySeparatorCharacters);

                    str1 = remainingWildcardDirectory.Substring(0, num);
                    remainingWildcardDirectory = remainingWildcardDirectory.Substring(num + 1);
                    if (str1 == "**")
                    {
                        str1 = null;
                        remainingWildcardDirectory = "**";
                    }
                }
				string[] strArrays1 = getFileSystemEntries(FileSystemEntity.Directories, baseDirectory, str1, null, false);
                for (int j = 0; j < (int)strArrays1.Length; j++)
                {
                    string str2 = strArrays1[j];
                    FileMatcher.GetFilesRecursive(listOfFiles, str2, remainingWildcardDirectory, filespec, extensionLengthToEnforce, regexFileMatch, true, projectDirectory, stripProjectDirectory, getFileSystemEntries);
                }
            }
        }
예제 #4
0
 private static void GetFileSpecInfo(string filespec, out string fixedDirectoryPart, out string wildcardDirectoryPart, out string filenamePart, out string matchFileExpression, out bool needsRecursion, out bool isLegalFileSpec, FileMatcher.GetFileSystemEntries getFileSystemEntries)
 {
     isLegalFileSpec = true;
     needsRecursion = false;
     fixedDirectoryPart = string.Empty;
     wildcardDirectoryPart = string.Empty;
     filenamePart = string.Empty;
     matchFileExpression = null;
     if (-1 != filespec.IndexOfAny(FileMatcher.invalidPathChars))
     {
         isLegalFileSpec = false;
         return;
     }
     if (-1 != filespec.IndexOf("...", StringComparison.Ordinal))
     {
         isLegalFileSpec = false;
         return;
     }
     int num = filespec.LastIndexOf(":", StringComparison.Ordinal);
     if (-1 != num && 1 != num)
     {
         isLegalFileSpec = false;
         return;
     }
     FileMatcher.SplitFileSpec(filespec, out fixedDirectoryPart, out wildcardDirectoryPart, out filenamePart, getFileSystemEntries);
     matchFileExpression = FileMatcher.RegularExpressionFromFileSpec(fixedDirectoryPart, wildcardDirectoryPart, filenamePart, out isLegalFileSpec);
     if (!isLegalFileSpec)
     {
         return;
     }
     needsRecursion = wildcardDirectoryPart.Length != 0;
 }
예제 #5
0
 internal static void GetFileSpecInfo(string filespec, out Regex regexFileMatch, out bool needsRecursion, out bool isLegalFileSpec, FileMatcher.GetFileSystemEntries getFileSystemEntries)
 {
     string str;
     string str1;
     string str2;
     string str3;
     FileMatcher.GetFileSpecInfo(filespec, out str, out str1, out str2, out str3, out needsRecursion, out isLegalFileSpec, getFileSystemEntries);
     if (!isLegalFileSpec)
     {
         regexFileMatch = null;
         return;
     }
     regexFileMatch = new Regex(str3, RegexOptions.IgnoreCase);
 }
예제 #6
0
        internal static string[] GetFiles(string projectDirectoryUnescaped, string filespecUnescaped, FileMatcher.GetFileSystemEntries getFileSystemEntries, DirectoryExists directoryExists)
        {
            string str;
            string str1;
            string str2;
            string str3;
            bool flag;
            bool flag1;
            string[] strArrays;
            bool flag2;
            string extension;
            bool flag3;
            string str4;
            int num;
            Regex regex;
            if (!FileMatcher.HasWildcards(filespecUnescaped))
            {
                string[] strArrays1 = new string[] { filespecUnescaped };
                return strArrays1;
            }
            ArrayList arrayLists = new ArrayList();
            IList lists = arrayLists;
            FileMatcher.GetFileSpecInfo(filespecUnescaped, out str, out str1, out str2, out str3, out flag, out flag1, getFileSystemEntries);
            if (!flag1)
            {
                string[] strArrays2 = new string[] { filespecUnescaped };
                return strArrays2;
            }
            bool flag4 = false;
            if (projectDirectoryUnescaped != null)
            {
                if (str == null)
                {
                    str = projectDirectoryUnescaped;
                    flag4 = true;
                }
                else
                {
                    string str5 = str;
                    try
                    {
                        str = Path.Combine(projectDirectoryUnescaped, str);
                    }
                    catch (ArgumentException argumentException)
                    {
                        strArrays = new string[0];
                        return strArrays;
                    }
                    flag4 = !string.Equals(str, str5, StringComparison.OrdinalIgnoreCase);
                }
            }
            if (str.Length > 0 && !directoryExists(str))
            {
                return new string[0];
            }
            flag2 = (str1.Length <= 0 ? false : str1 != string.Concat("**", FileMatcher.directorySeparator));
            bool flag5 = flag2;
            if (flag5)
            {
                extension = null;
            }
            else
            {
                extension = Path.GetExtension(str2);
            }
            string str6 = extension;
            if (str6 == null || str6.IndexOf('*') != -1)
            {
                flag3 = false;
            }
            else if (str6.EndsWith("?", StringComparison.Ordinal))
            {
                flag3 = true;
            }
            else
            {
                flag3 = (str6.Length != 4 ? false : str2.IndexOf('*') != -1);
            }
            bool flag6 = flag3;
            try
            {
                IList lists1 = lists;
                string str7 = str;
                string str8 = str1;
                if (flag5)
                {
                    str4 = null;
                }
                else
                {
                    str4 = str2;
                }
                num = (flag6 ? str6.Length : 0);
                if (flag5)
                {
                    regex = new Regex(str3, RegexOptions.IgnoreCase);
                }
                else
                {
                    regex = null;
                }
                FileMatcher.GetFilesRecursive(lists1, str7, str8, str4, num, regex, flag, projectDirectoryUnescaped, flag4, getFileSystemEntries);
                return (string[])arrayLists.ToArray(typeof(string));
            }
            catch (Exception exception)
            {

                string[] strArrays3 = new string[] { filespecUnescaped };
                strArrays = strArrays3;
            }
            return strArrays;
        }
예제 #7
0
        private static string[] GetAccessibleFileSystemEntries(FileMatcher.FileSystemEntity entityType, string path, string pattern, string projectDirectory, bool stripProjectDirectory)
        {
            string[] accessibleFiles = null;
            switch (entityType)
            {
                case FileMatcher.FileSystemEntity.Files:
                {
                    accessibleFiles = FileMatcher.GetAccessibleFiles(path, pattern, projectDirectory, stripProjectDirectory);
                    break;
                }
                case FileMatcher.FileSystemEntity.Directories:
                {
                    accessibleFiles = FileMatcher.GetAccessibleDirectories(path, pattern);
                    break;
                }
                case FileMatcher.FileSystemEntity.FilesAndDirectories:
                {
                    accessibleFiles = FileMatcher.GetAccessibleFilesAndDirectories(path, pattern);
                    break;
                }
                default:
                {

                    break;
                }
            }
            return accessibleFiles;
        }