strip the same files when archiving and extracting

This commit is contained in:
Chris Danford
2006-02-01 04:48:21 +00:00
parent 5467ab21ed
commit 4c5340c6c4
4 changed files with 29 additions and 12 deletions
@@ -69,6 +69,13 @@ static bool CompareStringNoCase( const RString &s1, const RString &s2 )
return s1.CompareNoCase( s2 ) < 0;
}
void GetSmzipFilesToExtract( RageFileDriver &zip, vector<RString> &vsOut )
{
GetDirListingRecursive( &zip, "/", "*", vsOut );
SMPackageUtil::StripIgnoredSmzipFiles( vsOut );
}
static LocalizedString COULD_NOT_OPEN_FILE ( "CSMPackageInstallDlg", "Could not open file '%s'." );
static LocalizedString IS_NOT_A_VALID_ZIP ( "CSMPackageInstallDlg", "'%s' is not a valid zip archive." );
static LocalizedString YOU_HAVE_CHOSEN_TO_INSTALL ( "CSMPackageInstallDlg", "You have chosen to install the package:" );
@@ -122,7 +129,7 @@ BOOL CSMPackageInstallDlg::OnInitDialog()
//
{
vector<RString> vs;
GetDirListingRecursive( &zip, "/", "*", vs );
GetSmzipFilesToExtract( zip, vs );
CEdit* pEdit2 = (CEdit*)GetDlgItem(IDC_EDIT_MESSAGE2);
RString sText = "\t" + join( "\r\n\t", vs );
pEdit2->SetWindowText( sText );
@@ -314,7 +321,7 @@ void CSMPackageInstallDlg::OnOK()
// Unzip the SMzip package into the installation folder
vector<RString> vs;
GetDirListingRecursive( &zip, "/", "*", vs );
GetSmzipFilesToExtract( zip, vs );
for( unsigned i=0; i<vs.size(); i++ )
{
// Throw some text up so the user has something to look at during the long pause.
@@ -347,10 +354,6 @@ retry_unzip:
const RString sFile = vs[i];
LOG->Trace( "Extracting: "+sFile );
// skip extracting "thumbs.db" files
if( Basename(sFile).CompareNoCase("thumbs.db") == 0 )
continue;
RString sError;
{
int iErr;
+17
View File
@@ -215,6 +215,23 @@ RString SMPackageUtil::GetLanguageCodeFromDisplayString( const RString &sDisplay
return s;
}
void SMPackageUtil::StripIgnoredSmzipFiles( vector<RString> &vsFilesInOut )
{
for( int i=vsFilesInOut.size()-1; i>=0; i-- )
{
const RString &sFile = vsFilesInOut[i];
bool bEraseThis = false;
bEraseThis |= EndsWith( sFile, "smzip.ctl" );
bEraseThis |= EndsWith( sFile, ".old" );
bEraseThis |= EndsWith( sFile, "Thumbs.db" );
bEraseThis |= (sFile.find("CVS") != string::npos);
if( bEraseThis )
vsFilesInOut.erase( vsFilesInOut.begin()+i );
}
}
bool SMPackageUtil::DoesOsAbsoluteFileExist( const RString &sOsAbsoluteFile )
{
#if defined(WIN32)
@@ -133,6 +133,7 @@ static bool ExportPackage( const RString &sPackageName, const RString &sSourceIn
if( sDir.Right(1) != "/" )
sDir += "/";
GetDirListingRecursive( &fileDriver, sDir, "*", asFilePaths );
SMPackageUtil::StripIgnoredSmzipFiles( asFilePaths );
}
}
@@ -177,12 +178,6 @@ static bool ExportPackage( const RString &sPackageName, const RString &sSourceIn
{
RString sFilePath = asFilePaths[j];
// don't export "thumbs.db" files or "CVS" folders
if( sFilePath.find("CVS") != string::npos )
continue; // skip
if( sFilePath.find("Thumbs.db") != string::npos )
continue; // skip
RString sExt = GetExtension( sFilePath );
bool bUseCompression = true;
if( sExt.CompareNoCase("avi")==0 ||
+2
View File
@@ -23,6 +23,8 @@ namespace SMPackageUtil
RString GetLanguageDisplayString( const RString &sIsoCode );
RString GetLanguageCodeFromDisplayString( const RString &sDisplayString );
void StripIgnoredSmzipFiles( vector<RString> &vsFilesInOut );
bool GetFileContentsOsAbsolute( const RString &sAbsoluteOsFile, RString &sOut );
bool DoesOsAbsoluteFileExist( const RString &sOsAbsoluteFile );