From b703943847635bc5d0170b791f2f543855ecd521 Mon Sep 17 00:00:00 2001 From: giantpune Date: Mon, 11 Jul 2011 05:47:33 +0000 Subject: [PATCH] *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 git-svn-id: http://wiiqt.googlecode.com/svn/trunk@107 389f4c8b-5dfe-645f-db0e-df882bc27289 --- WiiQt/lz77.cpp | 5 +++++ WiiQt/nusdownloader.cpp | 5 ++++- WiiQt/u8.cpp | 16 +++++++++++++--- WiiQt/u8.h | 5 +++++ 4 files changed, 27 insertions(+), 4 deletions(-) diff --git a/WiiQt/lz77.cpp b/WiiQt/lz77.cpp index bf90729..d22d466 100644 --- a/WiiQt/lz77.cpp +++ b/WiiQt/lz77.cpp @@ -189,7 +189,12 @@ QByteArray LZ77::Decompress( const QByteArray &compressed, int offset ) infile.read( (char*)&gbaheader, 4 ); decomp_size = gbaheader >> 8; + if( !decomp_size ) + { + infile.read( (char*)&decomp_size, 4 ); + } quint8 text_buf[ N + 17 ]; + //qDebug() << "decomp_size:" << decomp_size; for( i = 0; i < N - F; i++ ) text_buf[ i ] = 0xdf; diff --git a/WiiQt/nusdownloader.cpp b/WiiQt/nusdownloader.cpp index e2fb3d1..20834c5 100644 --- a/WiiQt/nusdownloader.cpp +++ b/WiiQt/nusdownloader.cpp @@ -332,6 +332,9 @@ QString NusDownloader::GetCachePath( quint32 idx ) if( currentJob.version == TITLE_LATEST_VERSION || !currentJob.tid )//c'mon guy return QString(); + if( cachePath.isEmpty() ) + return QString(); + QString path = cachePath; if( path.endsWith( "/" ) ) path.resize( path.size() - 1 ); @@ -486,7 +489,7 @@ void NusDownloader::StartDownload() //qDebug() << "NusDownloader::StartDownload" << dlJob.index; emit SendDownloadProgress( 0 ); QString dlUrl = NUS_BASE_URL + dlJob.tid + "/" + dlJob.name; - //qDebug() << "url" << dlUrl; + qDebug() << "url" << dlUrl; currentJobText = dlUrl; QUrl url( dlUrl ); diff --git a/WiiQt/u8.cpp b/WiiQt/u8.cpp index 8a23cc3..66273e6 100644 --- a/WiiQt/u8.cpp +++ b/WiiQt/u8.cpp @@ -19,6 +19,7 @@ U8::U8( bool initialize, int type, const QStringList &names ) { ok = false; isLz77 = false; + wii_cs_error = false; paths.clear(); nestedU8s.clear(); 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"; fixWarn = true; + wii_cs_error = true; } - fst[ current ].ParentOffset = qFromBigEndian( folder ); +#ifndef U8_DONT_FIX_RECURSION_ERRORS + fst[ current ].ParentOffset = qFromBigEndian( folder ); +#endif } +//#ifndef U8_DONT_FIX_RECURSION_ERRORS +// fst[ current ].ParentOffset = qFromBigEndian( folder ); +//#endif } - path += "/"; + path += '/'; paths << path; } else @@ -924,6 +931,7 @@ void U8::CreateEntryList() U8::U8( const QByteArray &ba ) { + wii_cs_error = false; //qDebug() << "U8::U8 dataSize:" << hex << ba.size(); Load( ba ); } @@ -931,6 +939,7 @@ U8::U8( const QByteArray &ba ) void U8::Load( const QByteArray &ba ) { ok = false; + wii_cs_error = false; isLz77 = false; headerType = U8_Hdr_none; paths.clear(); @@ -1063,7 +1072,8 @@ int U8::FindEntry( const QString &str, int d ) else 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 { diff --git a/WiiQt/u8.h b/WiiQt/u8.h index f1754e7..06d3892 100644 --- a/WiiQt/u8.h +++ b/WiiQt/u8.h @@ -151,12 +151,17 @@ public: //reads from the fst and makes the list of paths 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: QByteArray data;//data starting at the U8 tag QStringList paths; bool ok; + bool wii_cs_error; + //if this archive as a whole is lz77 compressed bool isLz77;