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 "ShellExt.h"#include "TortoiseUtils.h"#include "errno.h"#include <assert.h>#include <io.h>#include "FCNTL.H"intWideCharToLocal(LPTSTRpLocal,LPWSTRpWide,DWORDdwChars){*pLocal=0;#ifdefUNICODElstrcpyn(pLocal,pWide,dwChars);#elseWideCharToMultiByte(CP_ACP,0,pWide,-1,pLocal,dwChars,NULL,NULL);#endifreturnlstrlen(pLocal);}intLocalToWideChar(LPWSTRpWide,LPTSTRpLocal,DWORDdwChars){*pWide=0;#ifdefUNICODElstrcpyn(pWide,pLocal,dwChars);#elseMultiByteToWideChar(CP_ACP,0,pLocal,-1,pWide,dwChars);#endifreturnlstrlenW(pWide);}LPWSTRhf_mbtowc(LPWSTRlpw,LPCSTRlpa,intnChars){assert(lpa!=NULL);assert(lpw!=NULL);lpw[0]='\0';MultiByteToWideChar(CP_ACP,0,lpa,-1,lpw,nChars);returnlpw;}LPSTRhf_wctomb(LPSTRlpa,LPCWSTRlpw,intnChars){assert(lpw!=NULL);assert(lpa!=NULL);lpa[0]='\0';WideCharToMultiByte(CP_ACP,0,lpw,-1,lpa,nChars,NULL,NULL);returnlpa;}std::stringGetTHgShellRoot(){LPCSTRregname="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);if(rv!=ERROR_SUCCESS)return0;res=reinterpret_cast<constchar*>(&Data);return1;}// 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)boolLaunchCommand(conststd::string&command,conststd::string&cwd){TDEBUG_TRACE("LaunchCommand: "<<command);TDEBUG_TRACE("LaunchCommand: in "<<cwd);PROCESS_INFORMATIONprocessInfo;memset(&processInfo,0,sizeof(processInfo));STARTUPINFOAstartupInfo;memset(&startupInfo,0,sizeof(startupInfo));intres=CreateProcessA(NULL,// No module name, use command lineconst_cast<char*>(command.c_str()),NULL,// Process handle not inheritedNULL,// Thread handle not inheritedFALSE,CREATE_NO_WINDOW,NULL,// use parent's environmentconst_cast<char*>(cwd.c_str()),&startupInfo,&processInfo);if(res==0){TDEBUG_TRACE("LaunchCommand: failed to launch");returnfalse;}CloseHandle(processInfo.hProcess);CloseHandle(processInfo.hThread);returntrue;}std::stringGetTemporaryFile(LPCTSTRprefix){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::stringDirName(conststd::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("\\");returnfilename.substr(pos+1);}HICONGetTortoiseIcon(conststd::string&iconname){std::stringthgdir=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);}returnh;}std::stringGetHgRepoRoot(conststd::string&path){std::stringp=IsDirectory(path)?path:DirName(path);while(!IsDirectory(p+"\\.hg")){std::stringoldp=p;p=DirName(p);if(p==oldp){p.clear();break;}}returnp;}boolIsHgRepo(conststd::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); return 0;
}
// get C runtime FILE from file descriptorFILE*f=::_fdopen(fd,"r"); if (f == 0)
{
TDEBUG_TRACE("fopenReadRenameAllowed: _fdopen failed");
+ ::_close(fd); return 0;
}
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.