fix smpackage uninstall and install to different installation other than where tools.exe resides
This commit is contained in:
@@ -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 )
|
bool DeleteRecursive( const RString &sDir )
|
||||||
{
|
{
|
||||||
ASSERT( sDir.Right(1) == "/" );
|
ASSERT( sDir.Right(1) == "/" );
|
||||||
|
|||||||
@@ -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( 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 */
|
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( 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 DoesFileExist( const RString &sPath );
|
||||||
bool IsAFile( const RString &sPath );
|
bool IsAFile( const RString &sPath );
|
||||||
bool IsADirectory( const RString &sPath );
|
bool IsADirectory( const RString &sPath );
|
||||||
|
|||||||
@@ -19,6 +19,7 @@
|
|||||||
#include "LocalizedString.h"
|
#include "LocalizedString.h"
|
||||||
#include "RageLog.h"
|
#include "RageLog.h"
|
||||||
#include "arch/Dialog/Dialog.h"
|
#include "arch/Dialog/Dialog.h"
|
||||||
|
#include "RageFileDriverDirect.h"
|
||||||
|
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
#define new DEBUG_NEW
|
#define new DEBUG_NEW
|
||||||
@@ -183,7 +184,7 @@ static bool CheckPackages( RageFileDriverZip &fileDriver )
|
|||||||
int cnt = 0;
|
int cnt = 0;
|
||||||
ini.GetValue( "Packages", "NumPackages", cnt );
|
ini.GetValue( "Packages", "NumPackages", cnt );
|
||||||
|
|
||||||
vector<RString> Directories;
|
vector<RString> vsDirectories;
|
||||||
for( int i = 0; i < cnt; ++i )
|
for( int i = 0; i < cnt; ++i )
|
||||||
{
|
{
|
||||||
RString path;
|
RString path;
|
||||||
@@ -197,15 +198,15 @@ static bool CheckPackages( RageFileDriverZip &fileDriver )
|
|||||||
if( !SMPackageUtil::IsValidPackageDirectory(path) )
|
if( !SMPackageUtil::IsValidPackageDirectory(path) )
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
Directories.push_back(path);
|
vsDirectories.push_back(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
if( Directories.empty() )
|
if( vsDirectories.empty() )
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
{
|
{
|
||||||
UninstallOld UninstallOldDlg;
|
UninstallOld UninstallOldDlg;
|
||||||
UninstallOldDlg.m_sPackages = join("\r\n", Directories);
|
UninstallOldDlg.m_sPackages = join("\r\n", vsDirectories);
|
||||||
int nResponse = UninstallOldDlg.DoModal();
|
int nResponse = UninstallOldDlg.DoModal();
|
||||||
if( nResponse == IDCANCEL )
|
if( nResponse == IDCANCEL )
|
||||||
return false; // cancelled
|
return false; // cancelled
|
||||||
@@ -219,9 +220,10 @@ static bool CheckPackages( RageFileDriverZip &fileDriver )
|
|||||||
if( cwd[cwd.size()-1] != '\\' )
|
if( cwd[cwd.size()-1] != '\\' )
|
||||||
cwd += "\\";
|
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
|
if( !DeleteRecursive(sDir) ) // error deleting
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
@@ -279,6 +281,9 @@ void CSMPackageInstallDlg::OnOK()
|
|||||||
exit(1); // better way to abort?
|
exit(1); // better way to abort?
|
||||||
}
|
}
|
||||||
|
|
||||||
|
RageFileDriverDirect dir( sInstallDir );
|
||||||
|
// handle error?
|
||||||
|
|
||||||
// Show comment (if any)
|
// Show comment (if any)
|
||||||
{
|
{
|
||||||
RString sComment = zip.GetGlobalComment();
|
RString sComment = zip.GetGlobalComment();
|
||||||
@@ -344,19 +349,23 @@ retry_unzip:
|
|||||||
goto show_error;
|
goto show_error;
|
||||||
}
|
}
|
||||||
|
|
||||||
RageFile fileTo;
|
int iError;
|
||||||
if( !fileTo.Open(sFile, RageFile::WRITE) )
|
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;
|
goto show_error;
|
||||||
}
|
}
|
||||||
|
|
||||||
RString sErr;
|
RString sErr;
|
||||||
if( !FileCopy(*pFileFrom, fileTo, sErr) )
|
if( !FileCopy(*pFileFrom, *pFileTo, sErr) )
|
||||||
{
|
{
|
||||||
sError = ssprintf( ERROR_COPYING_FILE.GetValue(), sFile.c_str(), sErr.c_str() );
|
sError = ssprintf( ERROR_COPYING_FILE.GetValue(), sFile.c_str(), sErr.c_str() );
|
||||||
goto show_error;
|
goto show_error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SAFE_DELETE( pFileFrom );
|
||||||
|
SAFE_DELETE( pFileTo );
|
||||||
}
|
}
|
||||||
|
|
||||||
goto done_with_file;
|
goto done_with_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()
|
BOOL UninstallOld::OnInitDialog()
|
||||||
{
|
{
|
||||||
CDialog::OnInitDialog();
|
CDialog::OnInitDialog();
|
||||||
|
|
||||||
DialogUtil::LocalizeDialogAndContents( *this );
|
DialogUtil::LocalizeDialogAndContents( *this );
|
||||||
|
|
||||||
|
GetDlgItem(IDC_PACKAGES)->SetWindowText( m_sPackages );
|
||||||
|
|
||||||
return TRUE; // return TRUE unless you set the focus to a control
|
return TRUE; // return TRUE unless you set the focus to a control
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -14,7 +14,6 @@ public:
|
|||||||
enum { IDD = IDD_UNINSTALL_OLD_PACKAGES };
|
enum { IDD = IDD_UNINSTALL_OLD_PACKAGES };
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
|
|
||||||
virtual BOOL OnInitDialog();
|
virtual BOOL OnInitDialog();
|
||||||
void OnOK();
|
void OnOK();
|
||||||
void OnCancel();
|
void OnCancel();
|
||||||
|
|||||||
@@ -232,20 +232,20 @@ BEGIN
|
|||||||
"Button",BS_AUTOCHECKBOX | WS_TABSTOP,10,149,145,11
|
"Button",BS_AUTOCHECKBOX | WS_TABSTOP,10,149,145,11
|
||||||
END
|
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 |
|
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION |
|
||||||
WS_SYSMENU
|
WS_SYSMENU
|
||||||
CAPTION "Uninstall Old Packages"
|
CAPTION "Uninstall Old Packages"
|
||||||
FONT 8, "MS Shell Dlg"
|
FONT 8, "MS Shell Dlg", 0, 0, 0x0
|
||||||
BEGIN
|
BEGIN
|
||||||
DEFPUSHBUTTON "&Yes",IDOK,55,132,50,14
|
DEFPUSHBUTTON "&Yes",IDOK,31,131,50,14
|
||||||
PUSHBUTTON "Cancel",IDCANCEL,171,132,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.",
|
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
|
IDC_STATIC,7,7,214,27
|
||||||
EDITTEXT IDC_PACKAGES,56,37,165,77,ES_MULTILINE | ES_AUTOHSCROLL |
|
EDITTEXT IDC_PACKAGES,31,36,165,77,ES_MULTILINE | ES_AUTOHSCROLL |
|
||||||
ES_READONLY | WS_VSCROLL
|
ES_READONLY | WS_VSCROLL
|
||||||
PUSHBUTTON "&No",IDC_BUTTON1,111,132,49,14
|
PUSHBUTTON "&No",IDC_BUTTON1,87,131,49,14
|
||||||
CTEXT "Delete old packages?",IDC_STATIC,55,119,166,12
|
CTEXT "Delete old packages?",IDC_STATIC,31,117,166,12
|
||||||
END
|
END
|
||||||
|
|
||||||
IDD_CHANGE_GAME_SETTINGS DIALOGEX 0, 0, 162, 298
|
IDD_CHANGE_GAME_SETTINGS DIALOGEX 0, 0, 162, 298
|
||||||
@@ -435,9 +435,9 @@ BEGIN
|
|||||||
IDD_UNINSTALL_OLD_PACKAGES, DIALOG
|
IDD_UNINSTALL_OLD_PACKAGES, DIALOG
|
||||||
BEGIN
|
BEGIN
|
||||||
LEFTMARGIN, 7
|
LEFTMARGIN, 7
|
||||||
RIGHTMARGIN, 270
|
RIGHTMARGIN, 221
|
||||||
TOPMARGIN, 7
|
TOPMARGIN, 7
|
||||||
BOTTOMMARGIN, 154
|
BOTTOMMARGIN, 145
|
||||||
END
|
END
|
||||||
|
|
||||||
IDD_CHANGE_GAME_SETTINGS, DIALOG
|
IDD_CHANGE_GAME_SETTINGS, DIALOG
|
||||||
|
|||||||
Reference in New Issue
Block a user