示例#1
0
        //Fonction qui crée les par2
        public static bool Create(DirectoryInfo workingDir, FileInfo filePath, string outputFilePar)
        {
            try
            {
                if (filePath.Exists == false)
                {
                    return(false);
                }
                if (filePath.Length < MIN_SIZE) //pas de fichier de parite pour les petits fichiers
                {
                    return(true);
                }
                int    exitCode  = -1;
                int    blocksize = Utilities.ARTICLE_SIZE;
                string argThread = (Threads > 0 ? "-t" + Threads.ToString() : "");
                string args      = string.Format(@"create -s{0} -r{1} {4} ""{3}"" ""{2}""", blocksize, Settings.Settings.Current.ParRedundancy, filePath.FullName, outputFilePar, argThread);

                if (ProcessWrapper.Run(workingDir.FullName, ExePar2, args, TIMEOUT_MS, out exitCode) == true)
                {
                    if (exitCode == 0)
                    {
                        return(true);
                    }
                }
            }
            catch (Exception ex)
            {
                Logger.Error(LOGNAME, ex.Message, ex);
            }
            return(false);
        }
示例#2
0
        public async Task Run(RunSynthesisPatcher settings, CancellationToken cancel)
        {
            if (cancel.IsCancellationRequested)
            {
                return;
            }

            var internalSettings = RunSynthesisMutagenPatcher.Factory(settings);

            internalSettings.ExtraDataFolder = PathToExtraData;

            var args = Parser.Default.FormatCommandLine(internalSettings);

            try
            {
                using ProcessWrapper process = ProcessWrapper.Create(
                          new ProcessStartInfo(PathToExecutable, args)
                {
                    WorkingDirectory = Path.GetDirectoryName(PathToExecutable) !
                },
                          cancel);
                using var outputSub = process.Output.Subscribe(_output);
                using var errSub    = process.Error.Subscribe(_error);
                var result = await process.Run();

                if (result != 0)
                {
                    throw new CliUnsuccessfulRunException(
                              result,
                              $"Process exited in failure: {process.StartInfo.FileName} {internalSettings}");
                }
            }
示例#3
0
 //Fonction qui repare une archive
 public static bool Repair(DirectoryInfo workingDir)
 {
     try
     {
         int      exitCode = -1;
         FileInfo par2File = workingDir.GetFiles("*.par2").FirstOrDefault();
         if (par2File == null)
         {
             return(false);
         }
         string argThread = (Threads > 0 ? "-t" + Threads.ToString() : "");
         string args      = string.Format(@"repair {1} ""{0}""", par2File.FullName, argThread);
         if (ProcessWrapper.Run(workingDir.FullName, ExePar2, args, TIMEOUT_MS, out exitCode) == true)
         {
             if (exitCode == 0)
             {
                 return(true);
             }
         }
     }
     catch (Exception ex)
     {
         Logger.Error(LOGNAME, ex.Message, ex);
     }
     return(false);
 }