diff options
author | Andreas Becker <atayoohoo@googlemail.com> | 2011-04-28 00:59:28 +0200 |
---|---|---|
committer | Katarina Machalkova <kmachalkova@suse.cz> | 2011-04-28 13:45:46 +0200 |
commit | 9ad4eeb4fa413b1a3e084d141c6eb01795f95b7f (patch) | |
tree | 031b7ad30c650665210cb5b63d59efe740fd57d1 /setup_native | |
parent | 8a9f54bc1283b7137a90506e29dba7962dd73f83 (diff) |
fixed cppcheck warnings
Diffstat (limited to 'setup_native')
-rw-r--r-- | setup_native/source/win32/customactions/shellextensions/copyextensiondata.cxx | 10 | ||||
-rw-r--r-- | setup_native/source/win32/customactions/shellextensions/registerextensions.cxx | 155 |
2 files changed, 6 insertions, 159 deletions
diff --git a/setup_native/source/win32/customactions/shellextensions/copyextensiondata.cxx b/setup_native/source/win32/customactions/shellextensions/copyextensiondata.cxx index d94b65459d8a..ffa1dfe0d50b 100644 --- a/setup_native/source/win32/customactions/shellextensions/copyextensiondata.cxx +++ b/setup_native/source/win32/customactions/shellextensions/copyextensiondata.cxx @@ -80,7 +80,6 @@ extern "C" UINT __stdcall copyExtensionData(MSIHANDLE handle) { std::_tstring sSourceDir = GetMsiProperty( handle, TEXT("SourceDir") ); std::_tstring sExtensionDir = sSourceDir + TEXT("extension\\"); std::_tstring sPattern = sExtensionDir + TEXT("*.oxt"); - // std::_tstring mystr; // Finding all oxt files in sExtensionDir @@ -91,7 +90,6 @@ extern "C" UINT __stdcall copyExtensionData(MSIHANDLE handle) { if ( hFindOxt != INVALID_HANDLE_VALUE ) { bool fNextFile = false; - bool fSuccess = true; bool bFailIfExist = true; std::_tstring sDestDir = GetMsiProperty( handle, TEXT("INSTALLLOCATION") ); @@ -101,9 +99,9 @@ extern "C" UINT __stdcall copyExtensionData(MSIHANDLE handle) { std::_tstring sShareDir = sDestDir + TEXT("share"); std::_tstring sExtDir = sShareDir + TEXT("\\extension"); std::_tstring sExtInstDir = sExtDir + TEXT("\\install"); - bool bDir = CreateDirectory(sShareDir.c_str(), NULL); - bDir = CreateDirectory(sExtDir.c_str(), NULL); - bDir = CreateDirectory(sExtInstDir.c_str(), NULL); + CreateDirectory(sShareDir.c_str(), NULL); + CreateDirectory(sExtDir.c_str(), NULL); + CreateDirectory(sExtInstDir.c_str(), NULL); do { @@ -112,7 +110,7 @@ extern "C" UINT __stdcall copyExtensionData(MSIHANDLE handle) { std::_tstring sSourceFile = sExtensionDir + sOxtFile; std::_tstring sDestFile = sShareInstallDir + sOxtFile; - fSuccess = CopyFile( sSourceFile.c_str(), sDestFile.c_str(), bFailIfExist ); + CopyFile( sSourceFile.c_str(), sDestFile.c_str(), bFailIfExist ); fNextFile = FindNextFile( hFindOxt, &aFindFileData ); diff --git a/setup_native/source/win32/customactions/shellextensions/registerextensions.cxx b/setup_native/source/win32/customactions/shellextensions/registerextensions.cxx index 6b32b33cc881..53066682e397 100644 --- a/setup_native/source/win32/customactions/shellextensions/registerextensions.cxx +++ b/setup_native/source/win32/customactions/shellextensions/registerextensions.cxx @@ -55,119 +55,6 @@ #include <tchar.h> #include <string> -/** creates a temporary folder with a unique name. - - The returned string is a file URL. -*/ -// static std::_tstring createTempFolder() -// { -// BOOL bExist = FALSE; -// TCHAR szTempName[MAX_PATH]; -// do -// { -// bExist = FALSE; -// // Get the temp path. -// TCHAR lpPathBuffer[MAX_PATH]; -// DWORD dwRetVal = GetTempPath(MAX_PATH, lpPathBuffer); -// if (dwRetVal > MAX_PATH || (dwRetVal == 0)) -// { -// //fprintf (stderr, "GetTempPath failed with error %d.\n", GetLastError()); -// return TEXT(""); -// } -// // Create a temporary file. -// UINT uRetVal = GetTempFileName(lpPathBuffer, // directory for tmp files -// "upg", // temp file name prefix -// 0, // create unique name -// szTempName); // buffer for name -// if (uRetVal == 0) -// { -// //fprintf (stderr, "GetTempFileName failed with error %d.\n", GetLastError()); -// return TEXT(""); -// } -// //Delete the file -// BOOL bDel = DeleteFile(szTempName); -// if (FALSE == bDel) -// { -// //fprintf(stderr, "Could not delete temp file. Error %d.\n", GetLastError()); -// return TEXT(""); -// } -// // Create the directory -// BOOL bDir = CreateDirectory(szTempName, NULL); -// if (FALSE == bDir) -// { -// DWORD error =GetLastError(); -// if (ERROR_ALREADY_EXISTS == error) -// { -// bExist = TRUE; -// } -// else -// { -// //fprintf(stderr, "CreateDirectory failed with error %d.\n", error); -// return TEXT(""); -// } -// } -// } while(bExist); - -// std::_tstring cur(szTempName); -// //make a file URL from the path -// std::_tstring ret(TEXT("file:///")); -// for (std::_tstring::iterator i = cur.begin(); i != cur.end(); i++) -// { -// if (*i == '\\') -// ret.append(TEXT("/")); -// else -// ret.push_back(*i); -// } -// // MessageBox(NULL, ret.c_str(), "createTempFolder", MB_OK); -// return ret.c_str(); -// } - -/** deletes the temporary folder. - The argument must be a file URL. -*/ -// static void deleteTempFolder(const std::_tstring& sTempFolder) -// { -// if (sTempFolder.size() == 0) -// return; -// //convert the file URL to a path -// const std::_tstring path(sTempFolder.substr(8)); -// std::_tstring path2; -// // MessageBox(NULL, path.c_str(), "del1", MB_OK); -// for (std::_tstring::const_iterator i = path.begin(); i != path.end(); i++) -// { -// if (*i == '/') -// path2.append(TEXT("\\")); -// else -// path2.push_back(*i); -// } - -// //We need a null terminated string with two nulls in the end -// //for the SHFILEOPSTRUCT -// const TCHAR * szTemp = path2.c_str(); -// size_t size = path2.size(); -// TCHAR * szTemp2 = new TCHAR[size + 2]; -// ZeroMemory(szTemp2, (size + 2) * sizeof(TCHAR)); -// memcpy(szTemp2, szTemp, size * sizeof(TCHAR)); - -// // MessageBox(NULL, szTemp2, "del3", MB_OK); -// SHFILEOPSTRUCT operation = -// { -// NULL, -// FO_DELETE, -// szTemp2, -// NULL, -// FOF_SILENT | FOF_NOCONFIRMATION | FOF_NOERRORUI | FOF_NOCONFIRMMKDIR, -// FALSE, -// NULL, -// NULL -// }; - -// SHFileOperation( &operation); -// delete [] szTemp2; -// } - - - static std::_tstring GetMsiProperty( MSIHANDLE handle, const std::_tstring& sProperty ) { std::_tstring result; @@ -189,8 +76,6 @@ static std::_tstring GetMsiProperty( MSIHANDLE handle, const std::_tstring& sPro /* creates a child process which is specified in lpCommand. out_exitCode is the exit code of the child process - - **/ static BOOL ExecuteCommand( LPCTSTR lpCommand, DWORD * out_exitCode) { @@ -251,7 +136,6 @@ static BOOL RemoveCompleteDirectory( std::_tstring sPath ) std::_tstring sParentDir = TEXT(".."); mystr = "Current short file: " + sFileName; - // MessageBox(NULL, mystr.c_str(), "Current Content", MB_OK); if (( strcmp(sFileName.c_str(),sCurrentDir.c_str()) != 0 ) && ( strcmp(sFileName.c_str(),sParentDir.c_str()) != 0 )) @@ -264,12 +148,10 @@ static BOOL RemoveCompleteDirectory( std::_tstring sPath ) if ( fSuccess ) { mystr = "Successfully removed content of dir " + sCompleteFileName; - // MessageBox(NULL, mystr.c_str(), "Removed Directory", MB_OK); } else { mystr = "An error occurred during removing content of " + sCompleteFileName; - // MessageBox(NULL, mystr.c_str(), "Error removing directory", MB_OK); } } else @@ -278,12 +160,10 @@ static BOOL RemoveCompleteDirectory( std::_tstring sPath ) if ( fSuccess ) { mystr = "Successfully removed file " + sCompleteFileName; - // MessageBox(NULL, mystr.c_str(), "Removed File", MB_OK); } else { mystr = "An error occurred during removal of file " + sCompleteFileName; - // MessageBox(NULL, mystr.c_str(), "Error removing file", MB_OK); } } } @@ -325,7 +205,6 @@ extern "C" UINT __stdcall RegisterExtensions(MSIHANDLE handle) WIN32_FIND_DATA aFindFileData; mystr = "unopkg file: " + sUnoPkgFile; - //MessageBox(NULL, mystr.c_str(), "Command", MB_OK); // Find unopkg.exe HANDLE hFindUnopkg = FindFirstFile( sUnoPkgFile.c_str(), &aFindFileData ); @@ -335,29 +214,11 @@ extern "C" UINT __stdcall RegisterExtensions(MSIHANDLE handle) // unopkg.exe exists in program directory std::_tstring sCommand = sUnoPkgFile + " sync"; mystr = "Command: " + sCommand; - //MessageBox(NULL, mystr.c_str(), "Command", MB_OK); DWORD exitCode = 0; - bool fSuccess = ExecuteCommand( sCommand.c_str(), & exitCode); - -// if ( fSuccess ) -// { -// mystr = "Executed successfully!"; -// MessageBox(NULL, mystr.c_str(), "Command", MB_OK); -// } -// else -// { -// mystr = "An error occurred during execution!"; -// MessageBox(NULL, mystr.c_str(), "Command", MB_OK); -// } - + ExecuteCommand( sCommand.c_str(), & exitCode); FindClose( hFindUnopkg ); } -// else -// { -// mystr = "Error: Did not find " + sUnoPkgFile; -// MessageBox(NULL, mystr.c_str(), "Command", MB_OK); -// } return ERROR_SUCCESS; } @@ -376,7 +237,6 @@ extern "C" UINT __stdcall RemoveExtensions(MSIHANDLE handle) std::_tstring sInstDir; std::_tstring sProductKey = GetMsiProperty( handle, TEXT("FINDPRODUCT") ); - //MessageBox( NULL, sProductKey.c_str(), "Titel", MB_OK ); if ( ERROR_SUCCESS == RegOpenKey( HKEY_CURRENT_USER, sProductKey.c_str(), &hKey ) ) { @@ -403,18 +263,7 @@ extern "C" UINT __stdcall RemoveExtensions(MSIHANDLE handle) std::_tstring sCacheDir = sInstDir + TEXT("share\\prereg\\bundled"); - bool fSuccess = RemoveCompleteDirectory( sCacheDir ); - -// if ( fSuccess ) -// { -// mystr = "Executed successfully!"; -// MessageBox(NULL, mystr.c_str(), "Main methode", MB_OK); -// } -// else -// { -// mystr = "An error occurred during execution!"; -// MessageBox(NULL, mystr.c_str(), "Main methode", MB_OK); -// } + RemoveCompleteDirectory( sCacheDir ); return ERROR_SUCCESS; } |