fix smpackage uninstall and install to different installation other than where tools.exe resides

This commit is contained in:
Chris Danford
2006-02-15 03:58:29 +00:00
parent 75bd3e55a7
commit 53e0ea8f24
6 changed files with 49 additions and 27 deletions
+17
View File
@@ -896,6 +896,23 @@ void GetDirListingRecursive( RageFileDriver *prfd, const RString &sDir, const RS
}
}
bool DeleteRecursive( RageFileDriver *prfd, const RString &sDir )
{
ASSERT( sDir.Right(1) == "/" );
vector<RString> vsFiles;
prfd->GetDirListing( sDir+"*", vsFiles, false, true );
FOREACH_CONST( RString, vsFiles, s )
{
if( IsADirectory(*s) )
DeleteRecursive( *s+"/" );
else
FILEMAN->Remove( *s );
}
return FILEMAN->Remove( sDir );
}
bool DeleteRecursive( const RString &sDir )
{
ASSERT( sDir.Right(1) == "/" );
+1
View File
@@ -439,6 +439,7 @@ void GetDirListing( const RString &sPath, vector<RString> &AddTo, bool bOnlyDirs
void GetDirListingRecursive( const RString &sDir, const RString &sMatch, vector<RString> &AddTo ); /* returns path too */
void GetDirListingRecursive( RageFileDriver *prfd, const RString &sDir, const RString &sMatch, vector<RString> &AddTo ); /* returns path too */
bool DeleteRecursive( const RString &sDir ); /* delete the dir and all files/subdirs inside it */
bool DeleteRecursive( RageFileDriver *prfd, const RString &sDir ); /* delete the dir and all files/subdirs inside it */
bool DoesFileExist( const RString &sPath );
bool IsAFile( const RString &sPath );
bool IsADirectory( const RString &sPath );
+19 -10
View File
@@ -19,6 +19,7 @@
#include "LocalizedString.h"
#include "RageLog.h"
#include "arch/Dialog/Dialog.h"
#include "RageFileDriverDirect.h"
#ifdef _DEBUG
#define new DEBUG_NEW
@@ -183,7 +184,7 @@ static bool CheckPackages( RageFileDriverZip &fileDriver )
int cnt = 0;
ini.GetValue( "Packages", "NumPackages", cnt );
vector<RString> Directories;
vector<RString> vsDirectories;
for( int i = 0; i < cnt; ++i )
{
RString path;
@@ -197,15 +198,15 @@ static bool CheckPackages( RageFileDriverZip &fileDriver )
if( !SMPackageUtil::IsValidPackageDirectory(path) )
continue;
Directories.push_back(path);
vsDirectories.push_back(path);
}
if( Directories.empty() )
if( vsDirectories.empty() )
return true;
{
UninstallOld UninstallOldDlg;
UninstallOldDlg.m_sPackages = join("\r\n", Directories);
UninstallOldDlg.m_sPackages = join("\r\n", vsDirectories);
int nResponse = UninstallOldDlg.DoModal();
if( nResponse == IDCANCEL )
return false; // cancelled
@@ -219,9 +220,10 @@ static bool CheckPackages( RageFileDriverZip &fileDriver )
if( cwd[cwd.size()-1] != '\\' )
cwd += "\\";
for( i = 0; i < (int) Directories.size(); ++i )
for( i = 0; i < (int)vsDirectories.size(); ++i )
{
RString sDir = Directories[i];
RString sDir = vsDirectories[i];
sDir += "/";
if( !DeleteRecursive(sDir) ) // error deleting
{
return false;
@@ -279,6 +281,9 @@ void CSMPackageInstallDlg::OnOK()
exit(1); // better way to abort?
}
RageFileDriverDirect dir( sInstallDir );
// handle error?
// Show comment (if any)
{
RString sComment = zip.GetGlobalComment();
@@ -344,19 +349,23 @@ retry_unzip:
goto show_error;
}
RageFile fileTo;
if( !fileTo.Open(sFile, RageFile::WRITE) )
int iError;
RageFileBasic *pFileTo = dir.Open( sFile, RageFile::WRITE, iError );
if( pFileTo == NULL )
{
sError = ssprintf( ERROR_OPENING_DESTINATION_FILE.GetValue(), sFile.c_str(), fileTo.GetError().c_str() );
sError = ssprintf( ERROR_OPENING_DESTINATION_FILE.GetValue(), sFile.c_str(), pFileTo->GetError().c_str() );
goto show_error;
}
RString sErr;
if( !FileCopy(*pFileFrom, fileTo, sErr) )
if( !FileCopy(*pFileFrom, *pFileTo, sErr) )
{
sError = ssprintf( ERROR_COPYING_FILE.GetValue(), sFile.c_str(), sErr.c_str() );
goto show_error;
}
SAFE_DELETE( pFileFrom );
SAFE_DELETE( pFileTo );
}
goto done_with_file;
+2 -6
View File
@@ -21,18 +21,14 @@ UninstallOld::~UninstallOld()
{
}
void UninstallOld::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
DDX_Text(pDX, IDC_PACKAGES, m_sPackages);
}
BOOL UninstallOld::OnInitDialog()
{
CDialog::OnInitDialog();
DialogUtil::LocalizeDialogAndContents( *this );
GetDlgItem(IDC_PACKAGES)->SetWindowText( m_sPackages );
return TRUE; // return TRUE unless you set the focus to a control
}
-1
View File
@@ -14,7 +14,6 @@ public:
enum { IDD = IDD_UNINSTALL_OLD_PACKAGES };
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
virtual BOOL OnInitDialog();
void OnOK();
void OnCancel();
+10 -10
View File
@@ -232,20 +232,20 @@ BEGIN
"Button",BS_AUTOCHECKBOX | WS_TABSTOP,10,149,145,11
END
IDD_UNINSTALL_OLD_PACKAGES DIALOG 0, 0, 277, 161
IDD_UNINSTALL_OLD_PACKAGES DIALOGEX 0, 0, 228, 152
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION |
WS_SYSMENU
CAPTION "Uninstall Old Packages"
FONT 8, "MS Shell Dlg"
FONT 8, "MS Shell Dlg", 0, 0, 0x0
BEGIN
DEFPUSHBUTTON "&Yes",IDOK,55,132,50,14
PUSHBUTTON "Cancel",IDCANCEL,171,132,50,14
DEFPUSHBUTTON "&Yes",IDOK,31,131,50,14
PUSHBUTTON "Cancel",IDCANCEL,147,131,50,14
LTEXT "The following packages are already installed. It is strongly recommended that they be deleted before installing this package.",
IDC_STATIC,32,11,214,19
EDITTEXT IDC_PACKAGES,56,37,165,77,ES_MULTILINE | ES_AUTOHSCROLL |
IDC_STATIC,7,7,214,27
EDITTEXT IDC_PACKAGES,31,36,165,77,ES_MULTILINE | ES_AUTOHSCROLL |
ES_READONLY | WS_VSCROLL
PUSHBUTTON "&No",IDC_BUTTON1,111,132,49,14
CTEXT "Delete old packages?",IDC_STATIC,55,119,166,12
PUSHBUTTON "&No",IDC_BUTTON1,87,131,49,14
CTEXT "Delete old packages?",IDC_STATIC,31,117,166,12
END
IDD_CHANGE_GAME_SETTINGS DIALOGEX 0, 0, 162, 298
@@ -435,9 +435,9 @@ BEGIN
IDD_UNINSTALL_OLD_PACKAGES, DIALOG
BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 270
RIGHTMARGIN, 221
TOPMARGIN, 7
BOTTOMMARGIN, 154
BOTTOMMARGIN, 145
END
IDD_CHANGE_GAME_SETTINGS, DIALOG