Example #1
0
 public static string ExpandVariables(string str, SpecializedDevice optionalDevice, string packageName = null)
 {
     if (optionalDevice == null)
     {
         return(ExpandCommonVariables(str));
     }
     else
     {
         return(optionalDevice.ExpandVariables(str, packageName));
     }
 }
Example #2
0
        public IEnumerable <FileReference> LocateAllFiles(SpecializedDevice device, string rootDir)
        {
            var expandedPath = SpecializedDevice.ExpandVariables(SourcePath, device).Replace('\\', '/');

            foreach (var mask in Masks)
            {
                var expandedMask = SpecializedDevice.ExpandVariables(mask, device);
                if (mask.Contains("|") || expandedPath.Contains("|"))
                {
                    continue;
                }

                string[] foundFileNames;

                try
                {
                    if (mask.Contains("*"))
                    {
                        foundFileNames = Directory.GetFiles(Path.Combine(rootDir, expandedPath), mask).Select(f => Path.GetFileName(f)).ToArray();
                    }
                    else
                    {
                        foundFileNames = new string[] { mask }
                    };
                }
                catch
                {
                    foundFileNames = new string[0];
                }

                foreach (var fn in foundFileNames)
                {
                    string fullPath;
                    try
                    {
                        fullPath = Path.Combine(rootDir, expandedPath + "/" + fn);
                        if (!File.Exists(fullPath))
                        {
                            continue;
                        }
                    }
                    catch
                    {
                        continue;
                    }

                    yield return(new FileReference($"{expandedPath}/{fn}", Type));
                }
            }
        }