public void StartParsingMainDir(string[] args) { List <string> extra; try { // parse the command line extra = options.Parse(args); if (BaseName.Length < 1) { Console.WriteLine(NO_BASENAME_ERROR); } } catch (OptionException e) { // output some error message Console.WriteLine("Didn't receive any valid parameters. " + NO_BASENAME_ERROR); Console.WriteLine("Try `--help' for more information."); } MoveIntoProjectDir(BaseName); //Move into the directory var xmlFuncs = new XMLMgr(); if (!File.Exists("caches.xml")) { Console.WriteLine("caches.xml doesn't exist."); return; } string outID, outVersion; Dictionary <String, String> dirToParse = xmlFuncs.ReadFromCacheFile("caches.xml"); //Read our caches file, provided it is there var firstElement = dirToParse.FirstOrDefault(); outID = firstElement.Key; outVersion = firstElement.Value; if (outID.Length != 0 && Directory.Exists(outID)) { DirGenerateCaches(outID, Convert.ToInt32(outVersion)); } else { Console.WriteLine("An error occured while trying to read caches.xml or the directory doesn't exist!"); } }
public static void VerifyBootstrapper(string mainChSetFolderName) { if (exeName.Length < 1) { Utils.LogInfo("-exename argument is null, empty or was not provided, not running bootstrapper checks...\n"); //Let them know and continue... return; } FileInfo fStream = new FileInfo(exeName); string fStreamPath = Path.GetFullPath(exeName); string targetDir = Path.GetFullPath(Path.Combine(mainChSetFolderName, "bootstrapper")); string targetFilePath = Path.Combine(targetDir, exeName); if (!File.Exists(fStreamPath)) { Utils.FatalError($"File: \"{fStreamPath}\" not found so it won't be copied to \"{targetDir}\", exiting...\n"); } Directory.CreateDirectory(targetDir); Utils.FStreamReplace(fStream, targetFilePath); //Last but not least gen the new caches.xml file in the target directory containing the hash of the exe. var hashFuncs = new Hashing(); string SHA1Hash = hashFuncs.genFileHash(targetFilePath); //Generate our sha1 file hash which we'll use later on XMLMgr.WriteCacheXML(Path.Combine(targetDir, "caches.xml"), mainChSetFolderName, SHA1Hash); //Evaluate if it should be compressed or not evalShouldCompress(targetFilePath, targetDir); if (bootstrapOnly) { Utils.LogInfo("Bootstrapping done, the application will now exit (-bonly argument was passed)!\n", true); } }