summaryrefslogtreecommitdiff
path: root/setup_native/source
diff options
context:
space:
mode:
authorOliver Bolte <obo@openoffice.org>2005-07-07 10:00:14 +0000
committerOliver Bolte <obo@openoffice.org>2005-07-07 10:00:14 +0000
commitd770dd8446290ee2b0fd6efd80ce6ca47e1b998f (patch)
tree3b055212dc2d072fba2a2cfc322e497c9b517c60 /setup_native/source
parent34a42348db38cf2eb829cd10b6462e689b5c970e (diff)
INTEGRATION: CWS sb33 (1.2.28); FILE MERGED
2005/07/06 09:43:01 sb 1.2.28.1: #124119# Merged in 1.2.22.2.
Diffstat (limited to 'setup_native/source')
-rwxr-xr-xsetup_native/source/win32/customactions/patch/swappatchfiles.cxx30
1 files changed, 25 insertions, 5 deletions
diff --git a/setup_native/source/win32/customactions/patch/swappatchfiles.cxx b/setup_native/source/win32/customactions/patch/swappatchfiles.cxx
index 190cc3480668..119f0ce82f2d 100755
--- a/setup_native/source/win32/customactions/patch/swappatchfiles.cxx
+++ b/setup_native/source/win32/customactions/patch/swappatchfiles.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: swappatchfiles.cxx,v $
*
- * $Revision: 1.2 $
+ * $Revision: 1.3 $
*
- * last change: $Author: obo $ $Date: 2005-04-20 11:41:45 $
+ * last change: $Author: obo $ $Date: 2005-07-07 11:00:14 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -102,7 +102,11 @@ static bool SwapFiles( const std::_tstring& sFileName1, const std::_tstring& sFi
{
std::_tstring sTempFileName = sFileName1 + TEXT(".tmp");
- bool fSuccess = MoveFileEx( sFileName1.c_str(), sTempFileName.c_str(), MOVEFILE_REPLACE_EXISTING );
+ bool fSuccess = true;
+
+ //Try to move the original file to a temp file
+ fSuccess = MoveFileEx( sFileName1.c_str(), sTempFileName.c_str(),
+ MOVEFILE_REPLACE_EXISTING );
if ( fSuccess )
{
@@ -110,14 +114,30 @@ static bool SwapFiles( const std::_tstring& sFileName1, const std::_tstring& sFi
if ( fSuccess )
{
- fSuccess = MoveFileEx( sTempFileName.c_str(), sFileName2.c_str(), MOVEFILE_REPLACE_EXISTING );
+ fSuccess = MoveFileEx( sTempFileName.c_str(), sFileName2.c_str(),
+ MOVEFILE_REPLACE_EXISTING );
if ( !fSuccess )
MoveFileEx( sFileName1.c_str(), sFileName2.c_str(), MOVEFILE_REPLACE_EXISTING );
}
else
+ {
MoveFileEx( sTempFileName.c_str(), sFileName1.c_str(), MOVEFILE_REPLACE_EXISTING );
+ }
+ }
+ else
+ {
+ //It could be that there is no original file and therefore copying the original to a temp
+ // file failed. Examine if there is no original and if so then move file2 to file1
+ WIN32_FIND_DATA data;
+ HANDLE hdl = FindFirstFile(sFileName1.c_str(), &data);
+ if (hdl == INVALID_HANDLE_VALUE)
+ fSuccess = MoveFileEx( sFileName2.c_str(), sFileName1.c_str(),
+ MOVEFILE_REPLACE_EXISTING );
+ else
+ FindClose(hdl);
}
+
return fSuccess;
}
@@ -241,7 +261,7 @@ extern "C" UINT __stdcall UninstallPatchedFiles( MSIHANDLE handle )
// mystr = "Convert: " + sFileName1 + " to " + sFileName2;
// MessageBox( NULL, mystr.c_str(), "Titel", MB_OK );
- SwapFiles( sFileName1, sFileName2 );
+ SwapFiles( sFileName2, sFileName1 );
}
pKeyName += _tcslen(pKeyName) + 1;