Esempio n. 1
0
        private static StringCollection GetCompilersOnPath()
        {
            PathScanner scanner = new PathScanner();

            scanner.Add("cl.exe");
            return(scanner.Scan("PATH"));
        }
Esempio n. 2
0
        public Sender(SyncOptions syncOptions, ILogger logger)
        {
            _logger                  = logger;
            _pathScanner             = new PathScanner(this);
            _sentReporter            = new SentReporter(_logger);
            _srcPath                 = Path.GetFullPath(syncOptions.SourcePath);
            _cancellationTokenSource = new CancellationTokenSource();

            if (!Directory.Exists(_srcPath))
            {
                throw new SyncException($"Invalid source path: {_srcPath}");
            }

            _excludeList = new FileMaskList();
            _excludeList.SetList(syncOptions.ExcludeList);

            _changes      = new Dictionary <string, FsSenderChange>();
            _needToScan   = true;
            _agentStarter = AgentStarter.Create(syncOptions, _logger);
            _logger.Log($"Sync {syncOptions}");
            _applyRequest = new ApplyRequest(_logger)
            {
                BasePath = _srcPath,
            };
            UpdateHasWork();
        }
Esempio n. 3
0
        /// <summary>
        /// Routine which checks if the resource compiler is present.
        /// </summary>
        /// <returns>
        /// <see langword="true" /> if the resource compiler is present;
        /// otherwise, <see langword="false" />.
        /// </returns>
        private static bool CheckResourceCompilerPresent()
        {
            PathScanner scanner = new PathScanner();

            scanner.Add("rc.exe");
            return(scanner.Scan("PATH").Count > 0);
        }
        public void SetUp()
        {
            _siteScanPath = "c:\\some\\directory";
            _discoverer   = new Mock <IDiscoverAssembliesThatHaveInstallers>();
            _loader       = new Mock <ILoadAnAssembly>();

            _pathScanner = new PathScanner(_siteScanPath, _discoverer.Object, _loader.Object);
        }
Esempio n. 5
0
 /// <summary>
 /// Routine which checks if the header files are present.
 /// </summary>
 /// <returns>
 /// <see langword="true" /> if the header files are present; otherwise,
 /// <see langword="false" />.
 /// </returns>
 private static bool CheckHeaderFilesPresent()
 {
     foreach (string headerFile in ExpectedHeaderFiles)
     {
         PathScanner scanner = new PathScanner();
         scanner.Add(headerFile);
         if (scanner.Scan("INCLUDE").Count == 0)
         {
             return(false);
         }
     }
     return(true);
 }
Esempio n. 6
0
 /// <summary>
 /// Routine which checks if the libs are present.
 /// </summary>
 /// <returns>
 /// <see langword="true" /> if the libs are present; otherwise,
 /// <see langword="false" />.
 /// </returns>
 private static bool CheckLibsPresent()
 {
     foreach (string lib in ExpectedLibs)
     {
         PathScanner scanner = new PathScanner();
         scanner.Add(lib);
         if (scanner.Scan("LIB").Count == 0)
         {
             return(false);
         }
     }
     return(true);
 }
Esempio n. 7
0
        private void MainForm_Load(object sender, EventArgs e)
        {
            while (true)
            {
                var rads = PathScanner.GetRADS();
                if (rads == null)
                {
                    var result = MessageBox.Show("Failed to locate League of Legends directory\r\nIncorrect path?", "Patcher", MessageBoxButtons.RetryCancel, MessageBoxIcon.Error);
                    if (result == DialogResult.Retry)
                    {
                        continue;
                    }
                    else
                    {
                        Environment.Exit(0);
                        return;
                    }
                }
                else
                {
                    var exe = PathScanner.GetEXE(rads);
                    if (exe == null)
                    {
                        var result = MessageBox.Show("Failed to locate League of Legends.exe file\r\nIncorrect path?", "Patcher", MessageBoxButtons.RetryCancel, MessageBoxIcon.Error);
                        if (result == DialogResult.Retry)
                        {
                            continue;
                        }
                        else
                        {
                            Environment.Exit(0);
                            return;
                        }
                    }
                    else
                    {
                        this.exePath = exe;
                        break;
                    }
                }
            }

            if (File.Exists(this.exePath + ".bak"))
            {
                this.backupBtn.Visible = true;
            }
            else
            {
                this.backupBtn.Visible = false;
            }
        }
Esempio n. 8
0
        static void Main(string[] args)
        {
            var unpackedDirectory  = args.Length > 0 ? args[0] : Directory.GetCurrentDirectory();
            var pathScanner        = new PathScanner(unpackedDirectory);
            var deploymentManifest = pathScanner.FindFirstAvailableInstaller();

            if (deploymentManifest is NoInstallationFound)
            {
                Environment.Exit((int)ExitCodes.NoInstallationPerformed);
            }

            using (var serverManager = new ServerManagerWrapper())
            {
                new SiteDeployer(serverManager, deploymentManifest.InstallationConfiguration).Deploy();
            }
        }
