Example #1
0
 protected bool GetFileSpecifications()
 {
     using (Operation engineOp = L.Begin("Scanning directory for file specification"))
     {
         if (Directory.Exists(BaseDirectory))
         {
             BaseDirectoryInfo = new DirectoryInfo(BaseDirectory);
             BaseDirectory     = BaseDirectoryInfo.FullName;
         }
         else
         {
             L.Error("The base directory {0} could not be found.", BaseDirectory);
             return(false);
         }
         CompilerArguments = PhpCommandLineParser.Default.Parse(FileSpec.ToArray(), BaseDirectory, RuntimeEnvironment.GetRuntimeDirectory(),
                                                                Environment.ExpandEnvironmentVariables(@"%windir%\Microsoft.NET\assembly\GAC_MSIL"));
         FileCount = CompilerArguments.SourceFiles.Count();
         if (FileCount == 0)
         {
             L.Error("No PHP source files match specification {files} in directory {dir}.", FileSpec, BaseDirectory);
             return(false);
         }
         else
         {
             Files          = CompilerArguments.SourceFiles.ToArray();
             FilesPathIndex = Files.Select((v, i) => new { v, i }).ToDictionary((f) => f.v.Path, (f) => f.i);
         }
         if (TargetFileSpec != null && TargetFileSpec.Count() > 0)
         {
             CommandLineArguments targetFilesArgs = PhpCommandLineParser.Default.Parse(TargetFileSpec.ToArray(), BaseDirectory, RuntimeEnvironment.GetRuntimeDirectory(),
                                                                                       Environment.ExpandEnvironmentVariables(@"%windir%\Microsoft.NET\assembly\GAC_MSIL"));
             TargetFilePaths = new HashSet <string>(targetFilesArgs.SourceFiles.Select(f => f.Path));
             if (TargetFilePaths.Count() == 0)
             {
                 L.Error("No PHP source files match target specification {files} in directory {dir}.", TargetFileSpec, Compiler.Arguments.BaseDirectory);
                 return(false);
             }
             else
             {
                 List <int> targetFileIndex = new List <int>(TargetFilePaths.Count);
                 for (int i = 0; i < FileCount; i++)
                 {
                     if (TargetFilePaths.Contains(Files[i].Path))
                     {
                         targetFileIndex.Add(i);
                     }
                 }
                 TargetFileIndex = targetFileIndex.ToArray();
             }
         }
         else
         {
             TargetFileIndex = Enumerable.Range(0, FileCount).ToArray();
         }
         engineOp.Complete();
         return(true);
     }
 }