Exemple #1
0
            public virtual string Gzip(IAbsoluteFilePath file, IAbsoluteFilePath dest = null,
                bool preserveFileNameAndModificationTime = false) {
                Contract.Requires<ArgumentNullException>(file != null);
                Contract.Requires<ArgumentException>(file.Exists);

                var defDest = (file + ".gz").ToAbsoluteFilePath();
                if (dest == null)
                    dest = defDest;

                var cmd = String.Format("-f --best --rsyncable --keep \"{0}\"", file);
                if (!preserveFileNameAndModificationTime)
                    cmd = "-n " + cmd;

                dest.RemoveReadonlyWhenExists();

                var startInfo =
                    new ProcessStartInfoBuilder(Common.Paths.ToolPath.GetChildFileWithName("gzip.exe"), cmd) {
                        WorkingDirectory = file.ParentDirectoryPath.ToString()
                    }.Build();
                var ret = ProcessManager.LaunchAndGrabTool(startInfo, "Gzip pack");

                if (Path.GetFullPath(dest.ToString()) != Path.GetFullPath(defDest.ToString()))
                    FileUtil.Ops.MoveWithRetry(defDest, dest);

                return ret.StandardOutput + ret.StandardError;
            }
 void CreateFiles(string outFile, bool overwrite = false, int bits = SshKeyPair.DefaultBits,
     string type = SshKeyPair.DefaultType) {
     if (!overwrite && File.Exists(outFile))
         throw new IOException("File exists " + outFile);
     var startInfo = new ProcessStartInfoBuilder(sshKeyGenBin,
         GetParameters(outFile, bits, type)) {
             WorkingDirectory = Common.Paths.AppPath.ToString()
         }.Build();
     _processManager.LaunchAndGrabTool(startInfo);
 }
Exemple #3
0
        public void RunExtractPboWithParameters(IAbsoluteFilePath input, IAbsoluteDirectoryPath output,
            params string[] parameters) {
            if (!input.Exists)
                throw new IOException("File doesn't exist: " + input);
            var startInfo =
                new ProcessStartInfoBuilder(_extractPboBin,
                    BuildParameters(input.ToString(), output.ToString(), parameters)) {
                        WorkingDirectory = Common.Paths.AppPath.ToString()
                    }.Build();

            ProcessExitResult(_processManager.LaunchAndGrabTool(startInfo));
        }
        public void Launch(IProcessManager processManager) {
            Contract.Requires<ArgumentNullException>(Path != null);
            Contract.Requires<ArgumentException>(!String.IsNullOrWhiteSpace(Path));
            //if (!UserSettings.Current.AppOptions.UseElevatedService) {
            var startInfo = new ProcessStartInfoBuilder(Path, Parameters) {
                WorkingDirectory = System.IO.Path.GetDirectoryName(Path),
                AsAdministrator = RunAsAdmin
            }.Build();

            MainLog.Logger.Info("Launching external app: " + startInfo.Format());
            processManager.StartAndForget(startInfo);
            //} else {
            //    _wcfClient.Value.Updater_StartAndForget(Path, Parameters, System.IO.Path.GetDirectoryName(Path), RunAsAdmin);
            //}
        }
Exemple #5
0
            public virtual string GzipStdOut(IAbsoluteFilePath inputFile, IAbsoluteFilePath outputFile = null,
                bool preserveFileNameAndModificationTime = false) {
                Contract.Requires<ArgumentException>(inputFile != null);
                Contract.Requires<ArgumentException>(inputFile.Exists);

                if (outputFile == null)
                    outputFile = (inputFile + ".gz").ToAbsoluteFilePath();

                var cmd = String.Format("-f --best --rsyncable --keep --stdout \"{0}\" > \"{1}\"",
                    inputFile, outputFile);
                if (!preserveFileNameAndModificationTime)
                    cmd = "-n " + cmd;

                outputFile.RemoveReadonlyWhenExists();
                var startInfo =
                    new ProcessStartInfoBuilder(Common.Paths.ToolPath.GetChildFileWithName("gzip.exe"), cmd) {
                        WorkingDirectory = Common.Paths.LocalDataPath.ToString()
                    }.Build();
                var ret = ProcessManager.LaunchAndGrabToolCmd(startInfo, "Gzip pack");
                return ret.StandardOutput + ret.StandardError;
            }
 public virtual ProcessExitResultWithOutput LaunchAndGrabToolCmd(ProcessStartInfo info,
     string tool) {
     var startInfo =
         new ProcessStartInfoBuilder(Common.Paths.CmdExe,
             String.Format("/C \"\"{0}\" {1}\"", info.FileName, info.Arguments)) {
                 WorkingDirectory = info.WorkingDirectory
             }.Build();
     return LaunchAndGrabTool(startInfo, tool);
 }
Exemple #7
0
 void RunMakePbo(string parameters) {
     var startInfo = new ProcessStartInfoBuilder(_makePboBin, parameters) {
         WorkingDirectory = Common.Paths.AppPath.ToString()
     }.Build();
     ProcessExitResult(_processManager.LaunchAndGrabTool(startInfo));
 }
Exemple #8
0
        public void SignFile(IAbsoluteFilePath file, IAbsoluteFilePath privateFile) {
            Contract.Requires<ArgumentNullException>(file != null);

            if (!file.Exists)
                throw new IOException("File doesn't exist: " + file);
            if (!privateFile.Exists)
                throw new IOException("File doesn't exist: " + privateFile);

            var startInfo =
                new ProcessStartInfoBuilder(_dsSignFileBin, BuildPathParameters(privateFile.ToString(), file.ToString())) {
                    WorkingDirectory = Common.Paths.StartPath.ToString()
                }.Build();
            ProcessExitResult(_processManager.LaunchAndGrabTool(startInfo));
        }
Exemple #9
0
        public void CreateKey(IAbsoluteFilePath outFile, bool overwrite = false) {
            Contract.Requires<ArgumentNullException>(outFile != null);

            var privateFile = outFile + ".biprivatekey";
            var publicFile = outFile + ".bikey";

            if (!overwrite) {
                if (File.Exists(privateFile))
                    throw new IOException("File exists: " + privateFile);
                if (File.Exists(publicFile))
                    throw new IOException("File exists: " + publicFile);
            }
            var startInfo = new ProcessStartInfoBuilder(_dsCreateKeyBin, BuildPathParameters(outFile.FileName)) {
                WorkingDirectory = outFile.ParentDirectoryPath.ToString()
            }.Build();

            ProcessExitResult(_processManager.LaunchAndGrabTool(startInfo));
        }