Esempio n. 9
0
        protected string MKSExecute(string command)
        {
            // locate Source Integrity client on PATH
            PathScanner pathScanner = new PathScanner();

            pathScanner.Add("si.exe");
            StringCollection files = pathScanner.Scan();

            if (files.Count == 0)
            {
                throw new BuildException("Could not find MKS Integrity Client on the system path.",
                                         Location);
            }

            // set up process
            Process proc = new Process();

            proc.StartInfo.UseShellExecute        = false;
            proc.StartInfo.CreateNoWindow         = true;
            proc.StartInfo.RedirectStandardOutput = true;
            proc.StartInfo.RedirectStandardError  = true;
            proc.StartInfo.FileName  = files[0];
            proc.StartInfo.Arguments = command;
            proc.Start();
            proc.WaitForExit();

            if (proc.ExitCode != 0)
            {
                throw new BuildException(proc.ExitCode.ToString(), Location,
                                         new Exception(proc.StandardError.ReadToEnd()));
            }
            else
            {
                return(proc.StandardOutput.ReadToEnd());
            }
        }
Esempio n. 10
0
        /// <summary>
        /// Determines whether any file that are includes in the specified
        /// source file has been updated after the obj was compiled.
        /// </summary>
        /// <param name="srcFileName">The source file to check.</param>
        /// <param name="objLastWriteTime">The last write time of the compiled obj.</param>
        /// <returns>
        /// The full path to the include file that was modified after the obj
        /// was compiled, or <see langword="null" /> if no include files were
        /// modified since the obj was compiled.
        /// </returns>
        /// <remarks>
        ///   <para>
        ///   To determine what includes are defined in a source file, conditional
        ///   directives are not honored.
        ///   </para>
        ///   <para>
        ///   If a given include cannot be resolved to an existing file, then
        ///   it will be considered stable.
        ///   </para>
        /// </remarks>
        private string FindUpdatedInclude(string srcFileName, DateTime objLastWriteTime) {
            // quick and dirty code to check whether includes have been modified
            // after the source was last modified

            // TODO: recursively check includes

            Log(Level.Debug, "Checking whether includes of \"{0}\" have been"
                + " updated.", srcFileName);

            // holds the line we're parsing
            string line;

            // locate include directives in source file
            using (StreamReader sr = new StreamReader(srcFileName, true)) {
                while ((line = sr.ReadLine()) != null) {
                    Match match = _includeRegex.Match(line);
                    if (match.Groups.Count != 2) {
                        continue;
                    }

                    string includeFile = match.Groups["includefile"].Value;

                    Log(Level.Debug, "Checking include \"{0}\"...", includeFile);

                    string resolvedInclude = _resolvedIncludes[includeFile] as string;
                    if (resolvedInclude == null) {
                        foreach (string includeDir in IncludeDirs.DirectoryNames) {
                            string foundIncludeFile = FileUtils.CombinePaths(includeDir, includeFile);
                            if (File.Exists(foundIncludeFile)) {
                                Log(Level.Debug, "Found include \"{0}\" in"
                                    + " includedirs.", includeFile);
                                resolvedInclude = foundIncludeFile;
                                break;
                            }
                        }

                        // if we could not locate include in include dirs and
                        // source dir, then try to locate include in INCLUDE 
                        // env var
                        if (resolvedInclude == null) {
                            PathScanner pathScanner = new PathScanner();
                            pathScanner.Add(includeFile);
                            StringCollection includes = pathScanner.Scan("INCLUDE");
                            if (includes.Count > 0) {
                                Log(Level.Debug, "Found include \"{0}\" in"
                                    + " INCLUDE.", includeFile);
                                resolvedInclude = includes[0];
                            }
                        }

                        // if we could not locate include in include dirs
                        // and INCLUDE env var then check for include in base
                        // directory (which is used as working dir)
                        if (resolvedInclude == null) {
                            string foundIncludeFile = FileUtils.CombinePaths(
                                BaseDirectory.FullName, includeFile);
                            if (File.Exists(foundIncludeFile)) {
                                Log(Level.Debug, "Found include \"{0}\" in"
                                    + " working directory.", includeFile);
                                resolvedInclude = foundIncludeFile;
                            }
                        }

                        if (resolvedInclude != null) {
                            _resolvedIncludes.Add(includeFile, resolvedInclude);
                        }
                    }

                    if (resolvedInclude != null) {
                        if (File.GetLastWriteTime(resolvedInclude) > objLastWriteTime) {
                            return resolvedInclude;
                        }
                    } else {
                        // TODO: what do we do if the include cannot be located ?
                        //
                        // for now we'll consider the obj file to be up-to-date
                        Log(Level.Debug, "Include \"{0}\" could not be located.", 
                            includeFile);
                    }
                }
            }

            return null;
        }
        public void Ctor_PoorMansDi_DoesntThrow()
        {
            var scanner = new PathScanner(_siteScanPath);

            Assert.That(scanner, Is.Not.Null);
        }