public static GetShortPathName ( string path ) : string | ||
path | string | |
Результат | string |
/// <summary> /// Constructor creates a shell executable file that echoes the PASSWORD /// environment variable when called. When GIT_ASKPASS is present, Git /// obtains a password for its HTTPS operations by calling it. /// </summary> public ClassGitPasswd() { // WAR: Do a different kind of shell script dependent on the OS) if (ClassUtils.IsMono()) { // Mono: Use the Shell script pathPasswordBatchHelper = Path.Combine(App.AppHome, "passwd.sh"); File.WriteAllText(pathPasswordBatchHelper, "echo $PASSWORD" + Environment.NewLine); // Set the execute bit if (Exec.Run("chmod", "+x " + pathPasswordBatchHelper).Success() == false) { App.PrintLogMessage("ClassGitPasswd: Unable to chmod +x on " + pathPasswordBatchHelper, MessageType.Error); } } else { // Windows: Use the CMD BAT script // Note: Using "App.AppHome" directory to host the batch helper file // fails on XP where that directory has spaces in the name ("Documents and Settings") // which git cannot handle in this context. Similarly, git will fail with // any other path that contains a space. // This redirection is used to provide the password in an automated way. pathPasswordBatchHelper = Path.Combine(Path.GetTempPath(), "passwd.bat"); File.WriteAllText(pathPasswordBatchHelper, "@echo %PASSWORD%" + Environment.NewLine); pathPasswordBatchHelper = ClassUtils.GetShortPathName(pathPasswordBatchHelper); } ClassUtils.AddEnvar("GIT_ASKPASS", pathPasswordBatchHelper); App.PrintLogMessage("Created HTTP password helper file: " + pathPasswordBatchHelper, MessageType.General); }
/// <summary> /// Constructor class function, create batch file helper in the temp space /// </summary> public ClassSSH() { string pathHelpertLong = ClassUtils.WriteResourceToFile(Path.GetTempPath(), "git_ssh_helper.sh", Properties.Resources.git_ssh_helper); pathHelper = ClassUtils.GetShortPathName(pathHelpertLong); // Make the batch file executable: this trick will only work with Mono File.SetAttributes(pathHelper, (FileAttributes)((uint)File.GetAttributes(pathHelper) | 0x80000000)); App.PrintLogMessage("SSH helper path:" + pathHelper, MessageType.Error); ClassUtils.AddEnvar("GIT_SSH", pathHelper); }
/// <summary> /// Constructor class function, create executables in the temp space /// </summary> public ClassPutty() { string pathPageantLong = ClassUtils.WriteResourceToFile(Path.GetTempPath(), "pageant.exe", Properties.Resources.pageant); string pathPlinkLong = ClassUtils.WriteResourceToFile(Path.GetTempPath(), "plink.exe", Properties.Resources.plink); string pathPuttyGenLong = ClassUtils.WriteResourceToFile(Path.GetTempPath(), "puttygen.exe", Properties.Resources.puttygen); pathPageant = ClassUtils.GetShortPathName(pathPageantLong); pathPlink = ClassUtils.GetShortPathName(pathPlinkLong); pathPuttyGen = ClassUtils.GetShortPathName(pathPuttyGenLong); ClassUtils.AddEnvar("PLINK_PROTOCOL", "ssh"); ClassUtils.AddEnvar("GIT_SSH", pathPlink); // Run the daemon process, update keys RunPageantUpdateKeys(); }