*u8: add support for checking if an archive was packed with wii.cs to allow fixing it

use case-insensitivity.  seems all the nintendo tools are running on windows and in the system menu html, paths are case-insensitive.  it doesnt seem like there is anywhere where they would need to be the other way

* lz77: support for unpacking archives larger than 0xffffff bytes

* nusdownloader: dont try to write files to cache if there is not one set
This commit is contained in:
giantpune 2011-07-11 05:47:33 +00:00
parent f4a991de29
commit c71ac45ab2
4 changed files with 27 additions and 4 deletions

View File

@ -189,7 +189,12 @@ QByteArray LZ77::Decompress( const QByteArray &compressed, int offset )
infile.read( (char*)&gbaheader, 4 ); infile.read( (char*)&gbaheader, 4 );
decomp_size = gbaheader >> 8; decomp_size = gbaheader >> 8;
if( !decomp_size )
{
infile.read( (char*)&decomp_size, 4 );
}
quint8 text_buf[ N + 17 ]; quint8 text_buf[ N + 17 ];
//qDebug() << "decomp_size:" << decomp_size;
for( i = 0; i < N - F; i++ ) for( i = 0; i < N - F; i++ )
text_buf[ i ] = 0xdf; text_buf[ i ] = 0xdf;

View File

@ -332,6 +332,9 @@ QString NusDownloader::GetCachePath( quint32 idx )
if( currentJob.version == TITLE_LATEST_VERSION || !currentJob.tid )//c'mon guy if( currentJob.version == TITLE_LATEST_VERSION || !currentJob.tid )//c'mon guy
return QString(); return QString();
if( cachePath.isEmpty() )
return QString();
QString path = cachePath; QString path = cachePath;
if( path.endsWith( "/" ) ) if( path.endsWith( "/" ) )
path.resize( path.size() - 1 ); path.resize( path.size() - 1 );
@ -486,7 +489,7 @@ void NusDownloader::StartDownload()
//qDebug() << "NusDownloader::StartDownload" << dlJob.index; //qDebug() << "NusDownloader::StartDownload" << dlJob.index;
emit SendDownloadProgress( 0 ); emit SendDownloadProgress( 0 );
QString dlUrl = NUS_BASE_URL + dlJob.tid + "/" + dlJob.name; QString dlUrl = NUS_BASE_URL + dlJob.tid + "/" + dlJob.name;
//qDebug() << "url" << dlUrl; qDebug() << "url" << dlUrl;
currentJobText = dlUrl; currentJobText = dlUrl;
QUrl url( dlUrl ); QUrl url( dlUrl );

View File

@ -19,6 +19,7 @@ U8::U8( bool initialize, int type, const QStringList &names )
{ {
ok = false; ok = false;
isLz77 = false; isLz77 = false;
wii_cs_error = false;
paths.clear(); paths.clear();
nestedU8s.clear(); nestedU8s.clear();
fst = NULL; fst = NULL;
@ -876,11 +877,17 @@ void U8::CreateEntryList()
{ {
qWarning() << "This archive was made by a broken tool such as U8Mii. I'm trying to fix it, but I can't make any promises"; qWarning() << "This archive was made by a broken tool such as U8Mii. I'm trying to fix it, but I can't make any promises";
fixWarn = true; fixWarn = true;
wii_cs_error = true;
} }
#ifndef U8_DONT_FIX_RECURSION_ERRORS
fst[ current ].ParentOffset = qFromBigEndian( folder ); fst[ current ].ParentOffset = qFromBigEndian( folder );
#endif
} }
//#ifndef U8_DONT_FIX_RECURSION_ERRORS
// fst[ current ].ParentOffset = qFromBigEndian( folder );
//#endif
} }
path += "/"; path += '/';
paths << path; paths << path;
} }
else else
@ -924,6 +931,7 @@ void U8::CreateEntryList()
U8::U8( const QByteArray &ba ) U8::U8( const QByteArray &ba )
{ {
wii_cs_error = false;
//qDebug() << "U8::U8 dataSize:" << hex << ba.size(); //qDebug() << "U8::U8 dataSize:" << hex << ba.size();
Load( ba ); Load( ba );
} }
@ -931,6 +939,7 @@ U8::U8( const QByteArray &ba )
void U8::Load( const QByteArray &ba ) void U8::Load( const QByteArray &ba )
{ {
ok = false; ok = false;
wii_cs_error = false;
isLz77 = false; isLz77 = false;
headerType = U8_Hdr_none; headerType = U8_Hdr_none;
paths.clear(); paths.clear();
@ -1063,7 +1072,8 @@ int U8::FindEntry( const QString &str, int d )
else else
item = str; item = str;
if( FstName( entry ) == item ) if( !FstName( entry ).compare( item, Qt::CaseInsensitive ) )
//if( FstName( entry ) == item )
{ {
if( item == str || item + "/" == str )//this is the item we are looking for if( item == str || item + "/" == str )//this is the item we are looking for
{ {

View File

@ -151,12 +151,17 @@ public:
//reads from the fst and makes the list of paths //reads from the fst and makes the list of paths
void CreateEntryList(); void CreateEntryList();
// if this archive was packed by any of the wii.cs tools and it is not
// a standard banner, it will be incorrectly packed, and this will return true
bool IsBuggy(){ return wii_cs_error; }
private: private:
QByteArray data;//data starting at the U8 tag QByteArray data;//data starting at the U8 tag
QStringList paths; QStringList paths;
bool ok; bool ok;
bool wii_cs_error;
//if this archive as a whole is lz77 compressed //if this archive as a whole is lz77 compressed
bool isLz77; bool isLz77;