Changeset fdc794881ed6…
Parent 8feb5e4dd752…
by
Changes to one file · Browse files at fdc794881ed6 Showing diff from parent 8feb5e4dd752 Diff from another changeset...
|
@@ -8,24 +8,26 @@
LPWSTR hf_mbtowc(LPWSTR lpw, LPCSTR lpa, int nChars)
{
- assert(lpa != NULL);
- assert(lpw != NULL);
-
- lpw[0] = '\0';
- MultiByteToWideChar(CP_ACP, 0, lpa, -1, lpw, nChars);
- return lpw;
+ assert(lpa != NULL);
+ assert(lpw != NULL);
+
+ lpw[0] = '\0';
+ MultiByteToWideChar(CP_ACP, 0, lpa, -1, lpw, nChars);
+ return lpw;
}
+
LPSTR hf_wctomb(LPSTR lpa, LPCWSTR lpw, int nChars)
{
- assert(lpw != NULL);
- assert(lpa != NULL);
-
- lpa[0] = '\0';
- WideCharToMultiByte(CP_ACP, 0, lpw, -1, lpa, nChars, NULL, NULL);
- return lpa;
+ assert(lpw != NULL);
+ assert(lpa != NULL);
+
+ lpa[0] = '\0';
+ WideCharToMultiByte(CP_ACP, 0, lpw, -1, lpa, nChars, NULL, NULL);
+ return lpa;
}
+
std::string GetTHgShellRoot()
{
LPCSTR regname = "Software\\TortoiseHgShell";
@@ -89,33 +91,36 @@// (see http://www.encocoservices.com/createprocess.html)
bool LaunchCommand(const std::string& command, const std::string& cwd)
{
- TDEBUG_TRACE("LaunchCommand: " << command);
- TDEBUG_TRACE("LaunchCommand: in " << cwd);
- PROCESS_INFORMATION processInfo;
- memset(&processInfo, 0, sizeof(processInfo));
+ TDEBUG_TRACE("LaunchCommand: " << command);
+ TDEBUG_TRACE("LaunchCommand: in " << cwd);
+ PROCESS_INFORMATION processInfo;
+ memset(&processInfo, 0, sizeof(processInfo));
- STARTUPINFOA startupInfo;
- memset(&startupInfo, 0, sizeof(startupInfo));
+ STARTUPINFOA startupInfo;
+ memset(&startupInfo, 0, sizeof(startupInfo));
- int res = CreateProcessA(NULL, // No module name, use command line
- const_cast<char*>(command.c_str()),
- NULL, // Process handle not inherited
- NULL, // Thread handle not inherited
- FALSE,
- CREATE_NO_WINDOW,
- NULL, // use parent's environment
- const_cast<char*>(cwd.c_str()),
- &startupInfo,
- &processInfo);
- if (res == 0)
- {
- TDEBUG_TRACE("LaunchCommand: failed to launch");
- return false;
- }
+ int res = CreateProcessA(
+ NULL, // No module name, use command line
+ const_cast<char*>(command.c_str()),
+ NULL, // Process handle not inherited
+ NULL, // Thread handle not inherited
+ FALSE,
+ CREATE_NO_WINDOW,
+ NULL, // use parent's environment
+ const_cast<char*>(cwd.c_str()),
+ &startupInfo,
+ &processInfo
+ );
- CloseHandle(processInfo.hProcess);
- CloseHandle(processInfo.hThread);
- return true;
+ if (res == 0)
+ {
+ TDEBUG_TRACE("LaunchCommand: failed to launch");
+ return false;
+ }
+
+ CloseHandle(processInfo.hProcess);
+ CloseHandle(processInfo.hThread);
+ return true;
}
std::string GetTemporaryFile(LPCTSTR prefix)
@@ -149,6 +154,7 @@ return (attributes & FILE_ATTRIBUTE_DIRECTORY) != 0;
}
+
std::string DirName(const std::string& filename)
{
if (filename.empty())
@@ -168,6 +174,7 @@ return filename.substr(pos+1);
}
+
HICON GetTortoiseIcon(const std::string& iconname)
{
std::string thgdir = GetTHgProgRoot();
@@ -189,6 +196,7 @@ return h;
}
+
std::string GetHgRepoRoot(const std::string& path)
{
std::string p = IsDirectory(path)? path : DirName(path);
@@ -205,6 +213,7 @@ return p;
}
+
bool IsHgRepo(const std::string& path)
{
return !GetHgRepoRoot(path).empty();
|
Loading...