Index: wizcfg/wizcfg.cpp =================================================================== RCS file: /scotty/wizard/wizcfg/wizcfg.cpp,v retrieving revision 1.1.2.12.2.95 diff -c -r1.1.2.12.2.95 wizcfg.cpp *** wizcfg/wizcfg.cpp 7 Aug 2024 11:16:15 -0000 1.1.2.12.2.95 --- wizcfg/wizcfg.cpp 8 Aug 2024 10:08:56 -0000 *************** *** 1707,1712 **** --- 1707,1715 ---- return; } + // + // wizcfg /4CopyVCPoj "d:\cvsbin\release builder\cvsnt\cvsnt.sln" .vc170 + // void CWizcfgApp::CopyVisualStudioSLN(CString & szPathToFile, CString & szNewSuffix) { CString szMessage; *************** *** 1760,1786 **** DWORD dwBufferTotal = GetFileSize (hFile, NULL); ! TCHAR ReadBuffer[8194]; BOOL bRead; DWORD sum = 0; DWORD dwBytesRead = 0; do { ! if(!(bRead = ReadFile (hFile, ReadBuffer, sizeof(ReadBuffer), &dwBytesRead, NULL))) ! break; sum += dwBytesRead; ! } while (dwBytesRead == sizeof(ReadBuffer)); ! CloseHandle (hFile); szPathToNewFile = szPathToFile; szPathToNewFile.Replace(szOldSLNSuffix,szNewSLNSuffix); - CString slnContents = ReadBuffer; - slnContents.Replace(szOldVCPROJSuffix,szNewVCPROJSuffix); - DWORD dwBytesWritten=0; hFile = CreateFileW (szPathToNewFile, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); if (hFile == INVALID_HANDLE_VALUE) { --- 1763,1978 ---- DWORD dwBufferTotal = GetFileSize (hFile, NULL); ! CHAR ReadBuffer[8194]; ! CString slnContents = _T(""); BOOL bRead; DWORD sum = 0; DWORD dwBytesRead = 0; do { ! ZeroMemory(ReadBuffer,sizeof(ReadBuffer)); ! dwBytesRead=0; ! bRead = ReadFile (hFile, ReadBuffer, sizeof(ReadBuffer), &dwBytesRead, NULL); ! CA2T strBuffer(ReadBuffer); ! slnContents +=strBuffer.m_psz; sum += dwBytesRead; ! if(!bRead) ! break; ! } while ((bRead==TRUE) && (dwBytesRead == sizeof(ReadBuffer))); CloseHandle (hFile); + if (sum<=0) + { + szMessage.FormatMessage(_T("CVS Suite Server Configurator Wizard - empty file \"%1!s!\"."), szPathToFile); + CT2A strMessage(szMessage); + CServerIo::log(CServerIo::logError,strMessage.m_psz); + AfxMessageBox(szMessage,MB_ICONSTOP); + return; + } + + /*if (sum!=slnContents.GetLength()) + { + szMessage.FormatMessage(_T("CVS Suite Server Configurator Wizard - sum: \"%2!d!\" != length \"%3!d!\" \"%1!s!\"."), szPathToFile, sum, slnContents.GetLength()); + CT2A strMessage(szMessage); + CServerIo::log(CServerIo::logError,strMessage.m_psz); + AfxMessageBox(szMessage,MB_ICONSTOP); + return; + }*/ + szPathToNewFile = szPathToFile; szPathToNewFile.Replace(szOldSLNSuffix,szNewSLNSuffix); DWORD dwBytesWritten=0; + CString defaultDirectory = szPathToNewFile; + TCHAR pathFull[MAX_PATH]; + TCHAR *fileExt; + DWORD pathres= GetFullPathName(szPathToNewFile,MAX_PATH,pathFull,&fileExt); + if (pathres==0) + { + szMessage.FormatMessage(_T("CVS Suite Server Configurator Wizard - cannot find directory of file location - unknown error.")); + CT2A strMessage(szMessage); + CServerIo::log(CServerIo::logError,strMessage.m_psz); + AfxMessageBox(szMessage,MB_ICONSTOP); + return; + } + if (pathres>MAX_PATH) + { + szMessage.FormatMessage(_T("CVS Suite Server Configurator Wizard - cannot find directory of file location - path too long.")); + CT2A strMessage(szMessage); + CServerIo::log(CServerIo::logError,strMessage.m_psz); + AfxMessageBox(szMessage,MB_ICONSTOP); + return; + } + CString filenameOnly = fileExt; + *fileExt=L'\0'; + CString szPathFull = pathFull; + BOOL setcwdres = SetCurrentDirectory(pathFull); + if (setcwdres == 0) + { + szMessage.FormatMessage(_T("CVS Suite Server Configurator Wizard - cannot set cwd \"%1!s!\"."), pathFull); + CT2A strMessage(szMessage); + CServerIo::log(CServerIo::logError,strMessage.m_psz); + AfxMessageBox(szMessage,MB_ICONSTOP); + return; + } + CString tmp2; + tmp2 = _T("cd /d ") + szPathFull + _T("\n"); + tmp2 += _T("cvs add -ko ") + filenameOnly + _T("\n"); + + + // now iterate around all the filenames... + CString szPathToOldProjFile; + CString szPathToNewProjFile; + int slnIndex = 0; + int slnProjectIndexStart = slnIndex; + int slnProjectIndexEnd = slnIndex; + while ((slnIndex = slnContents.Find(szOldVCPROJSuffix,slnIndex))!=-1) + { + slnProjectIndexStart = slnIndex; + slnProjectIndexEnd = slnIndex; + while (--slnProjectIndexStart>1) + { + if (slnContents[slnProjectIndexStart]==L'"') + break; + } + if (slnContents[slnProjectIndexStart]!=L'"') + { + szMessage.FormatMessage(_T("CVS Suite Server Configurator Wizard - error processing SLN file at \"%1!d!\" (reverse)."), slnIndex); + CT2A strMessage(szMessage); + CServerIo::log(CServerIo::logError,strMessage.m_psz); + AfxMessageBox(szMessage,MB_ICONSTOP); + return; + } + ++slnProjectIndexStart; + while (++slnProjectIndexEndOpenClipboard(); ! else ! if (AfxGetMainWnd()) ! AfxGetMainWnd()->OpenClipboard(); ! else ! bRes=OpenClipboard(NULL); ! if (bRes!=0) ! { ! EmptyClipboard(); ! SIZE_T strsiz = tmp2.GetLength(); ! HGLOBAL clippy = GlobalAlloc(GMEM_DDESHARE/*GMEM_MOVEABLE*/,sizeof(wchar_t)*(strsiz+100)); ! if (clippy!=NULL) ! { ! wchar_t * cbuffer = (wchar_t*)GlobalLock(clippy); ! ZeroMemory(cbuffer,sizeof(wchar_t)*(strsiz+99)); ! CopyMemory(cbuffer,(const wchar_t *)tmp2,sizeof(wchar_t)*(strsiz)); ! GlobalUnlock(clippy); ! if (SetClipboardData(CF_UNICODETEXT,clippy)==NULL) ! AfxMessageBox(_T("Unable to set 'cvs add' commands to the clipboard."),MB_ICONINFORMATION); ! } ! CloseClipboard(); ! } ! else ! AfxMessageBox(_T("Unable to open clipboard to put 'cvs add' commands to the clipboard."),MB_ICONINFORMATION); ! ! ! szMessage.FormatMessage(_T("CVS Suite Server Configurator Wizard - Copy Visual Studio Solution - Completed copy of \"%2!s!\" to \"%3!s!\" and %4!d! projects.\n\nClipboard has a script for adding new files to CVS.\n\nCVSNT %1!s!."), ! CVSNT_PRODUCTVERSION_TSTRING, szPathToFile, szPathToNewFile, slnReplaceCount); CT2A strMessage(szMessage); CServerIo::log(CServerIo::logNotice,strMessage.m_psz); AfxMessageBox(szMessage,MB_ICONINFORMATION); *************** *** 3265,3271 **** szMessage += cmdInfo.m_szUnknown; } szMessage += _T("\n\n"); ! szMessage += _T("wizcfg /AddRights user-name /VistaFirewall /wXPFirewall \n"); szMessage += _T(" /CVSNTRestart /SetRepository /Policy /Eclipse \n"); szMessage += _T(" /BUsers num-users /Days num-days /YesFull /Trial \n"); szMessage += _T(" /ISV isv-name /KLicenseTypeMulti \n"); --- 3486,3493 ---- szMessage += cmdInfo.m_szUnknown; } szMessage += _T("\n\n"); ! szMessage += _T("wizcfg \"Configure Windows Helper Utility\" \n"); ! szMessage += _T(" /AddRights user-name /VistaFirewall /wXPFirewall \n"); szMessage += _T(" /CVSNTRestart /SetRepository /Policy /Eclipse \n"); szMessage += _T(" /BUsers num-users /Days num-days /YesFull /Trial \n"); szMessage += _T(" /ISV isv-name /KLicenseTypeMulti \n"); *************** *** 3279,3285 **** szMessage += _T(" /Force /QuietNot /XtendLicense \n"); szMessage += _T(" /Unenforce /Noeclipse [name]"); szMessage += _T("\n\n"); ! szMessage += _T("wizcfg is part of CVS Suite ") CVSNT_PRODUCTVERSION_TYEAR _T(" (CVSNT ") CVSNT_PRODUCTVERSION_TSTRING _T(")\n"); CT2A strMessage(szMessage); CServerIo::log(CServerIo::logNotice,strMessage.m_psz); --- 3501,3509 ---- szMessage += _T(" /Force /QuietNot /XtendLicense \n"); szMessage += _T(" /Unenforce /Noeclipse [name]"); szMessage += _T("\n\n"); ! szMessage += _T("wizcfg always runs as an elevated 'administrator' process.\n\n"); ! szMessage += _T("wizcfg is part of CVS Suite ") CVSNT_PRODUCTVERSION_TYEAR _T(" \n"); ! szMessage += _T(" (CVSNT ") CVSNT_PRODUCTVERSION_TSTRING _T(")\n"); CT2A strMessage(szMessage); CServerIo::log(CServerIo::logNotice,strMessage.m_psz);