Mercurial and Git clients can push and pull from this alias URL to interact with this repository. You can change to which repository an alias points by going to the Aliases link on the project page.
#include "stdafx.h"#include "TortoiseUtils.h"#include <assert.h>#include <io.h>#include "FCNTL.H"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";
HKEYkey=HKEY_LOCAL_MACHINE;TCHARlpszValue[MAX_PATH]="";LONGlpcbLonger=MAX_PATH*sizeof(TCHAR);if(RegQueryValue(key,regname,lpszValue,&lpcbLonger)!=ERROR_SUCCESS)return"";returnlpszValue;}std::stringGetTHgProgRoot(){LPCSTRregname="Software\\TortoiseHg";HKEYkey=HKEY_LOCAL_MACHINE;TCHARlpszValue[MAX_PATH]="";LONGlpcbLonger=MAX_PATH*sizeof(TCHAR);if(RegQueryValue(key,regname,lpszValue,&lpcbLonger)!=ERROR_SUCCESS)return"";returnlpszValue;}intGetRegistryConfig(conststd::string&name,std::string&res){constchar*constsubkey="Software\\TortoiseHg";HKEYhkey=0;LONGrv=RegOpenKeyExA(HKEY_CURRENT_USER,subkey,0,KEY_READ,&hkey);if(rv!=ERROR_SUCCESS||hkey==0)return0;BYTEData[MAX_PATH]="";DWORDcbData=MAX_PATH*sizeof(BYTE);rv=RegQueryValueExA(hkey,name.c_str(),0,0,Data,&cbData);intret=0;if(rv==ERROR_SUCCESS){res=reinterpret_cast<constchar*>(&Data);ret=1;}RegCloseKey(hkey);returnret;}// Start an external command// Note: if the command is a batch file and the [full] path to the// batch contains spaces, the path must be double-quoted.// (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)
{chartempDir[MAX_PATH+1];chartempFile[MAX_PATH+1];if(GetTempPath(MAX_PATH,tempDir)==0){TDEBUG_TRACE("GetTemporaryFile: Failed to find temporary path");}elseif(GetTempFileName(tempDir,prefix,0,tempFile)!=0){returntempFile;}else{TDEBUG_TRACE("GetTemporaryFile: Failed to get temporary file");}return"";}boolIsDirectory(conststd::string&filename){DWORDattributes=GetFileAttributesA(filename.c_str());if(attributes==INVALID_FILE_ATTRIBUTES)returnfalse; return (attributes & FILE_ATTRIBUTE_DIRECTORY) != 0;
}
+std::string DirName(const std::string& filename)
{
if (filename.empty())
returnfilename;std::string::size_typepos=filename.find_last_of("\\");std::stringmyfilename=filename.substr(0,pos);if(myfilename.size()>0&&myfilename[myfilename.size()-1]==':')myfilename.push_back('\\');returnmyfilename;}std::stringBaseName(conststd::string&filename){if(filename.empty())returnfilename;std::string::size_typepos=filename.find_last_of("\\"); return filename.substr(pos+1);
}
+HICON GetTortoiseIcon(const std::string& iconname)
{
std::string thgdir = GetTHgProgRoot();
if(thgdir.empty()){TDEBUG_TRACE("GetTortoiseIcon: THG root is empty");returnNULL;}std::stringiconpath=thgdir+"\\icons\\"+iconname;TDEBUG_TRACE(" GetTortoiseIcon: loading "+iconpath);HICONh=(HICON)LoadImageA(0,iconpath.c_str(),IMAGE_ICON,16,16,LR_LOADFROMFILE);if(!h){TDEBUG_TRACE(" GetTortoiseIcon: can't find "+iconpath);} return h;
}
+std::string GetHgRepoRoot(const std::string& path)
{
std::string p = IsDirectory(path)? path : DirName(path);
while(!IsDirectory(p+"\\.hg")){std::stringoldp=p;p=DirName(p);if(p==oldp){p.clear();break;}} return p;
}
+bool IsHgRepo(const std::string& path)
{
return !GetHgRepoRoot(path).empty();
}// open a file for reading, allowing renames and deletes by other// processes while we have it openFILE*fopenReadRenameAllowed(constchar*path){HANDLEfh=::CreateFileA(path,GENERIC_READ,FILE_SHARE_DELETE|FILE_SHARE_READ|FILE_SHARE_WRITE,0,OPEN_EXISTING,0,0);if(fh==INVALID_HANDLE_VALUE)return0;// get C runtime file descriptor from file handleintfd=::_open_osfhandle((intptr_t)fh,_O_RDONLY);if(fd==-1){TDEBUG_TRACE("fopenReadRenameAllowed: _open_osfhandle failed");::CloseHandle(fh);return0;}// get C runtime FILE from file descriptorFILE*f=::_fdopen(fd,"r");if(f==0){TDEBUG_TRACE("fopenReadRenameAllowed: _fdopen failed");::_close(fd);return0;}returnf;}
Attach a Trello Card
Add a tag
Your session has expired
You are no longer logged in. Please log in and try your request again.
Filter RSS Feed
This RSS feed URL allows you to see the contents of your current filter using any feed reader.
This link includes a special authentication token. If you share the URL with anyone else, they can see this RSS feed's activity. You can disable these tokens when needed.
Your current filter is unsaved; changing it won't affect this RSS feed.