mirror of
https://github.com/martravi/wiiqt6.git
synced 2024-11-21 21:19:15 +01:00
* adding stuff to convert to/from data.bin for saves
git-svn-id: http://wiiqt.googlecode.com/svn/trunk@34 389f4c8b-5dfe-645f-db0e-df882bc27289
This commit is contained in:
parent
7570278999
commit
1994e8bdda
@ -9,7 +9,7 @@
|
||||
|
||||
*/
|
||||
|
||||
//#include <stdio.h>
|
||||
#include <stdio.h>
|
||||
//#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
@ -343,7 +343,8 @@ void aes_decrypt(u8 *iv, u8 *inbuf, u8 *outbuf, unsigned long long len) {
|
||||
u8 block[16];
|
||||
unsigned int blockno = 0, i;
|
||||
|
||||
// debug_printf("aes_decrypt(%p, %p, %p, %lld)\n", iv, inbuf, outbuf, len);
|
||||
//fprintf( stderr,"aes_decrypt(%p, %p, %p, %lld)\n", iv, inbuf, outbuf, len );
|
||||
//printf("aes_decrypt(%p, %p, %p, %lld)\n", iv, inbuf, outbuf, len);
|
||||
|
||||
for (blockno = 0; blockno <= (len / sizeof(block)); blockno++) {
|
||||
unsigned int fraction;
|
||||
@ -373,7 +374,8 @@ void aes_encrypt(u8 *iv, u8 *inbuf, u8 *outbuf, unsigned long long len) {
|
||||
u8 block[16];
|
||||
unsigned int blockno = 0, i;
|
||||
|
||||
// debug_printf("aes_decrypt(%p, %p, %p, %lld)\n", iv, inbuf, outbuf, len);
|
||||
//printf("aes_decrypt(%p, %p, %p, %lld)\n", iv, inbuf, outbuf, len);
|
||||
//fprintf( stderr,"aes_encrypt(%p, %p, %p, %lld)\n", iv, inbuf, outbuf, len);
|
||||
|
||||
for (blockno = 0; blockno <= (len / sizeof(block)); blockno++) {
|
||||
unsigned int fraction;
|
||||
|
@ -5,12 +5,6 @@
|
||||
#include "blocks0to7.h"
|
||||
#include "nandspare.h"
|
||||
|
||||
#define NAND_FILE 1
|
||||
#define NAND_DIR 2
|
||||
#define NAND_READ 1
|
||||
#define NAND_WRITE 2
|
||||
#define NAND_RW ( NAND_READ | NAND_WRITE )
|
||||
|
||||
struct fst_t
|
||||
{
|
||||
quint8 filename[ 0xc ];
|
||||
|
@ -9,6 +9,7 @@ NandDump::NandDump( const QString &path )
|
||||
if( !path.isEmpty() )
|
||||
SetPath( path );
|
||||
}
|
||||
|
||||
NandDump::~NandDump()
|
||||
{
|
||||
if( !basePath.isEmpty() )
|
||||
@ -31,11 +32,13 @@ bool NandDump::SetPath( const QString &path )
|
||||
if( fi.exists() && fi.isFile() )
|
||||
{
|
||||
qWarning() << "NandDump::SetPath ->" << path << "is a file";
|
||||
basePath.clear();
|
||||
return false;
|
||||
}
|
||||
if( !fi.exists() && !QDir().mkpath( path ) )
|
||||
{
|
||||
qWarning() << "NandDump::SetPath -> cant create" << path;
|
||||
basePath.clear();
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -48,6 +51,7 @@ bool NandDump::SetPath( const QString &path )
|
||||
|| ( !d.exists( "sys" ) && !d.mkdir( "sys" ) ) )
|
||||
{
|
||||
qWarning() << "NandDump::SetPath -> error creating subfolders in" << path;
|
||||
basePath.clear();
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -57,6 +61,7 @@ bool NandDump::SetPath( const QString &path )
|
||||
if( !fi.exists() && !FlushUID() )
|
||||
{
|
||||
qWarning() << "NandDump::SetPath -> can\'t create new uid.sys";
|
||||
basePath.clear();
|
||||
return false;
|
||||
}
|
||||
else
|
||||
@ -65,6 +70,7 @@ bool NandDump::SetPath( const QString &path )
|
||||
if( !f.open( QIODevice::ReadOnly ) )
|
||||
{
|
||||
qWarning() << "NandDump::SetPath -> error opening existing uid.sys" << uidPath;
|
||||
basePath.clear();
|
||||
return false;
|
||||
}
|
||||
QByteArray u = f.readAll();
|
||||
@ -80,6 +86,7 @@ bool NandDump::SetPath( const QString &path )
|
||||
if( !fi.exists() && !FlushContentMap() )
|
||||
{
|
||||
qWarning() << "NandDump::SetPath -> can\'t create new content map";
|
||||
basePath.clear();
|
||||
return false;
|
||||
}
|
||||
else
|
||||
@ -88,6 +95,7 @@ bool NandDump::SetPath( const QString &path )
|
||||
if( !f.open( QIODevice::ReadOnly ) )
|
||||
{
|
||||
qWarning() << "NandDump::SetPath -> error opening existing content.map" << cmPath;
|
||||
basePath.clear();
|
||||
return false;
|
||||
}
|
||||
QByteArray u = f.readAll();
|
||||
@ -107,6 +115,11 @@ bool NandDump::SetPath( const QString &path )
|
||||
return true;
|
||||
}
|
||||
|
||||
const QString NandDump::BasePath()
|
||||
{
|
||||
return basePath;
|
||||
}
|
||||
|
||||
//write the uid to the HDD
|
||||
bool NandDump::FlushUID()
|
||||
{
|
||||
@ -338,6 +351,10 @@ bool NandDump::InstallNusItem( const NusJob &job )
|
||||
p.insert( 8 ,"/" );
|
||||
p.prepend( "/title/" );
|
||||
QString path = basePath + p + "/content";
|
||||
|
||||
//remove old title if it exists
|
||||
AbortInstalling( job.tid );
|
||||
|
||||
if( !QFileInfo( path ).exists() && !QDir().mkpath( path ) )
|
||||
return false;
|
||||
|
||||
@ -434,6 +451,10 @@ bool NandDump::InstallWad( Wad wad )
|
||||
p.insert( 8 ,"/" );
|
||||
p.prepend( "/title/" );
|
||||
QString path = basePath + p + "/content";
|
||||
|
||||
//remove old title if it exists
|
||||
AbortInstalling( wad.Tid() );
|
||||
|
||||
if( !QFileInfo( path ).exists() && !QDir().mkpath( path ) )
|
||||
return false;
|
||||
|
||||
@ -498,7 +519,6 @@ QMap< quint64, quint16 > NandDump::GetInstalledTitles()
|
||||
if( basePath.isEmpty() )
|
||||
return ret;
|
||||
|
||||
//QStringList tickets;
|
||||
//get all the tickets
|
||||
QDir d( basePath + "/ticket" );
|
||||
QFileInfoList fiL = d.entryInfoList( QDir::Dirs | QDir::NoDotAndDotDot );//get all folders in "/ticket"
|
||||
@ -540,6 +560,97 @@ QMap< quint64, quint16 > NandDump::GetInstalledTitles()
|
||||
return ret;
|
||||
}
|
||||
|
||||
QMap< quint64, quint32 > NandDump::GetSaveList()
|
||||
{
|
||||
qDebug() << "NandDump::GetSaveList()";
|
||||
QMap< quint64, quint32 >ret;
|
||||
if( basePath.isEmpty() )
|
||||
return ret;
|
||||
|
||||
//get all the tickets
|
||||
QDir d( basePath + "/title" );
|
||||
QFileInfoList fiL = d.entryInfoList( QDir::Dirs | QDir::NoDotAndDotDot );//get all folders in "/title"
|
||||
foreach( QFileInfo fi, fiL )
|
||||
{
|
||||
//qDebug() << "fi:" << fi.absoluteFilePath();
|
||||
if( fi.fileName().size() != 8 )
|
||||
continue;
|
||||
|
||||
bool ok = false;
|
||||
quint32 upper = fi.fileName().toInt( &ok, 16 );
|
||||
if( !ok )
|
||||
continue;
|
||||
//qDebug() << " upper" << hex << upper;
|
||||
|
||||
QDir sd( fi.absoluteFilePath() );//subDir
|
||||
QFileInfoList sfiL = sd.entryInfoList( QDir::Dirs | QDir::NoDotAndDotDot );//get all subfolders in this subfolder
|
||||
foreach( QFileInfo sfi, sfiL )
|
||||
{
|
||||
QString lowerStr = sfi.fileName();
|
||||
if( lowerStr.size() != 8 )
|
||||
continue;
|
||||
|
||||
quint32 lower = lowerStr.toInt( &ok, 16 );
|
||||
if( !ok )
|
||||
continue;
|
||||
|
||||
if( !QFileInfo( basePath + "/title/" + fi.fileName() + "/" + lowerStr + "/data/banner.bin" ).exists() )
|
||||
continue;
|
||||
|
||||
quint64 tid = ( ( (quint64)upper << 32 ) | lower );
|
||||
quint32 size = 0;
|
||||
//go through the data directory and get all the sizes
|
||||
QDirIterator it( QDir( basePath + "/title/" + fi.fileName() + "/" + lowerStr + "/data" ), QDirIterator::Subdirectories );
|
||||
while( it.hasNext() )
|
||||
{
|
||||
it.next();
|
||||
QFileInfo saveStuff = it.fileInfo();
|
||||
if( saveStuff.isFile() )//its a file, get the data and add it to the return idem
|
||||
{
|
||||
size += saveStuff.size();
|
||||
}
|
||||
}
|
||||
//add this title to the return list
|
||||
ret.insert( tid, size );
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool NandDump::DeleteSave( quint64 tid )
|
||||
{
|
||||
if( basePath.isEmpty() )
|
||||
return false;
|
||||
QString tidStr = QString( "%1" ).arg( tid, 16, 16, QChar( '0' ) );
|
||||
QString dataPath = tidStr;
|
||||
dataPath.insert( 8, "/" );
|
||||
dataPath.prepend( basePath + "/title/" );
|
||||
dataPath.append( "/data" );
|
||||
|
||||
//make a list of everything in the data folder and then go through the list in reverse order and delete everything
|
||||
QFileInfoList list;
|
||||
QDir dir( dataPath );
|
||||
dir.setFilter( QDir::Files | QDir::Dirs | QDir::NoDotAndDotDot );
|
||||
QDirIterator it( dir, QDirIterator::Subdirectories );
|
||||
while( it.hasNext() )
|
||||
{
|
||||
it.next();
|
||||
list << it.fileInfo();
|
||||
}
|
||||
while( !list.isEmpty() )
|
||||
{
|
||||
QFileInfo fi = list.takeLast();
|
||||
//qDebug() << "would delete" << fi.absoluteFilePath();
|
||||
if( ( fi.isFile() && !QFile::remove( fi.absoluteFilePath() ) )
|
||||
|| ( fi.isDir() && !QDir().rmdir( fi.absoluteFilePath() ) ) )
|
||||
{
|
||||
qDebug() << "failed to delete" << fi.absoluteFilePath();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void NandDump::ReadReplacementStrings()
|
||||
{
|
||||
replaceStrings.clear();
|
||||
@ -713,7 +824,7 @@ QMap<QString, QString> NandDump::GetReplacementStrings()
|
||||
SaveGame NandDump::GetSaveData( quint64 tid )
|
||||
{
|
||||
SaveGame ret;
|
||||
ret.tid = tid;
|
||||
ret.tid = 0;
|
||||
if( basePath.isEmpty() )
|
||||
return ret;
|
||||
|
||||
@ -728,24 +839,33 @@ SaveGame NandDump::GetSaveData( quint64 tid )
|
||||
if( !d.exists() )//folder doesnt exist, theres nothing to get
|
||||
return ret;
|
||||
|
||||
d.setFilter( QDir::NoDotAndDotDot );
|
||||
d.setFilter( QDir::Files | QDir::Dirs | QDir::NoDotAndDotDot );
|
||||
|
||||
//go through this directory and get the goods
|
||||
QDirIterator it( d, QDirIterator::Subdirectories );
|
||||
while( it.hasNext() )
|
||||
{
|
||||
QString str = it.next();
|
||||
if( !str.startsWith( path ) )
|
||||
{
|
||||
qWarning() << "NandDump::GetSaveData -> bad path" << path << str;
|
||||
return ret;
|
||||
}
|
||||
str.remove( 0, path.size() );
|
||||
ret.entries << FromNandPath( str );//convert from the paths used in the local filesystem to ones expected by wii games
|
||||
|
||||
QFileInfo fi = it.fileInfo();
|
||||
if( fi.isFile() )//its a file, get the data and add it to the return idem
|
||||
{
|
||||
ret.data << ReadFile( fi.absoluteFilePath() );
|
||||
ret.isFile << true;
|
||||
ret.attr << DEFAULT_SAVE_ATTR_FILE;
|
||||
}
|
||||
else//its a folder, nothing special to do
|
||||
ret.isFile << false;
|
||||
else//its a folder
|
||||
{
|
||||
ret.attr << DEFAULT_SAVE_ATTR_DIR;
|
||||
}
|
||||
}
|
||||
ret.tid = tid;
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -776,7 +896,8 @@ bool NandDump::InstallSave( const SaveGame &save )
|
||||
foreach( QString entry, save.entries )
|
||||
{
|
||||
QString cp = ToNandPath( entry );
|
||||
if( save.isFile.at( entryIdx ) )//this is a file
|
||||
quint8 attr = save.attr.at( entryIdx );
|
||||
if( NAND_ATTR_TYPE( attr ) == NAND_FILE )//this is a file
|
||||
{
|
||||
if( !SaveData( save.data.at( dataIdx++ ), path + cp ) )
|
||||
return false;
|
||||
@ -791,20 +912,3 @@ bool NandDump::InstallSave( const SaveGame &save )
|
||||
return true;
|
||||
}
|
||||
|
||||
bool NandDump::IsValidSave( const SaveGame &save )
|
||||
{
|
||||
if( !save.tid || save.entries.size() != save.isFile.size() )
|
||||
return false;
|
||||
|
||||
quint16 files = 0;
|
||||
quint16 cnt = save.isFile.size();
|
||||
for( quint16 i = 0; i < cnt; i++ )
|
||||
{
|
||||
if( save.isFile.at( i ) )
|
||||
files++;
|
||||
}
|
||||
if( files != save.data.size() )
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -1,19 +1,16 @@
|
||||
#ifndef NANDDUMP_H
|
||||
#define NANDDUMP_H
|
||||
|
||||
#include "nusdownloader.h"
|
||||
#include "includes.h"
|
||||
#include "sharedcontentmap.h"
|
||||
#include "uidmap.h"
|
||||
#include "wad.h"
|
||||
#include "tools.h"
|
||||
|
||||
struct SaveGame//struct to hold save data
|
||||
{
|
||||
quint64 tid; //tid this data belongs to
|
||||
QStringList entries; //paths of all the files & folders
|
||||
QList<bool>isFile; //type of each entry. false = folder, true = file
|
||||
QList<QByteArray> data; //data for each file. size of this list should equal the number of files in the above list
|
||||
};
|
||||
//there is no way to know what attributes the save items were meant to have when reading from an extracted dump
|
||||
//these are just generic attributes that should work for all save data when writing back to a real nand
|
||||
#define DEFAULT_SAVE_ATTR_FILE NAND_ATTR( NAND_FILE, NAND_RW, NAND_RW, 0 )
|
||||
#define DEFAULT_SAVE_ATTR_DIR NAND_ATTR( NAND_DIR, NAND_RW, NAND_RW, 0 )
|
||||
|
||||
//class for handeling an extracted wii nand filesystem
|
||||
//! nothing can be done unless basePath is set. do this either by setting it in the constructor, or by calling SetPath()
|
||||
@ -70,6 +67,10 @@ public:
|
||||
// returns a map of < tid, version >
|
||||
QMap< quint64, quint16 > GetInstalledTitles();
|
||||
|
||||
//get a list of all available saves in this nand
|
||||
// returns <tid, size>
|
||||
QMap< quint64, quint32 > GetSaveList();
|
||||
|
||||
//write the current uid & content.map to the PC
|
||||
//failure to make sure this is done can end up with a broken nand
|
||||
bool Flush();
|
||||
@ -91,6 +92,9 @@ public:
|
||||
// if no save is found, it will return a SaveData object with an empty list of entries
|
||||
SaveGame GetSaveData( quint64 tid );
|
||||
|
||||
//deletes everything in the "data" folder for a title
|
||||
bool DeleteSave( quint64 tid );
|
||||
|
||||
//installs a save to the nand
|
||||
bool InstallSave( const SaveGame &save );
|
||||
|
||||
@ -109,8 +113,8 @@ public:
|
||||
const QString ToNandPath( const QString &path );
|
||||
const QString FromNandPath( const QString &path );
|
||||
|
||||
//sanity check a save object
|
||||
static bool IsValidSave( const SaveGame &save );
|
||||
//get the current basepath
|
||||
const QString BasePath();
|
||||
|
||||
|
||||
|
||||
|
@ -6,6 +6,7 @@
|
||||
|
||||
#include "includes.h"
|
||||
#include "tiktmd.h"
|
||||
#include "tools.h"
|
||||
|
||||
#define SHOPPING_USER_AGENT "Opera/9.00 (Nintendo Wii; U; ; 1038-58; Wii Shop Channel/1.0; en)"
|
||||
#define UPDATING_USER_AGENT "wii libnup/1.0"
|
||||
@ -13,7 +14,7 @@
|
||||
#define WIICONNECT24_USER_AGENT "WiiConnect24/1.0FC4plus1 (build 061114161108)"
|
||||
#define NUS_BASE_URL "http://ccs.shop.wii.com/ccs/download/"
|
||||
|
||||
#define TITLE_LATEST_VERSION 0xffff
|
||||
|
||||
|
||||
enum
|
||||
{
|
||||
@ -21,16 +22,6 @@ enum
|
||||
IDX_TMD
|
||||
};
|
||||
|
||||
//struct used to keep all the data about a NUS request together
|
||||
//when a finished job is returned, the data list will be the TMD, then the ticket, then all the contents
|
||||
struct NusJob
|
||||
{
|
||||
quint64 tid;
|
||||
quint16 version;
|
||||
bool decrypt;
|
||||
QList<QByteArray> data;
|
||||
};
|
||||
|
||||
struct downloadJob
|
||||
{
|
||||
QString tid;
|
||||
@ -63,7 +54,7 @@ public:
|
||||
|
||||
//get a list of titles for a given update
|
||||
//if a title is not available on NUS, a substitute is given instead ( a later version of the same title )
|
||||
//to keep people from bulk DLing and installing and messing something up, any boot2 upudate will NOT be included
|
||||
//to keep people from bulk DLing and installing and messing something up, any boot2 update will NOT be included
|
||||
//in the list, ask for it specifically. IOS35 is added in all updates for use in sneek
|
||||
//lists are created from wiimpersonator logs when available. otherwise they come from examining game update partitions
|
||||
|
||||
|
@ -32,10 +32,10 @@ SaveBanner::SaveBanner( QByteArray stuff )
|
||||
//no clue what this stuff is, dont really need it though
|
||||
//i suspect instructions for animation ? ( VC icons display forwards and backwards in the system menu )
|
||||
//also speed is not always the same
|
||||
//quint32 tmp;
|
||||
//f.read( (char*)&tmp, 4 );
|
||||
//quint32 tmp2;
|
||||
//f.read( (char*)&tmp2, 4 );
|
||||
quint32 tmp;
|
||||
f.read( (char*)&tmp, 4 );
|
||||
quint32 tmp2;
|
||||
f.read( (char*)&tmp2, 4 );
|
||||
f.seek( 0x20 );
|
||||
|
||||
quint16 name[ 0x20 ];
|
||||
@ -255,3 +255,78 @@ static int ConvertRGB5A3ToBitMap(quint8* tplbuf, quint8** bitmapdata, quint32 wi
|
||||
}
|
||||
return outsz;
|
||||
}
|
||||
|
||||
/*
|
||||
" 0 20000" "Data East Arcade Classics " "icons: 4" "banner size: a8a0"
|
||||
" 10 20000" "Paintball 2009 " "icons: 1" "banner size: 72a0"
|
||||
" 0 55570000" "Let's TAP " "icons: 8" "banner size: f0a0" //too slow
|
||||
" 0 57ff0000" "Metroid: Other M " "icons: 8" "banner size: f0a0" //too fast
|
||||
" 0 2aaa0000" "Championship foosball " "icons: 7" "banner size: dea0" //little too slow
|
||||
" 1 aaaa0000" "Blue World " "icons: 8" "banner size: f0a0" //perfect?
|
||||
" 0 55520000" "零-月蝕の仮面- " "icons: 1" "banner size: 72a0"
|
||||
" 0 2e0000" "Punch-Out!! " "icons: 4" "banner size: a8a0" //just a little bit too slow
|
||||
" 0 15550000" "Balls of Fury " "icons: 7" "banner size: dea0" //mine plays to slow
|
||||
" 0 aaaa0000" "The Umbrella Chronicles " "icons: 8" "banner size: f0a0"
|
||||
" 0 20000" "DU SUPER MARIO BROS. Wii " "icons: 1" "banner size: 72a0"
|
||||
" 0 55550000" "Excite Truck " "icons: 8" "banner size: f0a0" //plays too slow
|
||||
" 0 2aa0000" "Guitar Hero III " "icons: 5" "banner size: baa0" //to slow
|
||||
" 0 2aa0000" "Guitar Hero III " "icons: 5" "banner size: baa0"
|
||||
" 0 aa0000" "HOD 2&3 RETURN " "icons: 4" "banner size: a8a0" //static
|
||||
" 10 0" "The House of the Dead " "icons: 1" "banner size: 72a0"
|
||||
" 1 aaaa0000" "Quantum of Solace™ " "icons: 8" "banner size: f0a0" //close to original speed
|
||||
" 10 0" "Trauma Center: Second Opinion " "icons: 1" "banner size: 72a0"
|
||||
" 0 0" "Indiana Pwns, by Team Twiizers " "icons: 1" "banner size: 72a0"
|
||||
" 10 55550000" "Alien Syndrome " "icons: 8" "banner size: f0a0" //should be playing forwards and then reverse 1 or 2 frames and start over?
|
||||
" 10 0" "Prince of Persia " "icons: 1" "banner size: 72a0"
|
||||
" 0 ffff0000" "Mad Dog McCree " "icons: 8" "banner size: f0a0" //plays too fast
|
||||
" 10 30000" "Rubik's World " "icons: 1" "banner size: 72a0"
|
||||
" 1 2000000" "Smash Bros. Brawl " "icons: 1" "banner size: 72a0"
|
||||
" 1 2000000" "大乱闘スマッシュブラザーズX " "icons: 1" "banner size: 72a0"
|
||||
" 1 2000000" "Smash Bros. Brawl " "icons: 1" "banner size: 72a0"
|
||||
" 0 20000" "Wii Sports " "icons: 1" "banner size: 72a0"
|
||||
" 10 aaaa0000" "Downhill Jam " "icons: 8" "banner size: f0a0"//correctish
|
||||
" 1 ffff0000" "Call of Duty: WaW " "icons: 8" "banner size: f0a0" //plays too fast
|
||||
" 10 ff0000" "Tony Hawk: RIDE " "icons: 4" "banner size: a8a0" //appears static
|
||||
" 0 20000" "Link's Training " "icons: 1" "banner size: 72a0"
|
||||
" 0 20000" "Wii Sports Resort " "icons: 1" "banner size: 72a0"
|
||||
" 0 ff0000" "Iron Man™ 2 " "icons: 4" "banner size: a8a0"//too slow
|
||||
" 10 55550000" "Attack of the Movies 3-D " "icons: 8" "banner size: f0a0" //appears static
|
||||
" 0 30000" "SUPER MARIO GALAXY 2 " "icons: 1" "banner size: 72a0"
|
||||
" 1 ffff0000" "Call of Duty: Black Ops " "icons: 8" "banner size: f0a0" //appears static
|
||||
" 0 aaaa0000" "DKC Returns " "icons: 8" "banner size: f0a0"//correct
|
||||
" 0 aaaa0000" "Wheel of Fortune " "icons: 8" "banner size: f0a0"//correct
|
||||
" 0 0" "Scooby-Doo! " "icons: 1" "banner size: 72a0"
|
||||
" 11 aaaa0000" "GoldenEye 007 " "icons: 8" "banner size: f0a0"//correctish
|
||||
" 0 aaaa0000" "Jeopardy! " "icons: 8" "banner size: f0a0"//correctish
|
||||
" 10 0" "All Star Karate " "icons: 1" "banner size: 72a0"
|
||||
" 0 20000" "NewSuperMarioBrosWii " "icons: 1" "banner size: 72a0"
|
||||
" 0 20000" "New SUPER MARIO BROS. Wii " "icons: 1" "banner size: 72a0"
|
||||
" 10 20000" "Cabela's NAA " "icons: 1" "banner size: 72a0"
|
||||
" 10 0" "NBA JAM " "icons: 1" "banner size: 72a0"
|
||||
" 0 30000" "Spider-Man™: SD " "icons: 1" "banner size: 72a0"
|
||||
" 1 ffff0000" "Tetris® Party Deluxe " "icons: 8" "banner size: f0a0"//plays too fast
|
||||
" 0 2aaa0000" "GH World Tour " "icons: 7" "banner size: dea0"
|
||||
" 0 aaa0000" "GH Metallica " "icons: 6" "banner size: cca0"
|
||||
" 0 aaa0000" "GH Smash Hits " "icons: 6" "banner size: cca0"
|
||||
" 0 2aaa0000" "GH™:Warriors of Rock " "icons: 7" "banner size: dea0"
|
||||
" 1 3ff0000" "Rock Band™ 2 " "icons: 5" "banner size: baa0"
|
||||
" 1 3ff0000" "Rock Band™ 3 " "icons: 5" "banner size: baa0"
|
||||
" 1 20000" "Check Mii Out Ch. " "icons: 1" "banner size: 72a0"
|
||||
" 10 ffff0000" "Super Smash Bros. " "icons: 8" "banner size: f0a0" //plays forward, pause, backwards, pause
|
||||
" 0 20000" "Wii Fit " "icons: 1" "banner size: 72a0"
|
||||
" 0 20000" "Wii Fit™ Plus " "icons: 1" "banner size: 72a0"
|
||||
skipping empty image
|
||||
skipping empty image
|
||||
skipping empty image
|
||||
skipping empty image
|
||||
skipping empty image
|
||||
skipping empty image
|
||||
skipping empty image
|
||||
" 1 20000" "Rabbids Go Home " "icons: 8" "banner size: f0a0"
|
||||
" 1 20000" "Mario Kart Wii " "icons: 1" "banner size: 72a0"
|
||||
" 1 20000" "Mario Kart Wii " "icons: 1" "banner size: 72a0"
|
||||
|
||||
|
||||
0x20000 = static even if theres multiple images ( data east arcade )
|
||||
*/
|
||||
|
||||
|
@ -116,6 +116,11 @@ QString SharedContentMap::GetNextEmptyCid()
|
||||
|
||||
void SharedContentMap::AddEntry( const QString &app, const QByteArray &hash )
|
||||
{
|
||||
if( app.size() != 8 || hash.size() != 20 )
|
||||
{
|
||||
qWarning() << "SharedContentMap::AddEntry -> bas size" << hex << app.size() << hash.size();
|
||||
return;
|
||||
}
|
||||
data += app.toAscii() + hash;
|
||||
}
|
||||
|
||||
|
@ -87,7 +87,7 @@ typedef struct _tmd {
|
||||
// C99 flexible array
|
||||
tmd_content contents[];
|
||||
} __attribute__((packed)) tmd;
|
||||
|
||||
/*
|
||||
typedef struct _tmd_view_content
|
||||
{
|
||||
quint32 cid;
|
||||
@ -132,9 +132,7 @@ typedef struct _cert_ecdsa {
|
||||
quint8 s[30];
|
||||
quint8 pad[0x3c];
|
||||
} __attribute__((packed)) cert_ecdsa;
|
||||
|
||||
#define COMMON_KEY {0xeb, 0xe4, 0x2a, 0x22, 0x5e, 0x85, 0x93, 0xe4, 0x48, 0xd9, 0xc5, 0x45, 0x73, 0x81, 0xaa, 0xf7}
|
||||
|
||||
*/
|
||||
//just a quick class to try to keep the rest of the code from getting full of the same shit over and over
|
||||
class Ticket
|
||||
{
|
||||
|
@ -83,7 +83,7 @@ void hexdump12( const QByteArray &d, int from, int len )
|
||||
|
||||
QByteArray PaddedByteArray( const QByteArray &orig, quint32 padTo )
|
||||
{
|
||||
QByteArray padding( RU( padTo, orig.size() ) - orig.size(), '\0' );
|
||||
QByteArray padding( RU( orig.size(), padTo ) - orig.size(), '\0' );
|
||||
//qDebug() << "padding with" << hex << RU( padTo, orig.size() ) << "bytes" <<
|
||||
return orig + padding;
|
||||
}
|
||||
@ -171,6 +171,87 @@ bool WriteFile( const QString &path, const QByteArray &ba )
|
||||
return true;
|
||||
}
|
||||
|
||||
bool IsValidSave( const SaveGame &save )
|
||||
{
|
||||
if( !save.tid || save.entries.size() != save.attr.size() )
|
||||
{
|
||||
qWarning() << "IsValidSave :bad sizes";
|
||||
return false;
|
||||
}
|
||||
if( !save.entries.contains( "/banner.bin" ) )
|
||||
{
|
||||
qWarning() << "IsValidSave :save doesnt contain a banner.bin" << save.entries;
|
||||
return false;
|
||||
}
|
||||
|
||||
quint16 files = 0;
|
||||
quint16 cnt = save.entries.size();
|
||||
for( quint16 i = 0; i < cnt; i++ )
|
||||
{
|
||||
if( save.entries.at( i ).size() > 52 )
|
||||
{
|
||||
qWarning() << "IsValidSave :name is too long" << i << save.entries.at( i );
|
||||
return false;
|
||||
}
|
||||
quint8 attr = save.attr.at( i );
|
||||
if( NAND_ATTR_TYPE( attr ) == NAND_FILE )
|
||||
{
|
||||
files++;
|
||||
}
|
||||
else if( NAND_ATTR_TYPE( attr ) == NAND_DIR )
|
||||
{
|
||||
}
|
||||
else //unknown attribute
|
||||
{
|
||||
qWarning() << "IsValidSave :unknown attribute" << i << hex << attr << NAND_ATTR_TYPE( attr );
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
if( files != save.data.size() )
|
||||
{
|
||||
qWarning() << "IsValidSave :files != data.size()";
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
const QByteArray DataFromSave( const SaveGame &save, const QString &name )
|
||||
{
|
||||
if( !save.tid || save.entries.size() != save.attr.size() )
|
||||
return QByteArray();
|
||||
|
||||
quint16 idx = 0;
|
||||
quint16 cnt = save.entries.size();
|
||||
for( quint16 i = 0; i < cnt; i++ )
|
||||
{
|
||||
quint8 attr = save.attr.at( i );
|
||||
if( NAND_ATTR_TYPE( attr ) == NAND_FILE )
|
||||
{
|
||||
if( save.entries.at( i ) == name )
|
||||
return save.data.at( idx );
|
||||
|
||||
idx++;
|
||||
}
|
||||
}
|
||||
return QByteArray();
|
||||
}
|
||||
|
||||
quint8 AttrFromSave( const SaveGame &save, const QString &name )
|
||||
{
|
||||
if( !save.tid || save.entries.size() != save.attr.size() )
|
||||
return 0;
|
||||
|
||||
quint16 cnt = save.entries.size();
|
||||
for( quint16 i = 0; i < cnt; i++ )
|
||||
{
|
||||
if( save.entries.at( i ) == name )
|
||||
return save.attr.at( i );
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
#define CERTS_DAT_SIZE 2560
|
||||
const quint8 certs_dat[ CERTS_DAT_SIZE ] = {
|
||||
0x00, 0x01, 0x00, 0x01, 0x7D, 0x9D, 0x5E, 0xBA, 0x52, 0x81, 0xDC, 0xA7, 0x06, 0x5D, 0x2F, 0x08,
|
||||
|
@ -8,6 +8,44 @@
|
||||
#define MIN( x, y ) ( ( x ) < ( y ) ? ( x ) : ( y ) )
|
||||
#define MAX( x, y ) ( ( x ) > ( y ) ? ( x ) : ( y ) )
|
||||
|
||||
#define NAND_FILE 1
|
||||
#define NAND_DIR 2
|
||||
#define NAND_READ 1
|
||||
#define NAND_WRITE 2
|
||||
#define NAND_RW ( NAND_READ | NAND_WRITE )
|
||||
|
||||
#define NAND_ATTR( type, user, group, other ) ( ( quint8 )( ( type & 3 ) | ( ( user & 3 ) << 6 ) | ( ( group & 3 ) << 4 ) | ( ( other & 3 ) << 2 ) ) )
|
||||
#define NAND_ATTR_TYPE( attr ) ( attr & 3 )
|
||||
#define NAND_ATTR_USER( attr ) ( ( attr >> 6 ) & 3 )
|
||||
#define NAND_ATTR_GROUP( attr ) ( ( attr >> 4 ) & 3 )
|
||||
#define NAND_ATTR_OTHER( attr ) ( ( attr >> 2 ) & 3 )
|
||||
|
||||
#define COMMON_KEY { 0xeb, 0xe4, 0x2a, 0x22, 0x5e, 0x85, 0x93, 0xe4, 0x48, 0xd9, 0xc5, 0x45, 0x73, 0x81, 0xaa, 0xf7 }
|
||||
|
||||
#define SD_KEY { 0xab, 0x01, 0xb9, 0xd8, 0xe1, 0x62, 0x2b, 0x08, 0xaf, 0xba, 0xd8, 0x4d, 0xbf, 0xc2, 0xa5, 0x5d };
|
||||
#define SD_IV { 0x21, 0x67, 0x12, 0xe6, 0xaa, 0x1f, 0x68, 0x9f, 0x95, 0xc5, 0xa2, 0x23, 0x24, 0xdc, 0x6a, 0x98 };
|
||||
#define MD5_BLANKER { 0x0e, 0x65, 0x37, 0x81, 0x99, 0xbe, 0x45, 0x17, 0xab, 0x06, 0xec, 0x22, 0x45, 0x1a, 0x57, 0x93 };
|
||||
|
||||
|
||||
#define TITLE_LATEST_VERSION 0xffff
|
||||
//struct used to keep all the data about a NUS request together
|
||||
//when a finished job is returned, the data list will be the TMD, then the ticket, then all the contents
|
||||
struct NusJob
|
||||
{
|
||||
quint64 tid;
|
||||
quint16 version;
|
||||
bool decrypt;
|
||||
QList<QByteArray> data;
|
||||
};
|
||||
|
||||
struct SaveGame//struct to hold save data
|
||||
{
|
||||
quint64 tid; //tid this data belongs to
|
||||
QStringList entries; //paths of all the files & folders
|
||||
QList<quint8>attr; //attributes for each file & folder in the save
|
||||
QList<QByteArray> data; //data for each file. size of this list should equal the number of files in the above list
|
||||
};
|
||||
|
||||
char ascii( char s );
|
||||
void hexdump( const void *d, int len );
|
||||
void hexdump( const QByteArray &d, int from = 0, int len = -1 );
|
||||
@ -22,6 +60,10 @@ QByteArray AesEncrypt( quint16 index, const QByteArray &source );
|
||||
|
||||
QByteArray GetSha1( const QByteArray &stuff );
|
||||
|
||||
bool IsValidSave( const SaveGame &save );
|
||||
const QByteArray DataFromSave( const SaveGame &save, const QString &name );
|
||||
quint8 AttrFromSave( const SaveGame &save, const QString &name );
|
||||
|
||||
//get a padded version of the given buffer
|
||||
QByteArray PaddedByteArray( const QByteArray &orig, quint32 padTo );
|
||||
|
||||
|
@ -2,8 +2,6 @@
|
||||
#define NANDWINDOW_H
|
||||
|
||||
#include "../WiiQt/includes.h"
|
||||
//#include "../WiiQt/nandbin.h"
|
||||
|
||||
#include "nandthread.h"
|
||||
|
||||
namespace Ui {
|
||||
@ -33,10 +31,6 @@ private:
|
||||
|
||||
QGraphicsTextItem *nandSize; //pointers to the items to show info under the blockmap
|
||||
QGraphicsTextItem *fileSize;
|
||||
/*QGraphicsTextItem *badText;
|
||||
QGraphicsTextItem *freeText;
|
||||
QGraphicsTextItem *usedText;
|
||||
QGraphicsTextItem *resText;*/
|
||||
|
||||
QList<quint16> blocks; //hold a list of what the blocks in the nand are used for
|
||||
void GetBlocksfromNand();
|
||||
|
@ -328,9 +328,11 @@ void MainWindow::on_actionImportWad_triggered()
|
||||
ShowMessage( tr( "<b>Error setting the basepath of the nand to %1</b>" ).arg( QFileInfo( ui->lineEdit_nandPath->text() ).absoluteFilePath() ) );
|
||||
return;
|
||||
}
|
||||
QString path = ui->lineEdit_wad->text().isEmpty() ?
|
||||
QCoreApplication::applicationDirPath() : ui->lineEdit_wad->text();
|
||||
QString fn = QFileDialog::getOpenFileName( this,
|
||||
tr("Wad files(*.wad)"),
|
||||
QCoreApplication::applicationDirPath(),
|
||||
path,
|
||||
tr("WadFiles (*.wad)"));
|
||||
if(fn == "") return;
|
||||
|
||||
|
@ -1,30 +1,53 @@
|
||||
#include "mainwindow.h"
|
||||
#include "ui_mainwindow.h"
|
||||
#include "tools.h"
|
||||
#include "savebanner.h"
|
||||
#include "ngdialog.h"
|
||||
#include "textdialog.h"
|
||||
|
||||
#include "../WiiQt/tools.h"
|
||||
#include "../WiiQt/savebanner.h"
|
||||
#include "../WiiQt/savedatabin.h"
|
||||
|
||||
#include "quazip.h"
|
||||
#include "quazipfile.h"
|
||||
|
||||
//TODO... get these from settings and dont use global variables
|
||||
static QString pcPath = "./saveBackups";
|
||||
static QString sneekPath = "/media/SDHC_4GB";
|
||||
//static QString sneekPath = "/media/SDHC_4GB";
|
||||
static QString sneekPath = "/home/j/c/QtWii/test";
|
||||
|
||||
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow), bannerthread( this )
|
||||
{
|
||||
ui->setupUi(this);
|
||||
progressBar.setVisible( false );
|
||||
ui->statusBar->addPermanentWidget( &progressBar, 0 );
|
||||
ngID = 0;
|
||||
ngKeyID = 0;
|
||||
|
||||
//sneekIconTimer.setInterval( 150 );//delay of icon image animation
|
||||
|
||||
connect( &bannerthread, SIGNAL( SendProgress( int ) ), this, SLOT( GetProgressUpdate( int ) ) );
|
||||
connect( &bannerthread, SIGNAL( SendDone( int ) ), this, SLOT( LoadThreadIsDone( int ) ) );
|
||||
connect( &bannerthread, SIGNAL( SendItem( QByteArray, const QString&, int, int ) ), this, SLOT( ReceiveSaveItem( QByteArray, const QString&, int, int ) ) );
|
||||
connect( &bannerthread, SIGNAL( SendSneekItem( QByteArray, const QString&, int ) ), this, SLOT( ReceiveSneekBanner( QByteArray, const QString&, int ) ) );
|
||||
connect( &bannerthread, SIGNAL( SendPcItem( PcSaveInfo ) ), this, SLOT( ReceivePcItem( PcSaveInfo ) ) );
|
||||
|
||||
connect( &sneekIconTimer, SIGNAL( timeout() ), this, SLOT( ShowNextSneekIcon() ) );
|
||||
connect( &pcIconTimer, SIGNAL( timeout() ), this, SLOT( ShowNextPcIcon() ) );
|
||||
|
||||
|
||||
|
||||
pcPath = "./saveBackups";
|
||||
//GetSavesFromSneek( "/media/WiiFat500" );
|
||||
GetSavesFromSneek( sneekPath );
|
||||
GetSavesFromPC( pcPath );
|
||||
|
||||
ngID = 0x4324c84;
|
||||
ngKeyID = 0x6aedb6ed;
|
||||
ngMac = QByteArray::fromHex( "0017abd2f253" );
|
||||
ngPriv = QByteArray::fromHex( "00633682060dc10f5e8ec41907745f6380b67f8ad11019caf21a3ea242d2" );
|
||||
ngSig = QByteArray::fromHex( "0015097c4e17ad791aa971221e07a0a2d9c97c6e2885fc7bf624e564c34100dd18568f683aa6f4f5a984842ddb002ef87724594975d0d43a0ecff81d" );
|
||||
|
||||
//QMessageBox::aboutQt( this, "bla" );
|
||||
|
||||
//QString bla = GetSaveName( 0x1000112345678ull );
|
||||
//qDebug() << "bla" << bla;
|
||||
|
||||
}
|
||||
|
||||
MainWindow::~MainWindow()
|
||||
@ -35,12 +58,56 @@ MainWindow::~MainWindow()
|
||||
//get the saves from a nand directory
|
||||
void MainWindow::GetSavesFromSneek( const QString &path )
|
||||
{
|
||||
if( !QFileInfo( path ).exists() )
|
||||
return;
|
||||
|
||||
if( bannerthread.isRunning() )
|
||||
{
|
||||
ui->statusBar->showMessage( tr( "Wait for the current job to finish" ) );
|
||||
return;
|
||||
}
|
||||
sneekPath = path;
|
||||
ui->listWidget_sneekSaves->clear();
|
||||
progressBar.setValue( 0 );
|
||||
progressBar.setVisible( true );
|
||||
bannerthread.GetBanners( path, LOAD_SNEEK );
|
||||
if( !bannerthread.SetNandPath( path ) )
|
||||
{
|
||||
qWarning() << "MainWindow::GetSavesFromSneek -> error sotteng path" << path;
|
||||
return;
|
||||
}
|
||||
bannerthread.GetBanners();
|
||||
}
|
||||
|
||||
void MainWindow::GetSavesFromPC( const QString &path )
|
||||
{
|
||||
pcPath = path;
|
||||
if( !QFileInfo( path ).exists() )
|
||||
return;
|
||||
|
||||
if( bannerthread.isRunning() )
|
||||
{
|
||||
ui->statusBar->showMessage( tr( "Wait for the current job to finish" ) );
|
||||
return;
|
||||
}
|
||||
//remove all currently loaded saves
|
||||
ui->listWidget_pcSaves->clear();
|
||||
pcInfos.clear();
|
||||
progressBar.setValue( 0 );
|
||||
progressBar.setVisible( true );
|
||||
bannerthread.GetBanners( pcPath );
|
||||
}
|
||||
void MainWindow::ReceivePcItem( PcSaveInfo info )
|
||||
{
|
||||
//qDebug() << "received a pc save";
|
||||
if( !info.sizes.size() || info.sizes.size() != info.descriptions.size() || info.sizes.size() != info.paths.size() )//invalid
|
||||
return;
|
||||
SaveBanner sb( info.banner );
|
||||
new SaveListItem( sb, info.tid, 0, ui->listWidget_pcSaves );
|
||||
//ui->listWidget_sneekSaves->addItem( item );
|
||||
//descMap.insert( tid, descriptions );
|
||||
pcInfos << info;
|
||||
}
|
||||
|
||||
/*
|
||||
//sneek save clicked
|
||||
void MainWindow::on_listWidget_sneekSaves_itemClicked(QListWidgetItem* item)
|
||||
@ -74,23 +141,12 @@ void MainWindow::on_listWidget_sneekSaves_currentItemChanged(QListWidgetItem* cu
|
||||
}
|
||||
|
||||
//get an item from the thread loading all the data and turn it into a banner
|
||||
void MainWindow::ReceiveSaveItem( QByteArray stuff, const QString& tid, int type, int size )
|
||||
{
|
||||
switch( type )
|
||||
{
|
||||
case LOAD_SNEEK:
|
||||
void MainWindow::ReceiveSneekBanner( QByteArray stuff, const QString& tid, int size )
|
||||
{
|
||||
QByteArray copy = stuff;
|
||||
SaveBanner sb( copy );
|
||||
SaveListItem *item = new SaveListItem( sb, tid, size, ui->listWidget_sneekSaves );
|
||||
ui->listWidget_sneekSaves->addItem( item );
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
new SaveListItem( sb, tid, size, ui->listWidget_sneekSaves );
|
||||
//ui->listWidget_sneekSaves->addItem( item );
|
||||
}
|
||||
|
||||
//get a pregress update from something that is doing work
|
||||
@ -183,3 +239,438 @@ void MainWindow::ShowNextSneekIcon()
|
||||
|
||||
ui->label_sneek_icon->setPixmap( sneekIcon.at( currentSneekIcon ) );
|
||||
}
|
||||
|
||||
void MainWindow::ShowNextPcIcon()
|
||||
{
|
||||
if( ++currentPcIcon >= pcIcon.size() )
|
||||
currentPcIcon = 0;
|
||||
|
||||
ui->label_PC_icon->setPixmap( pcIcon.at( currentPcIcon ) );
|
||||
}
|
||||
|
||||
//clicked button to delete save from sneek
|
||||
void MainWindow::on_pushButton_sneekDelete_clicked()
|
||||
{
|
||||
QList<QListWidgetItem*>selected = ui->listWidget_sneekSaves->selectedItems();
|
||||
quint16 cnt = selected.size();
|
||||
if( !cnt )
|
||||
return;
|
||||
|
||||
if( QMessageBox::question( this, tr( "Are you sure?" ), \
|
||||
tr( "You are about to delete %1 %2 from the SNEEK nand" ).arg( cnt )\
|
||||
.arg( cnt == 1 ? tr( "save" ) : tr( "saves" ) ),
|
||||
QMessageBox::Ok | QMessageBox::Cancel, QMessageBox::Cancel ) != QMessageBox::Ok )
|
||||
return;
|
||||
|
||||
quint16 del = 0;
|
||||
for( quint16 i = 0; i < cnt; i++ )
|
||||
{
|
||||
QListWidgetItem* item = selected.takeFirst();
|
||||
SaveListItem *si = static_cast< SaveListItem * >( item );
|
||||
if( !si )
|
||||
{
|
||||
qDebug() << "MainWindow::on_pushButton_sneekDelete_clicked() -> error casting" << item->text();
|
||||
delete item;
|
||||
continue;
|
||||
}
|
||||
|
||||
bool ok = false;
|
||||
quint64 tid = si->Tid().toLongLong( &ok, 16 );
|
||||
if( !ok )
|
||||
{
|
||||
qDebug() << "MainWindow::on_pushButton_sneekDelete_clicked() -> error converting" << si->Tid() << "to int";
|
||||
delete item;
|
||||
continue;
|
||||
}
|
||||
delete item;
|
||||
if( !bannerthread.DeleteSaveFromSneekNand( tid ) )
|
||||
qDebug() << "MainWindow::on_pushButton_sneekDelete_clicked() -> error deleting" << tid;
|
||||
|
||||
else
|
||||
del++;
|
||||
|
||||
}
|
||||
|
||||
ui->statusBar->showMessage( tr( "Deleted %1 of %2 saves" ).arg( del ).arg( cnt ), 5000 );
|
||||
}
|
||||
|
||||
QString MainWindow::GetSaveName( quint64 tid )
|
||||
{
|
||||
if( pcPath.isEmpty() )
|
||||
return QString();
|
||||
|
||||
QString tidStr = QString( "%1" ).arg( tid, 16, 16, QChar( '0' ) );
|
||||
tidStr.insert( 8, "/" );
|
||||
|
||||
QString parent = pcPath + "/" + tidStr;
|
||||
QFileInfo fi( parent );
|
||||
if( fi.exists() && fi.isFile() )
|
||||
{
|
||||
qWarning() << "MainWindow::GetSaveName ->" << fi.absoluteFilePath() << "is a file";
|
||||
return QString();
|
||||
}
|
||||
if( !fi.exists() && !QDir().mkpath( fi.absoluteFilePath() ) )
|
||||
{
|
||||
qWarning() << "MainWindow::GetSaveName -> error creating" << fi.absoluteFilePath();
|
||||
return QString();
|
||||
}
|
||||
quint32 i = 1;
|
||||
QString name = QString( "1.zip" );
|
||||
QDir dir( fi.absoluteFilePath() );
|
||||
while( dir.exists( name ) )
|
||||
{
|
||||
name = QString( "%1.zip" ).arg( ++i );
|
||||
}
|
||||
return fi.absoluteFilePath() + "/" + name;
|
||||
}
|
||||
|
||||
//quick sanity checks on the NG stuff
|
||||
bool MainWindow::NG_Ok()
|
||||
{
|
||||
return ( ngID && ngKeyID && ngSig.size() == 60 && ngMac.size() == 6 && ngPriv.size() == 30 );
|
||||
}
|
||||
|
||||
//button to extract a save from sneek clicked
|
||||
void MainWindow::on_pushButton_sneekExtract_clicked()
|
||||
{
|
||||
|
||||
QList<QListWidgetItem*>selected = ui->listWidget_sneekSaves->selectedItems();
|
||||
quint16 cnt = selected.size();
|
||||
if( !cnt )
|
||||
{
|
||||
ui->statusBar->showMessage( tr( "No saves are selected to extract" ) );
|
||||
return;
|
||||
}
|
||||
if( !NG_Ok() )
|
||||
{
|
||||
on_actionSet_NG_Keys_triggered();
|
||||
if( !NG_Ok() )
|
||||
{
|
||||
qDebug() << "invalid keys. can't create data.bins";
|
||||
ui->statusBar->showMessage( tr( "I Need valid keys to extract saves" ) );
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
bool promptForDetails = true;
|
||||
//keep from prompting for details for multiple saves
|
||||
if( cnt > 1 && QMessageBox::question( this, tr( "Enter Details?" ), \
|
||||
tr( "You are about to extract %1 saves from the SNEEK nand.<br>Do you want to enter details for each of them?" )
|
||||
.arg( cnt ), QMessageBox::No | QMessageBox::Yes, QMessageBox::No ) == QMessageBox::No )
|
||||
promptForDetails = false;
|
||||
|
||||
quint16 done = 0;
|
||||
for( quint16 i = 0; i < cnt; i++ )
|
||||
{
|
||||
QListWidgetItem* item = selected.at( i );
|
||||
SaveListItem *si = static_cast< SaveListItem * >( item );
|
||||
if( !si )
|
||||
{
|
||||
qDebug() << "MainWindow::on_pushButton_sneekExtract_clicked() -> error casting" << item->text();
|
||||
delete item;
|
||||
continue;
|
||||
}
|
||||
|
||||
bool ok = false;
|
||||
quint64 tid = si->Tid().toLongLong( &ok, 16 );
|
||||
if( !ok )
|
||||
{
|
||||
qDebug() << "MainWindow::on_pushButton_sneekExtract_clicked() -> error converting" << si->Tid() << "to int";
|
||||
continue;
|
||||
}
|
||||
|
||||
//get a save destination
|
||||
QString fn = GetSaveName( tid );
|
||||
if( fn.isEmpty() )
|
||||
continue;
|
||||
|
||||
//extract the save
|
||||
SaveGame sg = bannerthread.GetSave( tid );
|
||||
if( !IsValidSave( sg ) )
|
||||
{
|
||||
ui->statusBar->showMessage( tr( "Error extracting save for %1").arg( tid, 16, 16, QChar( '0' ) ) );
|
||||
qDebug() << "MainWindow::on_pushButton_sneekExtract_clicked() -> invalid save" << QString( "%1" ).arg( tid, 16, 16, QChar( '0' ) );
|
||||
continue;
|
||||
}
|
||||
|
||||
//convert to data.bin
|
||||
QByteArray ba = SaveDataBin::DataBinFromSaveStruct( sg, ngPriv, ngSig, ngMac, ngID, ngKeyID );
|
||||
if( ba.isEmpty() )
|
||||
{
|
||||
ui->statusBar->showMessage( tr( "Error encoding save for %1").arg( tid, 16, 16, QChar( '0' ) ) );
|
||||
qDebug() << "MainWindow::on_pushButton_sneekExtract_clicked() -> error converting" << QString( "%1" ).arg( tid, 16, 16, QChar( '0' ) );
|
||||
continue;
|
||||
}
|
||||
|
||||
QString fullDesc = QString( "SaveInfo\nversion=%1\ntid=%2\n" ).arg( DESC_VERSION ).arg( tid, 16, 16, QChar( '0' ) );
|
||||
QDate date = QDate::currentDate();
|
||||
QTime time = QTime::currentTime();
|
||||
QString desc = QString( "title=%1\ndate=%2\ntime=%3\n" ).arg( si->Banner()->Title() ).arg( date.toString() ).arg( time.toString() );
|
||||
|
||||
if( promptForDetails )
|
||||
{
|
||||
fullDesc += "desc=\n" + TextDialog::GetText( this, desc ) + "\nend_desc\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
fullDesc += "desc=\n" + desc + "\nend_desc\n";
|
||||
}
|
||||
//qDebug() << "description:\n" << fullDesc;
|
||||
|
||||
//write to file
|
||||
if( !WriteZipFile( ba, fullDesc.toLatin1(), fn ) )
|
||||
{
|
||||
ui->statusBar->showMessage( tr( "Error writing save for %1").arg( tid, 16, 16, QChar( '0' ) ) );
|
||||
qDebug() << "MainWindow::on_pushButton_sneekExtract_clicked() -> error writing" << QString( "%1" ).arg( tid, 16, 16, QChar( '0' ) );
|
||||
continue;
|
||||
}
|
||||
//item extracted ok, now add the info to the tab displaying the PC
|
||||
SaveBanner banner = *si->Banner();
|
||||
AddNewPCSave( fullDesc, si->Tid(), si->Size(), fn, banner );
|
||||
done++;
|
||||
|
||||
}
|
||||
|
||||
ui->statusBar->showMessage( tr( "Extracted %1 of %2 saves" ).arg( done ).arg( cnt ), 5000 );
|
||||
}
|
||||
|
||||
void MainWindow::AddNewPCSave( const QString &desc, const QString &tid, quint32 size, const QString &path, SaveBanner banner )
|
||||
{
|
||||
//look to see if there is already some pc saves from the same game
|
||||
quint32 cnt = pcInfos.size();
|
||||
for( quint32 i = 0; i < cnt; i++ )
|
||||
{
|
||||
if( tid == pcInfos.at( i ).tid )
|
||||
{
|
||||
PcSaveInfo info = pcInfos.at( i );
|
||||
info.sizes << size;
|
||||
info.descriptions << desc;
|
||||
info.paths << path;
|
||||
|
||||
pcInfos.replace( i, info );
|
||||
return;
|
||||
}
|
||||
}
|
||||
//not found, create a new one
|
||||
PcSaveInfo info;
|
||||
info.tid = tid;
|
||||
info.sizes << size;
|
||||
info.descriptions << desc;
|
||||
info.paths << path;
|
||||
|
||||
pcInfos << info;
|
||||
new SaveListItem( banner, tid, 0, ui->listWidget_pcSaves );
|
||||
}
|
||||
|
||||
//try to write a zip file with a data.bin and a descriptive text file
|
||||
bool MainWindow::WriteZipFile( const QByteArray &dataBin, const QByteArray &desc, const QString &path )
|
||||
{
|
||||
qDebug() << "MainWindow::WriteZipFile" << path;
|
||||
QuaZip zip( path );
|
||||
if( !zip.open(QuaZip::mdCreate ) )
|
||||
{
|
||||
qWarning( "error creating zip file: %d", zip.getZipError() );
|
||||
return false;
|
||||
}
|
||||
zip.setComment( "Created with giantpune's saveToy" );
|
||||
QuaZipFile outFile( &zip );
|
||||
for( quint8 i = 0; i < 2; i++ )
|
||||
{
|
||||
QString fn;
|
||||
QByteArray stuff;
|
||||
if( i == 0 )
|
||||
{
|
||||
stuff = dataBin;
|
||||
fn = "data.bin";
|
||||
}
|
||||
else
|
||||
{
|
||||
stuff = desc;
|
||||
fn = "info.txt";
|
||||
}
|
||||
|
||||
if( !outFile.open( QIODevice::WriteOnly, QuaZipNewInfo( fn, fn ) ) )
|
||||
{
|
||||
qWarning("MainWindow::WriteZipFile: outFile.open(): %d", outFile.getZipError() );
|
||||
goto error;
|
||||
}
|
||||
if( outFile.write( stuff ) != stuff.size() )
|
||||
{
|
||||
qWarning() << "MainWindow::WriteZipFile: wrong size written to zip file";
|
||||
goto error;
|
||||
}
|
||||
outFile.close();
|
||||
if( outFile.getZipError() !=UNZ_OK )
|
||||
{
|
||||
qWarning("MainWindow::WriteZipFile: outFile.close(): %d", outFile.getZipError() );
|
||||
goto error;
|
||||
}
|
||||
}
|
||||
zip.close();
|
||||
if( zip.getZipError() != 0 )
|
||||
{
|
||||
qWarning("MainWindow::WriteZipFile: zip.close(): %d", zip.getZipError());
|
||||
goto error;
|
||||
}
|
||||
return true;
|
||||
|
||||
error:
|
||||
zip.close();
|
||||
if( QFile::exists( path ) )
|
||||
QFile::remove( path );
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
//tools -> set ng keys
|
||||
void MainWindow::on_actionSet_NG_Keys_triggered()
|
||||
{
|
||||
qDebug() << hex << ngID;
|
||||
NgDialog d( this );
|
||||
|
||||
d.ngID = ngID;
|
||||
d.ngKeyID = ngKeyID;
|
||||
d.ngMac = ngMac;
|
||||
d.ngPriv = ngPriv;
|
||||
d.ngSig = ngSig;
|
||||
|
||||
if( !d.exec() )
|
||||
{
|
||||
//qDebug() << "not accepted";
|
||||
return;
|
||||
}
|
||||
ngID = d.ngID;
|
||||
ngKeyID = d.ngKeyID;
|
||||
ngMac = d.ngMac;
|
||||
ngPriv = d.ngPriv;
|
||||
ngSig = d.ngSig;
|
||||
/*qDebug() << "accepted";
|
||||
qDebug() << hex << d.ngID
|
||||
<< "\n" << d.ngKeyID
|
||||
<< "\n" << d.ngMac.toHex()
|
||||
<< "\n" << d.ngPriv.toHex()
|
||||
<< "\n" << d.ngSig.toHex();*/
|
||||
}
|
||||
|
||||
//PC list item changed
|
||||
void MainWindow::on_listWidget_pcSaves_currentItemChanged( QListWidgetItem* current, QListWidgetItem* previous )
|
||||
{
|
||||
Q_UNUSED( previous );
|
||||
if( !current )
|
||||
return;
|
||||
|
||||
SaveListItem *i = static_cast< SaveListItem * >( current );
|
||||
|
||||
ShowPCSaveDetails( i );
|
||||
}
|
||||
|
||||
//show detials for a save backed up on the PC
|
||||
void MainWindow::ShowPCSaveDetails( SaveListItem *item )
|
||||
{
|
||||
qDebug() << "MainWindow::ShowPCSaveDetails";
|
||||
pcIconTimer.stop();
|
||||
currentPcIcon = 0;
|
||||
pcIcon.clear();
|
||||
ui->comboBox_pcSelect->clear();
|
||||
//find the item in the list of infos that matches this item
|
||||
currentPcSave = 0xffffffff;
|
||||
quint32 cnt = pcInfos.size();
|
||||
for( quint32 i = 0; i < cnt; i++ )
|
||||
{
|
||||
if( item->Tid() == pcInfos.at( i ).tid )
|
||||
{
|
||||
currentPcSave = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if( currentPcSave == 0xffffffff )
|
||||
{
|
||||
qWarning() << "MainWindow::ShowPCSaveDetails -> tid not found";
|
||||
return;
|
||||
}
|
||||
|
||||
SaveBanner *sb = item->Banner();
|
||||
|
||||
ui->label_pc_title->setText( sb->Title() );
|
||||
|
||||
if( !sb->SubTitle().isEmpty() && sb->Title() != sb->SubTitle() )
|
||||
ui->label_pc_title2->setText( sb->SubTitle() );
|
||||
else
|
||||
ui->label_pc_title2->clear();
|
||||
|
||||
QString tid = item->Tid();
|
||||
tid.insert( 8, "/" );
|
||||
tid.prepend( "/" );
|
||||
//ui->label_sneek_path->setText( tid );
|
||||
|
||||
QString id;
|
||||
tid = item->Tid().right( 8 );
|
||||
quint32 num = qFromBigEndian( (quint32) tid.toInt( NULL, 16 ) );
|
||||
for( int i = 0; i < 4; i++ )
|
||||
id += ascii( (char)( num >> ( 8 * i ) ) & 0xff );
|
||||
|
||||
ui->label_pc_id->setText( id );
|
||||
|
||||
foreach( QImage im, sb->IconImgs() )
|
||||
pcIcon << QPixmap::fromImage( im );
|
||||
|
||||
currentPcIcon = 0;
|
||||
ui->label_PC_icon->setPixmap( pcIcon.at( 0 ) );
|
||||
if( pcIcon.size() > 1 )
|
||||
{
|
||||
pcIconTimer.setInterval( 1000 / pcIcon.size() );//delay of icon image animation
|
||||
pcIconTimer.start();
|
||||
}
|
||||
|
||||
//add combobox entries for each of the different saves for this game
|
||||
cnt = pcInfos.at( currentPcSave ).sizes.size();
|
||||
for( quint32 i = 0; i < cnt; i++ )
|
||||
{
|
||||
QString version = pcInfos.at( currentPcSave ).paths.at( i );
|
||||
version.remove( 0, version.lastIndexOf( "/" ) + 1 );
|
||||
ui->comboBox_pcSelect->addItem( version );
|
||||
}
|
||||
}
|
||||
|
||||
//pc combobox index changed
|
||||
void MainWindow::on_comboBox_pcSelect_currentIndexChanged( int index )
|
||||
{
|
||||
qDebug() << "MainWindow::on_comboBox_pcSelect_currentIndexChanged" << index;
|
||||
if( index < 0 )
|
||||
return;
|
||||
ui->plainTextEdit_pcDesc->clear();
|
||||
if( currentPcSave >= (quint32)pcInfos.size() || index >= pcInfos.at( currentPcSave ).sizes.size() )
|
||||
{
|
||||
qWarning() << "MainWindow::on_comboBox_pc_date_currentIndexChanged -> index is out of range";
|
||||
return;
|
||||
}
|
||||
|
||||
int size = pcInfos.at( currentPcSave ).sizes.at( index );
|
||||
QString sizeStr;
|
||||
if( size < 0x400 )
|
||||
sizeStr = tr( "%1 B" ).arg( size, 3 );
|
||||
else if( size < 0x100000 )
|
||||
{
|
||||
float kib = (float)size / 1024.00f;
|
||||
sizeStr = tr( "%1 KiB" ).arg( kib, 3, 'f', 2 );
|
||||
}
|
||||
else//assume there wont be any 1GB saves
|
||||
{
|
||||
float mib = (float)size / 1048576.00f;
|
||||
sizeStr = tr( "%1 MiB" ).arg( mib, 3, 'f', 2 );
|
||||
}
|
||||
int blocks = RU( 0x20000, size) / 0x20000;
|
||||
QString si = QString( "%1 %2 (%3)").arg( blocks ).arg( blocks == 1 ? tr( "Block" ) : tr( "Blocks" ) ).arg( sizeStr );
|
||||
|
||||
ui->label_pc_size->setText( si );
|
||||
QString path = pcInfos.at( currentPcSave ).paths.at( index );
|
||||
if( path.size() >= 30 )
|
||||
{
|
||||
path = path.right( 27 );
|
||||
path.prepend( "..." );
|
||||
}
|
||||
ui->label_pc_path->setText( path );
|
||||
ui->plainTextEdit_pcDesc->clear();
|
||||
ui->plainTextEdit_pcDesc->insertPlainText( pcInfos.at( currentPcSave ).descriptions.at( index ) );
|
||||
}
|
||||
|
@ -3,8 +3,8 @@
|
||||
|
||||
#include "saveloadthread.h"
|
||||
#include "savelistitem.h"
|
||||
#include "savebanner.h"
|
||||
#include "includes.h"
|
||||
#include "../WiiQt/savebanner.h"
|
||||
#include "../WiiQt/includes.h"
|
||||
|
||||
namespace Ui {
|
||||
class MainWindow;
|
||||
@ -22,27 +22,59 @@ private:
|
||||
Ui::MainWindow *ui;
|
||||
QProgressBar progressBar;
|
||||
void GetSavesFromSneek( const QString &path );
|
||||
void GetSavesFromPC( const QString &path );
|
||||
|
||||
SaveLoadThread bannerthread;
|
||||
|
||||
//void ShowSneekSaveDetails( SaveListItem *item );
|
||||
int currentSneekIcon;
|
||||
QTimer sneekIconTimer;
|
||||
QList<QPixmap>sneekIcon;
|
||||
|
||||
int currentPcIcon;
|
||||
QTimer pcIconTimer;
|
||||
QList<QPixmap>pcIcon;
|
||||
quint32 currentPcSave;
|
||||
|
||||
//basepath used for local save backups
|
||||
QString pcPath;
|
||||
|
||||
//get available filename for backup save inside pcPath
|
||||
QString GetSaveName( quint64 tid );
|
||||
|
||||
//variables used for creating the data.bins on extraction
|
||||
quint32 ngID;
|
||||
quint32 ngKeyID;
|
||||
QByteArray ngSig;
|
||||
QByteArray ngMac;
|
||||
QByteArray ngPriv;
|
||||
|
||||
//for remembering PC saves' TID and the descriptions of each save
|
||||
QList< PcSaveInfo > pcInfos;
|
||||
|
||||
bool NG_Ok();
|
||||
|
||||
bool WriteZipFile( const QByteArray &dataBin, const QByteArray &desc, const QString &path );
|
||||
void AddNewPCSave( const QString &desc, const QString &tid, quint32 size, const QString &path, SaveBanner banner );
|
||||
|
||||
|
||||
private slots:
|
||||
void on_comboBox_pcSelect_currentIndexChanged(int index);
|
||||
void on_listWidget_pcSaves_currentItemChanged(QListWidgetItem* current, QListWidgetItem* previous);
|
||||
void on_actionSet_NG_Keys_triggered();
|
||||
void on_pushButton_sneekExtract_clicked();
|
||||
void on_pushButton_sneekDelete_clicked();
|
||||
void on_actionSet_Sneek_Path_triggered();
|
||||
void on_listWidget_sneekSaves_currentItemChanged( QListWidgetItem* current, QListWidgetItem* previous );
|
||||
//void on_listWidget_sneekSaves_itemClicked(QListWidgetItem* item);
|
||||
//void on_listWidget_sneekSaves_itemActivated( QListWidgetItem* item );
|
||||
|
||||
void ReceiveSaveItem( QByteArray, const QString&, int, int );
|
||||
void ReceiveSneekBanner( QByteArray, const QString&, int );
|
||||
void ReceivePcItem( PcSaveInfo );
|
||||
void GetProgressUpdate( int );
|
||||
void LoadThreadIsDone( int );
|
||||
|
||||
void ShowSneekSaveDetails( SaveListItem *item );
|
||||
void ShowPCSaveDetails( SaveListItem *item );
|
||||
void ShowNextSneekIcon();
|
||||
void ShowNextPcIcon();
|
||||
|
||||
};
|
||||
|
||||
|
@ -175,13 +175,13 @@
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="tab_2">
|
||||
<widget class="QWidget" name="PCtab">
|
||||
<attribute name="title">
|
||||
<string>Tab 2</string>
|
||||
<string>PC Backups</string>
|
||||
</attribute>
|
||||
<layout class="QGridLayout" name="gridLayout_4">
|
||||
<item row="0" column="0">
|
||||
<widget class="QListWidget" name="listWidget_sneekSaves_2">
|
||||
<widget class="QListWidget" name="listWidget_pcSaves">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>620</width>
|
||||
@ -297,10 +297,14 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="comboBox_pc_date"/>
|
||||
<widget class="QComboBox" name="comboBox_pcSelect"/>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPlainTextEdit" name="plainTextEdit"/>
|
||||
<widget class="QPlainTextEdit" name="plainTextEdit_pcDesc">
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QGridLayout" name="gridLayout_3">
|
||||
@ -313,6 +317,9 @@
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QPushButton" name="pushButton_pc_saveDesc">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Save Desc.</string>
|
||||
</property>
|
||||
@ -349,6 +356,8 @@
|
||||
<string>Tools</string>
|
||||
</property>
|
||||
<addaction name="actionSet_Sneek_Path"/>
|
||||
<addaction name="actionSet_Local_Path"/>
|
||||
<addaction name="actionSet_NG_Keys"/>
|
||||
</widget>
|
||||
<addaction name="menuTools"/>
|
||||
</widget>
|
||||
@ -369,6 +378,22 @@
|
||||
<string>Ctrl+L</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionSet_Local_Path">
|
||||
<property name="text">
|
||||
<string>Set Local Path...</string>
|
||||
</property>
|
||||
<property name="shortcut">
|
||||
<string>Ctrl+R</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionSet_NG_Keys">
|
||||
<property name="text">
|
||||
<string>Set NG Keys...</string>
|
||||
</property>
|
||||
<property name="shortcut">
|
||||
<string>Ctrl+G</string>
|
||||
</property>
|
||||
</action>
|
||||
</widget>
|
||||
<layoutdefault spacing="6" margin="11"/>
|
||||
<resources/>
|
||||
|
200
saveToy/ngdialog.cpp
Normal file
200
saveToy/ngdialog.cpp
Normal file
@ -0,0 +1,200 @@
|
||||
#include "ngdialog.h"
|
||||
#include "ui_ngdialog.h"
|
||||
#include "../WiiQt/keysbin.h"
|
||||
#include "../WiiQt/savedatabin.h"
|
||||
|
||||
NgDialog::NgDialog(QWidget *parent) :
|
||||
QDialog(parent),
|
||||
ui(new Ui::NgDialog)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
hex.setPattern( "^[A-Fa-f0-9]+$" );
|
||||
ngID = 0;
|
||||
ngKeyID = 0;
|
||||
|
||||
QFontMetrics fm( fontMetrics() );
|
||||
int max = fm.width( ui->label_ngid->text() );
|
||||
max = MAX( max, fm.width( ui->label_ngKeyId->text() ) );
|
||||
max = MAX( max, fm.width( ui->label_ngMac->text() ) );
|
||||
max = MAX( max, fm.width( ui->label_ngPriv->text() ) );
|
||||
max = MAX( max, fm.width( ui->label_ngSig->text() ) );
|
||||
|
||||
max += 5;
|
||||
ui->label_ngid->setMinimumWidth( max );
|
||||
ui->label_ngKeyId->setMinimumWidth( max );
|
||||
ui->label_ngMac->setMinimumWidth( max );
|
||||
ui->label_ngPriv->setMinimumWidth( max );
|
||||
ui->label_ngSig->setMinimumWidth( max );
|
||||
}
|
||||
|
||||
NgDialog::~NgDialog()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
int NgDialog::exec()
|
||||
{
|
||||
ui->lineEdit_ngID->setText( QString( "%1" ).arg( ngID, 8, 16, QChar( '0' ) ) );
|
||||
ui->lineEdit_ngKeyId->setText( QString( "%1" ).arg( ngKeyID, 8, 16, QChar( '0' ) ) );
|
||||
ui->lineEdit_ngSig->setText( ngSig.toHex() );
|
||||
ui->lineEdit_ngMac->setText( ngMac.toHex() );
|
||||
ui->lineEdit_ngPriv->setText( ngPriv.toHex() );
|
||||
|
||||
return QDialog::exec();
|
||||
}
|
||||
|
||||
bool NgDialog::ValidNGID()
|
||||
{
|
||||
bool ok = false;
|
||||
ngID = ui->lineEdit_ngID->text().toInt( &ok, 16 );
|
||||
return ok;
|
||||
}
|
||||
|
||||
bool NgDialog::ValidNGKeyID()
|
||||
{
|
||||
bool ok = false;
|
||||
ngKeyID = ui->lineEdit_ngKeyId->text().toInt( &ok, 16 );
|
||||
return ok;
|
||||
}
|
||||
|
||||
bool NgDialog::ValidNGSig()
|
||||
{
|
||||
if( ui->lineEdit_ngSig->text().size() != 120 )
|
||||
return false;
|
||||
return hex.exactMatch( ui->lineEdit_ngSig->text() );
|
||||
}
|
||||
|
||||
bool NgDialog::ValidNGMac()
|
||||
{
|
||||
if( ui->lineEdit_ngMac->text().size() != 12 )
|
||||
return false;
|
||||
return hex.exactMatch( ui->lineEdit_ngMac->text() );
|
||||
}
|
||||
|
||||
bool NgDialog::ValidNGPriv()
|
||||
{
|
||||
if( ui->lineEdit_ngPriv->text().size() != 60 )
|
||||
return false;
|
||||
return hex.exactMatch( ui->lineEdit_ngPriv->text() );
|
||||
}
|
||||
|
||||
void NgDialog::on_lineEdit_ngID_textChanged( QString str )
|
||||
{
|
||||
if( str.contains( " " ) )//remove spaces ( useful for copy/pasting out of a hexeditor )
|
||||
{
|
||||
str.remove( " " );
|
||||
ui->lineEdit_ngID->setText( str );
|
||||
return;
|
||||
}
|
||||
QString color = ValidNGID() ? "green" : "red";
|
||||
ui->lineEdit_ngID->setStyleSheet( "QLineEdit { background-color: " + color + "; }" );
|
||||
}
|
||||
|
||||
void NgDialog::on_lineEdit_ngSig_textChanged( QString str )
|
||||
{
|
||||
if( str.contains( " " ) )//remove spaces ( useful for copy/pasting out of a hexeditor )
|
||||
{
|
||||
str.remove( " " );
|
||||
ui->lineEdit_ngSig->setText( str );
|
||||
return;
|
||||
}
|
||||
QString color = ValidNGSig() ? "green" : "red";
|
||||
ui->lineEdit_ngSig->setStyleSheet( "QLineEdit { background-color: " + color + "; }" );
|
||||
}
|
||||
|
||||
void NgDialog::on_lineEdit_ngKeyId_textChanged( QString str )
|
||||
{
|
||||
if( str.contains( " " ) )//remove spaces ( useful for copy/pasting out of a hexeditor )
|
||||
{
|
||||
str.remove( " " );
|
||||
ui->lineEdit_ngKeyId->setText( str );
|
||||
return;
|
||||
}
|
||||
QString color = ValidNGKeyID() ? "green" : "red";
|
||||
ui->lineEdit_ngKeyId->setStyleSheet( "QLineEdit { background-color: " + color + "; }" );
|
||||
}
|
||||
|
||||
void NgDialog::on_lineEdit_ngMac_textChanged( QString str )
|
||||
{
|
||||
if( str.contains( " " ) )//remove spaces ( useful for copy/pasting out of a hexeditor )
|
||||
{
|
||||
str.remove( " " );
|
||||
ui->lineEdit_ngMac->setText( str );
|
||||
return;
|
||||
}
|
||||
QString color = ValidNGMac() ? "green" : "red";
|
||||
ui->lineEdit_ngMac->setStyleSheet( "QLineEdit { background-color: " + color + "; }" );
|
||||
}
|
||||
|
||||
void NgDialog::on_lineEdit_ngPriv_textChanged( QString str )
|
||||
{
|
||||
if( str.contains( " " ) )//remove spaces ( useful for copy/pasting out of a hexeditor )
|
||||
{
|
||||
str.remove( " " );
|
||||
ui->lineEdit_ngPriv->setText( str );
|
||||
return;
|
||||
}
|
||||
QString color = ValidNGPriv() ? "green" : "red";
|
||||
ui->lineEdit_ngPriv->setStyleSheet( "QLineEdit { background-color: " + color + "; }" );
|
||||
}
|
||||
|
||||
//open keys.bin to get stuff from it
|
||||
void NgDialog::on_pushButton_keys_clicked()
|
||||
{
|
||||
QString fn = QFileDialog::getOpenFileName( this, tr( "Select keys.bin" ) );
|
||||
if( fn.isEmpty() )
|
||||
return;
|
||||
|
||||
QByteArray ba = ReadFile( fn );
|
||||
if( ba.size() != 0x400 )
|
||||
{
|
||||
ui->label_message->setText( tr( "keys.bin should be 0x400 bytes" ) );
|
||||
return;
|
||||
}
|
||||
|
||||
KeysBin keys( ba );
|
||||
ui->lineEdit_ngID->setText( keys.NG_ID().toHex() );
|
||||
ui->lineEdit_ngKeyId->setText( keys.NG_key_ID().toHex() );
|
||||
ui->lineEdit_ngPriv->setText( keys.NG_Priv().toHex() );
|
||||
ui->lineEdit_ngSig->setText( keys.NG_Sig().toHex() );
|
||||
}
|
||||
|
||||
//read a data.bin and get some keys from it
|
||||
void NgDialog::on_pushButton_existingSave_clicked()
|
||||
{
|
||||
QString fn = QFileDialog::getOpenFileName( this, tr( "Select data.bin" ) );
|
||||
if( fn.isEmpty() )
|
||||
return;
|
||||
|
||||
QByteArray ba = ReadFile( fn );
|
||||
SaveDataBin sb( ba );
|
||||
if( !sb.IsOk() )
|
||||
{
|
||||
ui->label_message->setText( tr( "error reading the data.bin" ) );
|
||||
return;
|
||||
}
|
||||
ui->lineEdit_ngID->setText( QString( "%1" ).arg( sb.NgID(), 8, 16, QChar( '0' ) ) );
|
||||
ui->lineEdit_ngKeyId->setText( QString( "%1" ).arg( sb.NgKeyID(), 8, 16, QChar( '0' ) ) );
|
||||
ui->lineEdit_ngSig->setText( sb.NgSig().toHex() );
|
||||
ui->lineEdit_ngMac->setText( sb.NgMac().toHex() );
|
||||
}
|
||||
|
||||
void NgDialog::on_pushButton_ok_clicked()
|
||||
{
|
||||
if( !ValidNGID() || !ValidNGKeyID() || !ValidNGSig() || !ValidNGMac() || !ValidNGPriv() )
|
||||
{
|
||||
ui->label_message->setText( tr( "Please correct mistakes before clicking ok" ) );
|
||||
qWarning() << "NgDialog::on_buttonBox_accepted() -> invalid shit";
|
||||
return;
|
||||
}
|
||||
|
||||
ngSig = QByteArray::fromHex( ui->lineEdit_ngSig->text().toLatin1() );
|
||||
ngMac = QByteArray::fromHex( ui->lineEdit_ngMac->text().toLatin1() );;
|
||||
ngPriv = QByteArray::fromHex( ui->lineEdit_ngPriv->text().toLatin1() );
|
||||
QDialog::accept();
|
||||
}
|
||||
|
||||
void NgDialog::on_pushButton_cancel_clicked()
|
||||
{
|
||||
QDialog::reject();
|
||||
}
|
51
saveToy/ngdialog.h
Normal file
51
saveToy/ngdialog.h
Normal file
@ -0,0 +1,51 @@
|
||||
#ifndef NGDIALOG_H
|
||||
#define NGDIALOG_H
|
||||
|
||||
#include "../WiiQt/includes.h"
|
||||
#include "../WiiQt/tools.h"
|
||||
|
||||
namespace Ui {
|
||||
class NgDialog;
|
||||
}
|
||||
|
||||
class NgDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit NgDialog( QWidget *parent = 0 );
|
||||
~NgDialog();
|
||||
|
||||
quint32 ngID;
|
||||
quint32 ngKeyID;
|
||||
QByteArray ngSig;
|
||||
QByteArray ngMac;
|
||||
QByteArray ngPriv;
|
||||
|
||||
private:
|
||||
Ui::NgDialog *ui;
|
||||
|
||||
QRegExp hex;
|
||||
|
||||
bool ValidNGID();
|
||||
bool ValidNGKeyID();
|
||||
bool ValidNGSig();
|
||||
bool ValidNGMac();
|
||||
bool ValidNGPriv();
|
||||
|
||||
private slots:
|
||||
void on_pushButton_cancel_clicked();
|
||||
void on_pushButton_ok_clicked();
|
||||
void on_pushButton_existingSave_clicked();
|
||||
void on_pushButton_keys_clicked();
|
||||
void on_lineEdit_ngPriv_textChanged(QString );
|
||||
void on_lineEdit_ngMac_textChanged(QString );
|
||||
void on_lineEdit_ngKeyId_textChanged(QString );
|
||||
void on_lineEdit_ngSig_textChanged(QString );
|
||||
void on_lineEdit_ngID_textChanged(QString );
|
||||
|
||||
public slots:
|
||||
int exec();
|
||||
};
|
||||
|
||||
#endif // NGDIALOG_H
|
180
saveToy/ngdialog.ui
Normal file
180
saveToy/ngdialog.ui
Normal file
@ -0,0 +1,180 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>NgDialog</class>
|
||||
<widget class="QDialog" name="NgDialog">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>462</width>
|
||||
<height>235</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>NG Stuff</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||
<item>
|
||||
<layout class="QFormLayout" name="formLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label_ngid">
|
||||
<property name="text">
|
||||
<string>NG ID</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLineEdit" name="lineEdit_ngID">
|
||||
<property name="maxLength">
|
||||
<number>16</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label_ngKeyId">
|
||||
<property name="text">
|
||||
<string>NG Key ID</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QLineEdit" name="lineEdit_ngKeyId">
|
||||
<property name="maxLength">
|
||||
<number>16</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QLineEdit" name="lineEdit_ngMac">
|
||||
<property name="maxLength">
|
||||
<number>24</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="label_ngMac">
|
||||
<property name="text">
|
||||
<string>NG Mac</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_keys">
|
||||
<property name="text">
|
||||
<string>Read keys.bin</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_existingSave">
|
||||
<property name="text">
|
||||
<string>Read data.bin</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_ngPriv">
|
||||
<property name="text">
|
||||
<string>NG Priv</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineEdit_ngPriv">
|
||||
<property name="maxLength">
|
||||
<number>120</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_ngSig">
|
||||
<property name="text">
|
||||
<string>NG SIG</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineEdit_ngSig">
|
||||
<property name="maxLength">
|
||||
<number>200</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label_message">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_4">
|
||||
<item>
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_ok">
|
||||
<property name="text">
|
||||
<string>Ok</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_cancel">
|
||||
<property name="text">
|
||||
<string>Cancel</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
32
saveToy/quazip/include/JlCompress.h
Normal file
32
saveToy/quazip/include/JlCompress.h
Normal file
@ -0,0 +1,32 @@
|
||||
#ifndef JLCOMPRESSFOLDER_H_
|
||||
#define JLCOMPRESSFOLDER_H_
|
||||
|
||||
#include "quazip.h"
|
||||
#include "quazipfile.h"
|
||||
#include "quazipfileinfo.h"
|
||||
#include <QString>
|
||||
#include <QDir>
|
||||
#include <QFileInfo>
|
||||
#include <QFile>
|
||||
|
||||
class JlCompress {
|
||||
private:
|
||||
static bool compressFile(QuaZip* zip, QString fileName, QString fileDest);
|
||||
static bool compressSubDir(QuaZip* parentZip, QString dir, QString parentDir, bool recursive = true);
|
||||
static bool extractFile(QuaZip* zip, QString fileName, QString fileDest);
|
||||
|
||||
static bool removeFile(QStringList listFile);
|
||||
|
||||
public:
|
||||
static bool compressFile(QString fileCompressed, QString file);
|
||||
static bool compressFiles(QString fileCompressed, QStringList files);
|
||||
static bool compressDir(QString fileCompressed, QString dir = QString(), bool recursive = true);
|
||||
|
||||
public:
|
||||
static QString extractFile(QString fileCompressed, QString file, QString fileDest = QString());
|
||||
static QStringList extractFiles(QString fileCompressed, QStringList files, QString dir = QString());
|
||||
static QStringList extractDir(QString fileCompressed, QString dir = QString());
|
||||
static QStringList getFileList(QString fileCompressed);
|
||||
};
|
||||
|
||||
#endif /* JLCOMPRESSFOLDER_H_ */
|
133
saveToy/quazip/include/crypt.h
Normal file
133
saveToy/quazip/include/crypt.h
Normal file
@ -0,0 +1,133 @@
|
||||
/* crypt.h -- base code for crypt/uncrypt ZIPfile
|
||||
|
||||
|
||||
Version 1.01e, February 12th, 2005
|
||||
|
||||
Copyright (C) 1998-2005 Gilles Vollant
|
||||
|
||||
This code is a modified version of crypting code in Infozip distribution
|
||||
|
||||
The encryption/decryption parts of this source code (as opposed to the
|
||||
non-echoing password parts) were originally written in Europe. The
|
||||
whole source package can be freely distributed, including from the USA.
|
||||
(Prior to January 2000, re-export from the US was a violation of US law.)
|
||||
|
||||
This encryption code is a direct transcription of the algorithm from
|
||||
Roger Schlafly, described by Phil Katz in the file appnote.txt. This
|
||||
file (appnote.txt) is distributed with the PKZIP program (even in the
|
||||
version without encryption capabilities).
|
||||
|
||||
If you don't need crypting in your application, just define symbols
|
||||
NOCRYPT and NOUNCRYPT.
|
||||
|
||||
This code support the "Traditional PKWARE Encryption".
|
||||
|
||||
The new AES encryption added on Zip format by Winzip (see the page
|
||||
http://www.winzip.com/aes_info.htm ) and PKWare PKZip 5.x Strong
|
||||
Encryption is not supported.
|
||||
*/
|
||||
|
||||
#define CRC32(c, b) ((*(pcrc_32_tab+(((int)(c) ^ (b)) & 0xff))) ^ ((c) >> 8))
|
||||
|
||||
/***********************************************************************
|
||||
* Return the next byte in the pseudo-random sequence
|
||||
*/
|
||||
static int decrypt_byte(unsigned long* pkeys, const unsigned long* pcrc_32_tab)
|
||||
{
|
||||
(void) pcrc_32_tab; /* avoid "unused parameter" warning */
|
||||
unsigned temp; /* POTENTIAL BUG: temp*(temp^1) may overflow in an
|
||||
* unpredictable manner on 16-bit systems; not a problem
|
||||
* with any known compiler so far, though */
|
||||
|
||||
temp = ((unsigned)(*(pkeys+2)) & 0xffff) | 2;
|
||||
return (int)(((temp * (temp ^ 1)) >> 8) & 0xff);
|
||||
}
|
||||
|
||||
/***********************************************************************
|
||||
* Update the encryption keys with the next byte of plain text
|
||||
*/
|
||||
static int update_keys(unsigned long* pkeys,const unsigned long* pcrc_32_tab,int c)
|
||||
{
|
||||
(*(pkeys+0)) = CRC32((*(pkeys+0)), c);
|
||||
(*(pkeys+1)) += (*(pkeys+0)) & 0xff;
|
||||
(*(pkeys+1)) = (*(pkeys+1)) * 134775813L + 1;
|
||||
{
|
||||
register int keyshift = (int)((*(pkeys+1)) >> 24);
|
||||
(*(pkeys+2)) = CRC32((*(pkeys+2)), keyshift);
|
||||
}
|
||||
return c;
|
||||
}
|
||||
|
||||
|
||||
/***********************************************************************
|
||||
* Initialize the encryption keys and the random header according to
|
||||
* the given password.
|
||||
*/
|
||||
static void init_keys(const char* passwd,unsigned long* pkeys,const unsigned long* pcrc_32_tab)
|
||||
{
|
||||
*(pkeys+0) = 305419896L;
|
||||
*(pkeys+1) = 591751049L;
|
||||
*(pkeys+2) = 878082192L;
|
||||
while (*passwd != '\0') {
|
||||
update_keys(pkeys,pcrc_32_tab,(int)*passwd);
|
||||
passwd++;
|
||||
}
|
||||
}
|
||||
|
||||
#define zdecode(pkeys,pcrc_32_tab,c) \
|
||||
(update_keys(pkeys,pcrc_32_tab,c ^= decrypt_byte(pkeys,pcrc_32_tab)))
|
||||
|
||||
#define zencode(pkeys,pcrc_32_tab,c,t) \
|
||||
(t=decrypt_byte(pkeys,pcrc_32_tab), update_keys(pkeys,pcrc_32_tab,c), t^(c))
|
||||
|
||||
#ifdef INCLUDECRYPTINGCODE_IFCRYPTALLOWED
|
||||
|
||||
#define RAND_HEAD_LEN 12
|
||||
/* "last resort" source for second part of crypt seed pattern */
|
||||
# ifndef ZCR_SEED2
|
||||
# define ZCR_SEED2 3141592654UL /* use PI as default pattern */
|
||||
# endif
|
||||
|
||||
static int crypthead(passwd, buf, bufSize, pkeys, pcrc_32_tab, crcForCrypting)
|
||||
const char *passwd; /* password string */
|
||||
unsigned char *buf; /* where to write header */
|
||||
int bufSize;
|
||||
unsigned long* pkeys;
|
||||
const unsigned long* pcrc_32_tab;
|
||||
unsigned long crcForCrypting;
|
||||
{
|
||||
int n; /* index in random header */
|
||||
int t; /* temporary */
|
||||
int c; /* random byte */
|
||||
unsigned char header[RAND_HEAD_LEN-2]; /* random header */
|
||||
static unsigned calls = 0; /* ensure different random header each time */
|
||||
|
||||
if (bufSize<RAND_HEAD_LEN)
|
||||
return 0;
|
||||
|
||||
/* First generate RAND_HEAD_LEN-2 random bytes. We encrypt the
|
||||
* output of rand() to get less predictability, since rand() is
|
||||
* often poorly implemented.
|
||||
*/
|
||||
if (++calls == 1)
|
||||
{
|
||||
srand((unsigned)(time(NULL) ^ ZCR_SEED2));
|
||||
}
|
||||
init_keys(passwd, pkeys, pcrc_32_tab);
|
||||
for (n = 0; n < RAND_HEAD_LEN-2; n++)
|
||||
{
|
||||
c = (rand() >> 7) & 0xff;
|
||||
header[n] = (unsigned char)zencode(pkeys, pcrc_32_tab, c, t);
|
||||
}
|
||||
/* Encrypt random header (last two bytes is high word of crc) */
|
||||
init_keys(passwd, pkeys, pcrc_32_tab);
|
||||
for (n = 0; n < RAND_HEAD_LEN-2; n++)
|
||||
{
|
||||
buf[n] = (unsigned char)zencode(pkeys, pcrc_32_tab, header[n], t);
|
||||
}
|
||||
buf[n++] = zencode(pkeys, pcrc_32_tab, (int)(crcForCrypting >> 16) & 0xff, t);
|
||||
buf[n++] = zencode(pkeys, pcrc_32_tab, (int)(crcForCrypting >> 24) & 0xff, t);
|
||||
return n;
|
||||
}
|
||||
|
||||
#endif
|
75
saveToy/quazip/include/ioapi.h
Normal file
75
saveToy/quazip/include/ioapi.h
Normal file
@ -0,0 +1,75 @@
|
||||
/* ioapi.h -- IO base function header for compress/uncompress .zip
|
||||
files using zlib + zip or unzip API
|
||||
|
||||
Version 1.01e, February 12th, 2005
|
||||
|
||||
Copyright (C) 1998-2005 Gilles Vollant
|
||||
*/
|
||||
|
||||
#ifndef _ZLIBIOAPI_H
|
||||
#define _ZLIBIOAPI_H
|
||||
|
||||
|
||||
#define ZLIB_FILEFUNC_SEEK_CUR (1)
|
||||
#define ZLIB_FILEFUNC_SEEK_END (2)
|
||||
#define ZLIB_FILEFUNC_SEEK_SET (0)
|
||||
|
||||
#define ZLIB_FILEFUNC_MODE_READ (1)
|
||||
#define ZLIB_FILEFUNC_MODE_WRITE (2)
|
||||
#define ZLIB_FILEFUNC_MODE_READWRITEFILTER (3)
|
||||
|
||||
#define ZLIB_FILEFUNC_MODE_EXISTING (4)
|
||||
#define ZLIB_FILEFUNC_MODE_CREATE (8)
|
||||
|
||||
|
||||
#ifndef ZCALLBACK
|
||||
|
||||
#if (defined(WIN32) || defined (WINDOWS) || defined (_WINDOWS)) && defined(CALLBACK) && defined (USEWINDOWS_CALLBACK)
|
||||
#define ZCALLBACK CALLBACK
|
||||
#else
|
||||
#define ZCALLBACK
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef voidpf (ZCALLBACK *open_file_func) OF((voidpf opaque, const char* filename, int mode));
|
||||
typedef uLong (ZCALLBACK *read_file_func) OF((voidpf opaque, voidpf stream, void* buf, uLong size));
|
||||
typedef uLong (ZCALLBACK *write_file_func) OF((voidpf opaque, voidpf stream, const void* buf, uLong size));
|
||||
typedef long (ZCALLBACK *tell_file_func) OF((voidpf opaque, voidpf stream));
|
||||
typedef long (ZCALLBACK *seek_file_func) OF((voidpf opaque, voidpf stream, uLong offset, int origin));
|
||||
typedef int (ZCALLBACK *close_file_func) OF((voidpf opaque, voidpf stream));
|
||||
typedef int (ZCALLBACK *testerror_file_func) OF((voidpf opaque, voidpf stream));
|
||||
|
||||
typedef struct zlib_filefunc_def_s
|
||||
{
|
||||
open_file_func zopen_file;
|
||||
read_file_func zread_file;
|
||||
write_file_func zwrite_file;
|
||||
tell_file_func ztell_file;
|
||||
seek_file_func zseek_file;
|
||||
close_file_func zclose_file;
|
||||
testerror_file_func zerror_file;
|
||||
voidpf opaque;
|
||||
} zlib_filefunc_def;
|
||||
|
||||
|
||||
|
||||
void fill_fopen_filefunc OF((zlib_filefunc_def* pzlib_filefunc_def));
|
||||
|
||||
#define ZREAD(filefunc,filestream,buf,size) ((*((filefunc).zread_file))((filefunc).opaque,filestream,buf,size))
|
||||
#define ZWRITE(filefunc,filestream,buf,size) ((*((filefunc).zwrite_file))((filefunc).opaque,filestream,buf,size))
|
||||
#define ZTELL(filefunc,filestream) ((*((filefunc).ztell_file))((filefunc).opaque,filestream))
|
||||
#define ZSEEK(filefunc,filestream,pos,mode) ((*((filefunc).zseek_file))((filefunc).opaque,filestream,pos,mode))
|
||||
#define ZCLOSE(filefunc,filestream) ((*((filefunc).zclose_file))((filefunc).opaque,filestream))
|
||||
#define ZERROR(filefunc,filestream) ((*((filefunc).zerror_file))((filefunc).opaque,filestream))
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
29
saveToy/quazip/include/quaadler32.h
Normal file
29
saveToy/quazip/include/quaadler32.h
Normal file
@ -0,0 +1,29 @@
|
||||
#ifndef QUAADLER32_H
|
||||
#define QUAADLER32_H
|
||||
|
||||
#include <QByteArray>
|
||||
|
||||
#include "quachecksum32.h"
|
||||
|
||||
/// Adler32 checksum
|
||||
/** \class QuaAdler32 quaadler32.h <quazip/quaadler32.h>
|
||||
* This class wrappers the adler32 function with the QuaChecksum32 interface.
|
||||
* See QuaChecksum32 for more info.
|
||||
*/
|
||||
class QuaAdler32 : public QuaChecksum32
|
||||
{
|
||||
|
||||
public:
|
||||
QuaAdler32();
|
||||
|
||||
quint32 calculate(const QByteArray &data);
|
||||
|
||||
void reset();
|
||||
void update(const QByteArray &buf);
|
||||
quint32 value();
|
||||
|
||||
private:
|
||||
quint32 checksum;
|
||||
};
|
||||
|
||||
#endif //QUAADLER32_H
|
53
saveToy/quazip/include/quachecksum32.h
Normal file
53
saveToy/quazip/include/quachecksum32.h
Normal file
@ -0,0 +1,53 @@
|
||||
#ifndef QUACHECKSUM32_H
|
||||
#define QUACHECKSUM32_H
|
||||
|
||||
#include <QByteArray>
|
||||
|
||||
/// Checksum interface.
|
||||
/** \class QuaChecksum32 quachecksum32.h <quazip/quachecksum32.h>
|
||||
* This is an interface for 32 bit checksums.
|
||||
* Classes implementing this interface can calcunate a certin
|
||||
* checksum in a single step:
|
||||
* \code
|
||||
* QChecksum32 *crc32 = new QuaCrc32();
|
||||
* rasoult = crc32->calculate(data);
|
||||
* \endcode
|
||||
* or by streaming the data:
|
||||
* \code
|
||||
* QChecksum32 *crc32 = new QuaCrc32();
|
||||
* while(!fileA.atEnd())
|
||||
* crc32->update(fileA.read(bufSize));
|
||||
* resoultA = crc32->value();
|
||||
* crc32->reset();
|
||||
* while(!fileB.atEnd())
|
||||
* crc32->update(fileB.read(bufSize));
|
||||
* resoultB = crc32->value();
|
||||
* \endcode
|
||||
*/
|
||||
class QuaChecksum32
|
||||
{
|
||||
|
||||
public:
|
||||
///Calculates the checksum for data.
|
||||
/** \a data source data
|
||||
* \return data checksum
|
||||
*
|
||||
* This function has no efect on the value returned by value().
|
||||
*/
|
||||
virtual quint32 calculate(const QByteArray &data) = 0;
|
||||
|
||||
///Resets the calculation on a checksun for a stream.
|
||||
virtual void reset() = 0;
|
||||
|
||||
///Updates the calculated checksum for the stream
|
||||
/** \a buf next portion of data from the stream
|
||||
*/
|
||||
virtual void update(const QByteArray &buf) = 0;
|
||||
|
||||
///Value of the checksum calculated for the stream passed throw update().
|
||||
/** \return checksum
|
||||
*/
|
||||
virtual quint32 value() = 0;
|
||||
};
|
||||
|
||||
#endif //QUACHECKSUM32_H
|
26
saveToy/quazip/include/quacrc32.h
Normal file
26
saveToy/quazip/include/quacrc32.h
Normal file
@ -0,0 +1,26 @@
|
||||
#ifndef QUACRC32_H
|
||||
#define QUACRC32_H
|
||||
|
||||
#include "quachecksum32.h"
|
||||
|
||||
///CRC32 checksum
|
||||
/** \class QuaCrc32 quacrc32.h <quazip/quacrc32.h>
|
||||
* This class wrappers the crc32 function with the QuaChecksum32 interface.
|
||||
* See QuaChecksum32 for more info.
|
||||
*/
|
||||
class QuaCrc32 : public QuaChecksum32 {
|
||||
|
||||
public:
|
||||
QuaCrc32();
|
||||
|
||||
quint32 calculate(const QByteArray &data);
|
||||
|
||||
void reset();
|
||||
void update(const QByteArray &buf);
|
||||
quint32 value();
|
||||
|
||||
private:
|
||||
quint32 checksum;
|
||||
};
|
||||
|
||||
#endif //QUACRC32_H
|
346
saveToy/quazip/include/quazip.h
Normal file
346
saveToy/quazip/include/quazip.h
Normal file
@ -0,0 +1,346 @@
|
||||
#ifndef QUA_ZIP_H
|
||||
#define QUA_ZIP_H
|
||||
|
||||
/*
|
||||
-- A kind of "standard" GPL license statement --
|
||||
QuaZIP - a Qt/C++ wrapper for the ZIP/UNZIP package
|
||||
Copyright (C) 2005-2007 Sergey A. Tachenov
|
||||
|
||||
This program is free software; you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by the
|
||||
Free Software Foundation; either version 2 of the License, or (at your
|
||||
option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
|
||||
Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along
|
||||
with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
-- A kind of "standard" GPL license statement ends here --
|
||||
|
||||
See COPYING file for GPL.
|
||||
|
||||
You are also permitted to use QuaZIP under the terms of LGPL (see
|
||||
COPYING.LGPL). You are free to choose either license, but please note
|
||||
that QuaZIP makes use of Qt, which is not licensed under LGPL. So if
|
||||
you are using Open Source edition of Qt, you therefore MUST use GPL for
|
||||
your code based on QuaZIP, since it would be also based on Qt in this
|
||||
case. If you are Qt commercial license owner, then you are free to use
|
||||
QuaZIP as long as you respect either GPL or LGPL for QuaZIP code.
|
||||
**/
|
||||
|
||||
#include <QString>
|
||||
#include <QTextCodec>
|
||||
|
||||
#include "zip.h"
|
||||
#include "unzip.h"
|
||||
|
||||
#include "quazipfileinfo.h"
|
||||
|
||||
// just in case it will be defined in the later versions of the ZIP/UNZIP
|
||||
#ifndef UNZ_OPENERROR
|
||||
// define additional error code
|
||||
#define UNZ_OPENERROR -1000
|
||||
#endif
|
||||
|
||||
/// ZIP archive.
|
||||
/** \class QuaZip quazip.h <quazip/quazip.h>
|
||||
* This class implements basic interface to the ZIP archive. It can be
|
||||
* used to read table contents of the ZIP archive and retreiving
|
||||
* information about the files inside it.
|
||||
*
|
||||
* You can also use this class to open files inside archive by passing
|
||||
* pointer to the instance of this class to the constructor of the
|
||||
* QuaZipFile class. But see QuaZipFile::QuaZipFile(QuaZip*, QObject*)
|
||||
* for the possible pitfalls.
|
||||
*
|
||||
* This class is indended to provide interface to the ZIP subpackage of
|
||||
* the ZIP/UNZIP package as well as to the UNZIP subpackage. But
|
||||
* currently it supports only UNZIP.
|
||||
*
|
||||
* The use of this class is simple - just create instance using
|
||||
* constructor, then set ZIP archive file name using setFile() function
|
||||
* (if you did not passed the name to the constructor), then open() and
|
||||
* then use different functions to work with it! Well, if you are
|
||||
* paranoid, you may also wish to call close before destructing the
|
||||
* instance, to check for errors on close.
|
||||
*
|
||||
* You may also use getUnzFile() and getZipFile() functions to get the
|
||||
* ZIP archive handle and use it with ZIP/UNZIP package API directly.
|
||||
*
|
||||
* This class supports localized file names inside ZIP archive, but you
|
||||
* have to set up proper codec with setCodec() function. By default,
|
||||
* locale codec will be used, which is probably ok for UNIX systems, but
|
||||
* will almost certainly fail with ZIP archives created in Windows. This
|
||||
* is because Windows ZIP programs have strange habit of using DOS
|
||||
* encoding for file names in ZIP archives. For example, ZIP archive
|
||||
* with cyrillic names created in Windows will have file names in \c
|
||||
* IBM866 encoding instead of \c WINDOWS-1251. I think that calling one
|
||||
* function is not much trouble, but for true platform independency it
|
||||
* would be nice to have some mechanism for file name encoding auto
|
||||
* detection using locale information. Does anyone know a good way to do
|
||||
* it?
|
||||
**/
|
||||
class QuaZip {
|
||||
public:
|
||||
/// Useful constants.
|
||||
enum Constants {
|
||||
MAX_FILE_NAME_LENGTH=256 /**< Maximum file name length. Taken from
|
||||
\c UNZ_MAXFILENAMEINZIP constant in
|
||||
unzip.c. */
|
||||
};
|
||||
/// Open mode of the ZIP file.
|
||||
enum Mode {
|
||||
mdNotOpen, ///< ZIP file is not open. This is the initial mode.
|
||||
mdUnzip, ///< ZIP file is open for reading files inside it.
|
||||
mdCreate, ///< ZIP file was created with open() call.
|
||||
mdAppend, /**< ZIP file was opened in append mode. This refers to
|
||||
* \c APPEND_STATUS_CREATEAFTER mode in ZIP/UNZIP package
|
||||
* and means that zip is appended to some existing file
|
||||
* what is useful when that file contains
|
||||
* self-extractor code. This is obviously \em not what
|
||||
* you whant to use to add files to the existing ZIP
|
||||
* archive.
|
||||
**/
|
||||
mdAdd ///< ZIP file was opened for adding files in the archive.
|
||||
};
|
||||
/// Case sensitivity for the file names.
|
||||
/** This is what you specify when accessing files in the archive.
|
||||
* Works perfectly fine with any characters thanks to Qt's great
|
||||
* unicode support. This is different from ZIP/UNZIP API, where
|
||||
* only US-ASCII characters was supported.
|
||||
**/
|
||||
enum CaseSensitivity {
|
||||
csDefault=0, ///< Default for platform. Case sensitive for UNIX, not for Windows.
|
||||
csSensitive=1, ///< Case sensitive.
|
||||
csInsensitive=2 ///< Case insensitive.
|
||||
};
|
||||
private:
|
||||
QTextCodec *fileNameCodec, *commentCodec;
|
||||
QString zipName;
|
||||
QString comment;
|
||||
Mode mode;
|
||||
union {
|
||||
unzFile unzFile_f;
|
||||
zipFile zipFile_f;
|
||||
};
|
||||
bool hasCurrentFile_f;
|
||||
int zipError;
|
||||
// not (and will not be) implemented
|
||||
QuaZip(const QuaZip& that);
|
||||
// not (and will not be) implemented
|
||||
QuaZip& operator=(const QuaZip& that);
|
||||
public:
|
||||
/// Constructs QuaZip object.
|
||||
/** Call setName() before opening constructed object. */
|
||||
QuaZip();
|
||||
/// Constructs QuaZip object associated with ZIP file \a zipName.
|
||||
QuaZip(const QString& zipName);
|
||||
/// Destroys QuaZip object.
|
||||
/** Calls close() if necessary. */
|
||||
~QuaZip();
|
||||
/// Opens ZIP file.
|
||||
/** Argument \a ioApi specifies IO function set for ZIP/UNZIP
|
||||
* package to use. See unzip.h, zip.h and ioapi.h for details. By
|
||||
* passing NULL (the default) you just tell package to use the
|
||||
* default API which works just fine on UNIX platforms. I have tried
|
||||
* it on win32-g++ platform too and it seems it works fine there
|
||||
* too, so I see no reason to use win32 IO API included in original
|
||||
* ZIP/UNZIP package.
|
||||
*
|
||||
* ZIP archive file name will be converted to 8-bit encoding using
|
||||
* Qt's QFile::encodeName() function before passing it to the
|
||||
* ZIP/UNZIP package API.
|
||||
*
|
||||
* Returns \c true if successful, \c false otherwise.
|
||||
*
|
||||
* Argument \a mode specifies open mode of the ZIP archive. See Mode
|
||||
* for details. Note that there is zipOpen2() function in the
|
||||
* ZIP/UNZIP API which accepts \a globalcomment argument, but it
|
||||
* does not use it anywhere, so this open() function does not have this
|
||||
* argument. See setComment() if you need to set global comment.
|
||||
*
|
||||
* \note ZIP/UNZIP API open calls do not return error code - they
|
||||
* just return \c NULL indicating an error. But to make things
|
||||
* easier, quazip.h header defines additional error code \c
|
||||
* UNZ_ERROROPEN and getZipError() will return it if the open call
|
||||
* of the ZIP/UNZIP API returns \c NULL.
|
||||
**/
|
||||
bool open(Mode mode, zlib_filefunc_def *ioApi =NULL);
|
||||
/// Closes ZIP file.
|
||||
/** Call getZipError() to determine if the close was successful. */
|
||||
void close();
|
||||
/// Sets the codec used to encode/decode file names inside archive.
|
||||
/** This is necessary to access files in the ZIP archive created
|
||||
* under Windows with non-latin characters in file names. For
|
||||
* example, file names with cyrillic letters will be in \c IBM866
|
||||
* encoding.
|
||||
**/
|
||||
void setFileNameCodec(QTextCodec *fileNameCodec)
|
||||
{this->fileNameCodec=fileNameCodec;}
|
||||
/// Sets the codec used to encode/decode file names inside archive.
|
||||
/** \overload
|
||||
* Equivalent to calling setFileNameCodec(QTextCodec::codecForName(codecName));
|
||||
**/
|
||||
void setFileNameCodec(const char *fileNameCodecName)
|
||||
{fileNameCodec=QTextCodec::codecForName(fileNameCodecName);}
|
||||
/// Returns the codec used to encode/decode comments inside archive.
|
||||
QTextCodec* getFileNameCodec()const {return fileNameCodec;}
|
||||
/// Sets the codec used to encode/decode comments inside archive.
|
||||
/** This codec defaults to locale codec, which is probably ok.
|
||||
**/
|
||||
void setCommentCodec(QTextCodec *commentCodec)
|
||||
{this->commentCodec=commentCodec;}
|
||||
/// Sets the codec used to encode/decode comments inside archive.
|
||||
/** \overload
|
||||
* Equivalent to calling setCommentCodec(QTextCodec::codecForName(codecName));
|
||||
**/
|
||||
void setCommentCodec(const char *commentCodecName)
|
||||
{commentCodec=QTextCodec::codecForName(commentCodecName);}
|
||||
/// Returns the codec used to encode/decode comments inside archive.
|
||||
QTextCodec* getCommentCodec()const {return commentCodec;}
|
||||
/// Returns the name of the ZIP file.
|
||||
/** Returns null string if no ZIP file name has been set.
|
||||
* \sa setZipName()
|
||||
**/
|
||||
QString getZipName()const {return zipName;}
|
||||
/// Sets the name of the ZIP file.
|
||||
/** Does nothing if the ZIP file is open.
|
||||
*
|
||||
* Does not reset error code returned by getZipError().
|
||||
**/
|
||||
void setZipName(const QString& zipName);
|
||||
/// Returns the mode in which ZIP file was opened.
|
||||
Mode getMode()const {return mode;}
|
||||
/// Returns \c true if ZIP file is open, \c false otherwise.
|
||||
bool isOpen()const {return mode!=mdNotOpen;}
|
||||
/// Returns the error code of the last operation.
|
||||
/** Returns \c UNZ_OK if the last operation was successful.
|
||||
*
|
||||
* Error code resets to \c UNZ_OK every time you call any function
|
||||
* that accesses something inside ZIP archive, even if it is \c
|
||||
* const (like getEntriesCount()). open() and close() calls reset
|
||||
* error code too. See documentation for the specific functions for
|
||||
* details on error detection.
|
||||
**/
|
||||
int getZipError()const {return zipError;}
|
||||
/// Returns number of the entries in the ZIP central directory.
|
||||
/** Returns negative error code in the case of error. The same error
|
||||
* code will be returned by subsequent getZipError() call.
|
||||
**/
|
||||
int getEntriesCount()const;
|
||||
/// Returns global comment in the ZIP file.
|
||||
QString getComment()const;
|
||||
/// Sets global comment in the ZIP file.
|
||||
/** Comment will be written to the archive on close operation.
|
||||
*
|
||||
* \sa open()
|
||||
**/
|
||||
void setComment(const QString& comment) {this->comment=comment;}
|
||||
/// Sets the current file to the first file in the archive.
|
||||
/** Returns \c true on success, \c false otherwise. Call
|
||||
* getZipError() to get the error code.
|
||||
**/
|
||||
bool goToFirstFile();
|
||||
/// Sets the current file to the next file in the archive.
|
||||
/** Returns \c true on success, \c false otherwise. Call
|
||||
* getZipError() to determine if there was an error.
|
||||
*
|
||||
* Should be used only in QuaZip::mdUnzip mode.
|
||||
*
|
||||
* \note If the end of file was reached, getZipError() will return
|
||||
* \c UNZ_OK instead of \c UNZ_END_OF_LIST_OF_FILE. This is to make
|
||||
* things like this easier:
|
||||
* \code
|
||||
* for(bool more=zip.goToFirstFile(); more; more=zip.goToNextFile()) {
|
||||
* // do something
|
||||
* }
|
||||
* if(zip.getZipError()==UNZ_OK) {
|
||||
* // ok, there was no error
|
||||
* }
|
||||
* \endcode
|
||||
**/
|
||||
bool goToNextFile();
|
||||
/// Sets current file by its name.
|
||||
/** Returns \c true if successful, \c false otherwise. Argument \a
|
||||
* cs specifies case sensitivity of the file name. Call
|
||||
* getZipError() in the case of a failure to get error code.
|
||||
*
|
||||
* This is not a wrapper to unzLocateFile() function. That is
|
||||
* because I had to implement locale-specific case-insensitive
|
||||
* comparison.
|
||||
*
|
||||
* Here are the differences from the original implementation:
|
||||
*
|
||||
* - If the file was not found, error code is \c UNZ_OK, not \c
|
||||
* UNZ_END_OF_LIST_OF_FILE (see also goToNextFile()).
|
||||
* - If this function fails, it unsets the current file rather than
|
||||
* resetting it back to what it was before the call.
|
||||
*
|
||||
* If \a fileName is null string then this function unsets the
|
||||
* current file and return \c true. Note that you should close the
|
||||
* file first if it is open! See
|
||||
* QuaZipFile::QuaZipFile(QuaZip*,QObject*) for the details.
|
||||
*
|
||||
* Should be used only in QuaZip::mdUnzip mode.
|
||||
*
|
||||
* \sa setFileNameCodec(), CaseSensitivity
|
||||
**/
|
||||
bool setCurrentFile(const QString& fileName, CaseSensitivity cs =csDefault);
|
||||
/// Returns \c true if the current file has been set.
|
||||
bool hasCurrentFile()const {return hasCurrentFile_f;}
|
||||
/// Retrieves information about the current file.
|
||||
/** Fills the structure pointed by \a info. Returns \c true on
|
||||
* success, \c false otherwise. In the latter case structure pointed
|
||||
* by \a info remains untouched. If there was an error,
|
||||
* getZipError() returns error code.
|
||||
*
|
||||
* Should be used only in QuaZip::mdUnzip mode.
|
||||
*
|
||||
* Does nothing and returns \c false in any of the following cases.
|
||||
* - ZIP is not open;
|
||||
* - ZIP does not have current file;
|
||||
* - \a info is \c NULL;
|
||||
*
|
||||
* In all these cases getZipError() returns \c UNZ_OK since there
|
||||
* is no ZIP/UNZIP API call.
|
||||
**/
|
||||
bool getCurrentFileInfo(QuaZipFileInfo* info)const;
|
||||
/// Returns the current file name.
|
||||
/** Equivalent to calling getCurrentFileInfo() and then getting \c
|
||||
* name field of the QuaZipFileInfo structure, but faster and more
|
||||
* convenient.
|
||||
*
|
||||
* Should be used only in QuaZip::mdUnzip mode.
|
||||
**/
|
||||
QString getCurrentFileName()const;
|
||||
/// Returns \c unzFile handle.
|
||||
/** You can use this handle to directly call UNZIP part of the
|
||||
* ZIP/UNZIP package functions (see unzip.h).
|
||||
*
|
||||
* \warning When using the handle returned by this function, please
|
||||
* keep in mind that QuaZip class is unable to detect any changes
|
||||
* you make in the ZIP file state (e. g. changing current file, or
|
||||
* closing the handle). So please do not do anything with this
|
||||
* handle that is possible to do with the functions of this class.
|
||||
* Or at least return the handle in the original state before
|
||||
* calling some another function of this class (including implicit
|
||||
* destructor calls and calls from the QuaZipFile objects that refer
|
||||
* to this QuaZip instance!). So if you have changed the current
|
||||
* file in the ZIP archive - then change it back or you may
|
||||
* experience some strange behavior or even crashes.
|
||||
**/
|
||||
unzFile getUnzFile() {return unzFile_f;}
|
||||
/// Returns \c zipFile handle.
|
||||
/** You can use this handle to directly call ZIP part of the
|
||||
* ZIP/UNZIP package functions (see zip.h). Warnings about the
|
||||
* getUnzFile() function also apply to this function.
|
||||
**/
|
||||
zipFile getZipFile() {return zipFile_f;}
|
||||
};
|
||||
|
||||
#endif
|
442
saveToy/quazip/include/quazipfile.h
Normal file
442
saveToy/quazip/include/quazipfile.h
Normal file
@ -0,0 +1,442 @@
|
||||
#ifndef QUA_ZIPFILE_H
|
||||
#define QUA_ZIPFILE_H
|
||||
|
||||
/*
|
||||
-- A kind of "standard" GPL license statement --
|
||||
QuaZIP - a Qt/C++ wrapper for the ZIP/UNZIP package
|
||||
Copyright (C) 2005-2008 Sergey A. Tachenov
|
||||
|
||||
This program is free software; you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by the
|
||||
Free Software Foundation; either version 2 of the License, or (at your
|
||||
option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
|
||||
Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along
|
||||
with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
-- A kind of "standard" GPL license statement ends here --
|
||||
|
||||
See COPYING file for GPL.
|
||||
|
||||
You are also permitted to use QuaZIP under the terms of LGPL (see
|
||||
COPYING.LGPL). You are free to choose either license, but please note
|
||||
that QuaZIP makes use of Qt, which is not licensed under LGPL. So if
|
||||
you are using Open Source edition of Qt, you therefore MUST use GPL for
|
||||
your code based on QuaZIP, since it would be also based on Qt in this
|
||||
case. If you are Qt commercial license owner, then you are free to use
|
||||
QuaZIP as long as you respect either GPL or LGPL for QuaZIP code.
|
||||
**/
|
||||
|
||||
#include <QIODevice>
|
||||
|
||||
#include "quazip.h"
|
||||
#include "quazipnewinfo.h"
|
||||
|
||||
/// A file inside ZIP archive.
|
||||
/** \class QuaZipFile quazipfile.h <quazip/quazipfile.h>
|
||||
* This is the most interesting class. Not only it provides C++
|
||||
* interface to the ZIP/UNZIP package, but also integrates it with Qt by
|
||||
* subclassing QIODevice. This makes possible to access files inside ZIP
|
||||
* archive using QTextStream or QDataStream, for example. Actually, this
|
||||
* is the main purpose of the whole QuaZIP library.
|
||||
*
|
||||
* You can either use existing QuaZip instance to create instance of
|
||||
* this class or pass ZIP archive file name to this class, in which case
|
||||
* it will create internal QuaZip object. See constructors' descriptions
|
||||
* for details. Writing is only possible with the existing instance.
|
||||
*
|
||||
* \section quazipfile-sequential Sequential or random-access?
|
||||
*
|
||||
* At the first thought, QuaZipFile has fixed size, the start and the
|
||||
* end and should be therefore considered random-access device. But
|
||||
* there is one major obstacle to making it random-access: ZIP/UNZIP API
|
||||
* does not support seek() operation and the only way to implement it is
|
||||
* through reopening the file and re-reading to the required position,
|
||||
* but this is prohibitely slow.
|
||||
*
|
||||
* Therefore, QuaZipFile is considered to be a sequential device. This
|
||||
* has advantage of availability of the ungetChar() operation (QIODevice
|
||||
* does not implement it properly for non-sequential devices unless they
|
||||
* support seek()). Disadvantage is a somewhat strange behaviour of the
|
||||
* size() and pos() functions. This should be kept in mind while using
|
||||
* this class.
|
||||
*
|
||||
**/
|
||||
class QuaZipFile: public QIODevice {
|
||||
Q_OBJECT
|
||||
private:
|
||||
QuaZip *zip;
|
||||
QString fileName;
|
||||
QuaZip::CaseSensitivity caseSensitivity;
|
||||
bool raw;
|
||||
qint64 writePos;
|
||||
// these two are for writing raw files
|
||||
ulong uncompressedSize;
|
||||
quint32 crc;
|
||||
bool internal;
|
||||
int zipError;
|
||||
// these are not supported nor implemented
|
||||
QuaZipFile(const QuaZipFile& that);
|
||||
QuaZipFile& operator=(const QuaZipFile& that);
|
||||
void resetZipError()const {setZipError(UNZ_OK);}
|
||||
// const, but sets zipError!
|
||||
void setZipError(int zipError)const;
|
||||
protected:
|
||||
/// Implementation of the QIODevice::readData().
|
||||
qint64 readData(char *data, qint64 maxSize);
|
||||
/// Implementation of the QIODevice::writeData().
|
||||
qint64 writeData(const char *data, qint64 maxSize);
|
||||
public:
|
||||
/// Constructs a QuaZipFile instance.
|
||||
/** You should use setZipName() and setFileName() or setZip() before
|
||||
* trying to call open() on the constructed object.
|
||||
**/
|
||||
QuaZipFile();
|
||||
/// Constructs a QuaZipFile instance.
|
||||
/** \a parent argument specifies this object's parent object.
|
||||
*
|
||||
* You should use setZipName() and setFileName() or setZip() before
|
||||
* trying to call open() on the constructed object.
|
||||
**/
|
||||
QuaZipFile(QObject *parent);
|
||||
/// Constructs a QuaZipFile instance.
|
||||
/** \a parent argument specifies this object's parent object and \a
|
||||
* zipName specifies ZIP archive file name.
|
||||
*
|
||||
* You should use setFileName() before trying to call open() on the
|
||||
* constructed object.
|
||||
*
|
||||
* QuaZipFile constructed by this constructor can be used for read
|
||||
* only access. Use QuaZipFile(QuaZip*,QObject*) for writing.
|
||||
**/
|
||||
QuaZipFile(const QString& zipName, QObject *parent =NULL);
|
||||
/// Constructs a QuaZipFile instance.
|
||||
/** \a parent argument specifies this object's parent object, \a
|
||||
* zipName specifies ZIP archive file name and \a fileName and \a cs
|
||||
* specify a name of the file to open inside archive.
|
||||
*
|
||||
* QuaZipFile constructed by this constructor can be used for read
|
||||
* only access. Use QuaZipFile(QuaZip*,QObject*) for writing.
|
||||
*
|
||||
* \sa QuaZip::setCurrentFile()
|
||||
**/
|
||||
QuaZipFile(const QString& zipName, const QString& fileName,
|
||||
QuaZip::CaseSensitivity cs =QuaZip::csDefault, QObject *parent =NULL);
|
||||
/// Constructs a QuaZipFile instance.
|
||||
/** \a parent argument specifies this object's parent object.
|
||||
*
|
||||
* \a zip is the pointer to the existing QuaZip object. This
|
||||
* QuaZipFile object then can be used to read current file in the
|
||||
* \a zip or to write to the file inside it.
|
||||
*
|
||||
* \warning Using this constructor for reading current file can be
|
||||
* tricky. Let's take the following example:
|
||||
* \code
|
||||
* QuaZip zip("archive.zip");
|
||||
* zip.open(QuaZip::mdUnzip);
|
||||
* zip.setCurrentFile("file-in-archive");
|
||||
* QuaZipFile file(&zip);
|
||||
* file.open(QIODevice::ReadOnly);
|
||||
* // ok, now we can read from the file
|
||||
* file.read(somewhere, some);
|
||||
* zip.setCurrentFile("another-file-in-archive"); // oops...
|
||||
* QuaZipFile anotherFile(&zip);
|
||||
* anotherFile.open(QIODevice::ReadOnly);
|
||||
* anotherFile.read(somewhere, some); // this is still ok...
|
||||
* file.read(somewhere, some); // and this is NOT
|
||||
* \endcode
|
||||
* So, what exactly happens here? When we change current file in the
|
||||
* \c zip archive, \c file that references it becomes invalid
|
||||
* (actually, as far as I understand ZIP/UNZIP sources, it becomes
|
||||
* closed, but QuaZipFile has no means to detect it).
|
||||
*
|
||||
* Summary: do not close \c zip object or change its current file as
|
||||
* long as QuaZipFile is open. Even better - use another constructors
|
||||
* which create internal QuaZip instances, one per object, and
|
||||
* therefore do not cause unnecessary trouble. This constructor may
|
||||
* be useful, though, if you already have a QuaZip instance and do
|
||||
* not want to access several files at once. Good example:
|
||||
* \code
|
||||
* QuaZip zip("archive.zip");
|
||||
* zip.open(QuaZip::mdUnzip);
|
||||
* // first, we need some information about archive itself
|
||||
* QByteArray comment=zip.getComment();
|
||||
* // and now we are going to access files inside it
|
||||
* QuaZipFile file(&zip);
|
||||
* for(bool more=zip.goToFirstFile(); more; more=zip.goToNextFile()) {
|
||||
* file.open(QIODevice::ReadOnly);
|
||||
* // do something cool with file here
|
||||
* file.close(); // do not forget to close!
|
||||
* }
|
||||
* zip.close();
|
||||
* \endcode
|
||||
**/
|
||||
QuaZipFile(QuaZip *zip, QObject *parent =NULL);
|
||||
/// Destroys a QuaZipFile instance.
|
||||
/** Closes file if open, destructs internal QuaZip object (if it
|
||||
* exists and \em is internal, of course).
|
||||
**/
|
||||
virtual ~QuaZipFile();
|
||||
/// Returns the ZIP archive file name.
|
||||
/** If this object was created by passing QuaZip pointer to the
|
||||
* constructor, this function will return that QuaZip's file name
|
||||
* (or null string if that object does not have file name yet).
|
||||
*
|
||||
* Otherwise, returns associated ZIP archive file name or null
|
||||
* string if there are no name set yet.
|
||||
*
|
||||
* \sa setZipName() getFileName()
|
||||
**/
|
||||
QString getZipName()const;
|
||||
/// Returns a pointer to the associated QuaZip object.
|
||||
/** Returns \c NULL if there is no associated QuaZip or it is
|
||||
* internal (so you will not mess with it).
|
||||
**/
|
||||
QuaZip* getZip()const;
|
||||
/// Returns file name.
|
||||
/** This function returns file name you passed to this object either
|
||||
* by using
|
||||
* QuaZipFile(const QString&,const QString&,QuaZip::CaseSensitivity,QObject*)
|
||||
* or by calling setFileName(). Real name of the file may differ in
|
||||
* case if you used case-insensitivity.
|
||||
*
|
||||
* Returns null string if there is no file name set yet. This is the
|
||||
* case when this QuaZipFile operates on the existing QuaZip object
|
||||
* (constructor QuaZipFile(QuaZip*,QObject*) or setZip() was used).
|
||||
*
|
||||
* \sa getActualFileName
|
||||
**/
|
||||
QString getFileName()const {return fileName;}
|
||||
/// Returns case sensitivity of the file name.
|
||||
/** This function returns case sensitivity argument you passed to
|
||||
* this object either by using
|
||||
* QuaZipFile(const QString&,const QString&,QuaZip::CaseSensitivity,QObject*)
|
||||
* or by calling setFileName().
|
||||
*
|
||||
* Returns unpredictable value if getFileName() returns null string
|
||||
* (this is the case when you did not used setFileName() or
|
||||
* constructor above).
|
||||
*
|
||||
* \sa getFileName
|
||||
**/
|
||||
QuaZip::CaseSensitivity getCaseSensitivity()const {return caseSensitivity;}
|
||||
/// Returns the actual file name in the archive.
|
||||
/** This is \em not a ZIP archive file name, but a name of file inside
|
||||
* archive. It is not necessary the same name that you have passed
|
||||
* to the
|
||||
* QuaZipFile(const QString&,const QString&,QuaZip::CaseSensitivity,QObject*),
|
||||
* setFileName() or QuaZip::setCurrentFile() - this is the real file
|
||||
* name inside archive, so it may differ in case if the file name
|
||||
* search was case-insensitive.
|
||||
*
|
||||
* Equivalent to calling getCurrentFileName() on the associated
|
||||
* QuaZip object. Returns null string if there is no associated
|
||||
* QuaZip object or if it does not have a current file yet. And this
|
||||
* is the case if you called setFileName() but did not open the
|
||||
* file yet. So this is perfectly fine:
|
||||
* \code
|
||||
* QuaZipFile file("somezip.zip");
|
||||
* file.setFileName("somefile");
|
||||
* QString name=file.getName(); // name=="somefile"
|
||||
* QString actual=file.getActualFileName(); // actual is null string
|
||||
* file.open(QIODevice::ReadOnly);
|
||||
* QString actual=file.getActualFileName(); // actual can be "SoMeFiLe" on Windows
|
||||
* \endcode
|
||||
*
|
||||
* \sa getZipName(), getFileName(), QuaZip::CaseSensitivity
|
||||
**/
|
||||
QString getActualFileName()const;
|
||||
/// Sets the ZIP archive file name.
|
||||
/** Automatically creates internal QuaZip object and destroys
|
||||
* previously created internal QuaZip object, if any.
|
||||
*
|
||||
* Will do nothing if this file is already open. You must close() it
|
||||
* first.
|
||||
**/
|
||||
void setZipName(const QString& zipName);
|
||||
/// Returns \c true if the file was opened in raw mode.
|
||||
/** If the file is not open, the returned value is undefined.
|
||||
*
|
||||
* \sa open(OpenMode,int*,int*,bool,const char*)
|
||||
**/
|
||||
bool isRaw()const {return raw;}
|
||||
/// Binds to the existing QuaZip instance.
|
||||
/** This function destroys internal QuaZip object, if any, and makes
|
||||
* this QuaZipFile to use current file in the \a zip object for any
|
||||
* further operations. See QuaZipFile(QuaZip*,QObject*) for the
|
||||
* possible pitfalls.
|
||||
*
|
||||
* Will do nothing if the file is currently open. You must close()
|
||||
* it first.
|
||||
**/
|
||||
void setZip(QuaZip *zip);
|
||||
/// Sets the file name.
|
||||
/** Will do nothing if at least one of the following conditions is
|
||||
* met:
|
||||
* - ZIP name has not been set yet (getZipName() returns null
|
||||
* string).
|
||||
* - This QuaZipFile is associated with external QuaZip. In this
|
||||
* case you should call that QuaZip's setCurrentFile() function
|
||||
* instead!
|
||||
* - File is already open so setting the name is meaningless.
|
||||
*
|
||||
* \sa QuaZip::setCurrentFile
|
||||
**/
|
||||
void setFileName(const QString& fileName, QuaZip::CaseSensitivity cs =QuaZip::csDefault);
|
||||
/// Opens a file for reading.
|
||||
/** Returns \c true on success, \c false otherwise.
|
||||
* Call getZipError() to get error code.
|
||||
*
|
||||
* \note Since ZIP/UNZIP API provides buffered reading only,
|
||||
* QuaZipFile does not support unbuffered reading. So do not pass
|
||||
* QIODevice::Unbuffered flag in \a mode, or open will fail.
|
||||
**/
|
||||
virtual bool open(OpenMode mode);
|
||||
/// Opens a file for reading.
|
||||
/** \overload
|
||||
* Argument \a password specifies a password to decrypt the file. If
|
||||
* it is NULL then this function behaves just like open(OpenMode).
|
||||
**/
|
||||
bool open(OpenMode mode, const char *password)
|
||||
{return open(mode, NULL, NULL, false, password);}
|
||||
/// Opens a file for reading.
|
||||
/** \overload
|
||||
* Argument \a password specifies a password to decrypt the file.
|
||||
*
|
||||
* An integers pointed by \a method and \a level will receive codes
|
||||
* of the compression method and level used. See unzip.h.
|
||||
*
|
||||
* If raw is \c true then no decompression is performed.
|
||||
*
|
||||
* \a method should not be \c NULL. \a level can be \c NULL if you
|
||||
* don't want to know the compression level.
|
||||
**/
|
||||
bool open(OpenMode mode, int *method, int *level, bool raw, const char *password =NULL);
|
||||
/// Opens a file for writing.
|
||||
/** \a info argument specifies information about file. It should at
|
||||
* least specify a correct file name. Also, it is a good idea to
|
||||
* specify correct timestamp (by default, current time will be
|
||||
* used). See QuaZipNewInfo.
|
||||
*
|
||||
* Arguments \a password and \a crc provide necessary information
|
||||
* for crypting. Note that you should specify both of them if you
|
||||
* need crypting. If you do not, pass \c NULL as password, but you
|
||||
* still need to specify \a crc if you are going to use raw mode
|
||||
* (see below).
|
||||
*
|
||||
* Arguments \a method and \a level specify compression method and
|
||||
* level.
|
||||
*
|
||||
* If \a raw is \c true, no compression is performed. In this case,
|
||||
* \a crc and uncompressedSize field of the \a info are required.
|
||||
*
|
||||
* Arguments \a windowBits, \a memLevel, \a strategy provide zlib
|
||||
* algorithms tuning. See deflateInit2() in zlib.
|
||||
**/
|
||||
bool open(OpenMode mode, const QuaZipNewInfo& info,
|
||||
const char *password =NULL, quint32 crc =0,
|
||||
int method =Z_DEFLATED, int level =Z_DEFAULT_COMPRESSION, bool raw =false,
|
||||
int windowBits =-MAX_WBITS, int memLevel =DEF_MEM_LEVEL, int strategy =Z_DEFAULT_STRATEGY);
|
||||
/// Returns \c true, but \ref quazipfile-sequential "beware"!
|
||||
virtual bool isSequential()const;
|
||||
/// Returns current position in the file.
|
||||
/** Implementation of the QIODevice::pos(). When reading, this
|
||||
* function is a wrapper to the ZIP/UNZIP unztell(), therefore it is
|
||||
* unable to keep track of the ungetChar() calls (which is
|
||||
* non-virtual and therefore is dangerous to reimplement). So if you
|
||||
* are using ungetChar() feature of the QIODevice, this function
|
||||
* reports incorrect value until you get back characters which you
|
||||
* ungot.
|
||||
*
|
||||
* When writing, pos() returns number of bytes already written
|
||||
* (uncompressed unless you use raw mode).
|
||||
*
|
||||
* \note Although
|
||||
* \ref quazipfile-sequential "QuaZipFile is a sequential device"
|
||||
* and therefore pos() should always return zero, it does not,
|
||||
* because it would be misguiding. Keep this in mind.
|
||||
*
|
||||
* This function returns -1 if the file or archive is not open.
|
||||
*
|
||||
* Error code returned by getZipError() is not affected by this
|
||||
* function call.
|
||||
**/
|
||||
virtual qint64 pos()const;
|
||||
/// Returns \c true if the end of file was reached.
|
||||
/** This function returns \c false in the case of error. This means
|
||||
* that you called this function on either not open file, or a file
|
||||
* in the not open archive or even on a QuaZipFile instance that
|
||||
* does not even have QuaZip instance associated. Do not do that
|
||||
* because there is no means to determine whether \c false is
|
||||
* returned because of error or because end of file was reached.
|
||||
* Well, on the other side you may interpret \c false return value
|
||||
* as "there is no file open to check for end of file and there is
|
||||
* no end of file therefore".
|
||||
*
|
||||
* When writing, this function always returns \c true (because you
|
||||
* are always writing to the end of file).
|
||||
*
|
||||
* Error code returned by getZipError() is not affected by this
|
||||
* function call.
|
||||
**/
|
||||
virtual bool atEnd()const;
|
||||
/// Returns file size.
|
||||
/** This function returns csize() if the file is open for reading in
|
||||
* raw mode, usize() if it is open for reading in normal mode and
|
||||
* pos() if it is open for writing.
|
||||
*
|
||||
* Returns -1 on error, call getZipError() to get error code.
|
||||
*
|
||||
* \note This function returns file size despite that
|
||||
* \ref quazipfile-sequential "QuaZipFile is considered to be sequential device",
|
||||
* for which size() should return bytesAvailable() instead. But its
|
||||
* name would be very misguiding otherwise, so just keep in mind
|
||||
* this inconsistence.
|
||||
**/
|
||||
virtual qint64 size()const;
|
||||
/// Returns compressed file size.
|
||||
/** Equivalent to calling getFileInfo() and then getting
|
||||
* compressedSize field, but more convenient and faster.
|
||||
*
|
||||
* File must be open for reading before calling this function.
|
||||
*
|
||||
* Returns -1 on error, call getZipError() to get error code.
|
||||
**/
|
||||
qint64 csize()const;
|
||||
/// Returns uncompressed file size.
|
||||
/** Equivalent to calling getFileInfo() and then getting
|
||||
* uncompressedSize field, but more convenient and faster. See
|
||||
* getFileInfo() for a warning.
|
||||
*
|
||||
* File must be open for reading before calling this function.
|
||||
*
|
||||
* Returns -1 on error, call getZipError() to get error code.
|
||||
**/
|
||||
qint64 usize()const;
|
||||
/// Gets information about current file.
|
||||
/** This function does the same thing as calling
|
||||
* QuaZip::getCurrentFileInfo() on the associated QuaZip object,
|
||||
* but you can not call getCurrentFileInfo() if the associated
|
||||
* QuaZip is internal (because you do not have access to it), while
|
||||
* you still can call this function in that case.
|
||||
*
|
||||
* File must be open for reading before calling this function.
|
||||
*
|
||||
* Returns \c false in the case of an error.
|
||||
**/
|
||||
bool getFileInfo(QuaZipFileInfo *info);
|
||||
/// Closes the file.
|
||||
/** Call getZipError() to determine if the close was successful.
|
||||
**/
|
||||
virtual void close();
|
||||
/// Returns the error code returned by the last ZIP/UNZIP API call.
|
||||
int getZipError()const {return zipError;}
|
||||
};
|
||||
|
||||
#endif
|
73
saveToy/quazip/include/quazipfileinfo.h
Normal file
73
saveToy/quazip/include/quazipfileinfo.h
Normal file
@ -0,0 +1,73 @@
|
||||
#ifndef QUA_ZIPFILEINFO_H
|
||||
#define QUA_ZIPFILEINFO_H
|
||||
|
||||
/*
|
||||
-- A kind of "standard" GPL license statement --
|
||||
QuaZIP - a Qt/C++ wrapper for the ZIP/UNZIP package
|
||||
Copyright (C) 2005-2007 Sergey A. Tachenov
|
||||
|
||||
This program is free software; you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by the
|
||||
Free Software Foundation; either version 2 of the License, or (at your
|
||||
option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
|
||||
Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along
|
||||
with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
-- A kind of "standard" GPL license statement ends here --
|
||||
|
||||
See COPYING file for GPL.
|
||||
|
||||
You are also permitted to use QuaZIP under the terms of LGPL (see
|
||||
COPYING.LGPL). You are free to choose either license, but please note
|
||||
that QuaZIP makes use of Qt, which is not licensed under LGPL. So if
|
||||
you are using Open Source edition of Qt, you therefore MUST use GPL for
|
||||
your code based on QuaZIP, since it would be also based on Qt in this
|
||||
case. If you are Qt commercial license owner, then you are free to use
|
||||
QuaZIP as long as you respect either GPL or LGPL for QuaZIP code.
|
||||
**/
|
||||
|
||||
#include <QByteArray>
|
||||
#include <QDateTime>
|
||||
|
||||
/// Information about a file inside archive.
|
||||
/** Call QuaZip::getCurrentFileInfo() or QuaZipFile::getFileInfo() to
|
||||
* fill this structure. */
|
||||
struct QuaZipFileInfo {
|
||||
/// File name.
|
||||
QString name;
|
||||
/// Version created by.
|
||||
quint16 versionCreated;
|
||||
/// Version needed to extract.
|
||||
quint16 versionNeeded;
|
||||
/// General purpose flags.
|
||||
quint16 flags;
|
||||
/// Compression method.
|
||||
quint16 method;
|
||||
/// Last modification date and time.
|
||||
QDateTime dateTime;
|
||||
/// CRC.
|
||||
quint32 crc;
|
||||
/// Compressed file size.
|
||||
quint32 compressedSize;
|
||||
/// Uncompressed file size.
|
||||
quint32 uncompressedSize;
|
||||
/// Disk number start.
|
||||
quint16 diskNumberStart;
|
||||
/// Internal file attributes.
|
||||
quint16 internalAttr;
|
||||
/// External file attributes.
|
||||
quint32 externalAttr;
|
||||
/// Comment.
|
||||
QString comment;
|
||||
/// Extra field.
|
||||
QByteArray extra;
|
||||
};
|
||||
|
||||
#endif
|
109
saveToy/quazip/include/quazipnewinfo.h
Normal file
109
saveToy/quazip/include/quazipnewinfo.h
Normal file
@ -0,0 +1,109 @@
|
||||
#ifndef QUA_ZIPNEWINFO_H
|
||||
#define QUA_ZIPNEWINFO_H
|
||||
|
||||
/*
|
||||
-- A kind of "standard" GPL license statement --
|
||||
QuaZIP - a Qt/C++ wrapper for the ZIP/UNZIP package
|
||||
Copyright (C) 2005-2007 Sergey A. Tachenov
|
||||
|
||||
This program is free software; you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by the
|
||||
Free Software Foundation; either version 2 of the License, or (at your
|
||||
option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
|
||||
Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along
|
||||
with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
-- A kind of "standard" GPL license statement ends here --
|
||||
|
||||
See COPYING file for GPL.
|
||||
|
||||
You are also permitted to use QuaZIP under the terms of LGPL (see
|
||||
COPYING.LGPL). You are free to choose either license, but please note
|
||||
that QuaZIP makes use of Qt, which is not licensed under LGPL. So if
|
||||
you are using Open Source edition of Qt, you therefore MUST use GPL for
|
||||
your code based on QuaZIP, since it would be also based on Qt in this
|
||||
case. If you are Qt commercial license owner, then you are free to use
|
||||
QuaZIP as long as you respect either GPL or LGPL for QuaZIP code.
|
||||
**/
|
||||
|
||||
#include <QDateTime>
|
||||
#include <QString>
|
||||
|
||||
/// Information about a file to be created.
|
||||
/** This structure holds information about a file to be created inside
|
||||
* ZIP archive. At least name should be set to something correct before
|
||||
* passing this structure to
|
||||
* QuaZipFile::open(OpenMode,const QuaZipNewInfo&,int,int,bool).
|
||||
**/
|
||||
struct QuaZipNewInfo {
|
||||
/// File name.
|
||||
/** This field holds file name inside archive, including path relative
|
||||
* to archive root.
|
||||
**/
|
||||
QString name;
|
||||
/// File timestamp.
|
||||
/** This is the last file modification date and time. Will be stored
|
||||
* in the archive central directory. It is a good practice to set it
|
||||
* to the source file timestamp instead of archive creating time. Use
|
||||
* setFileDateTime() or QuaZipNewInfo(const QString&, const QString&).
|
||||
**/
|
||||
QDateTime dateTime;
|
||||
/// File internal attributes.
|
||||
quint16 internalAttr;
|
||||
/// File external attributes.
|
||||
quint32 externalAttr;
|
||||
/// File comment.
|
||||
/** Will be encoded using QuaZip::getCommentCodec().
|
||||
**/
|
||||
QString comment;
|
||||
/// File local extra field.
|
||||
QByteArray extraLocal;
|
||||
/// File global extra field.
|
||||
QByteArray extraGlobal;
|
||||
/// Uncompressed file size.
|
||||
/** This is only needed if you are using raw file zipping mode, i. e.
|
||||
* adding precompressed file in the zip archive.
|
||||
**/
|
||||
ulong uncompressedSize;
|
||||
/// Constructs QuaZipNewInfo instance.
|
||||
/** Initializes name with \a name, dateTime with current date and
|
||||
* time. Attributes are initialized with zeros, comment and extra
|
||||
* field with null values.
|
||||
**/
|
||||
QuaZipNewInfo(const QString& name);
|
||||
/// Constructs QuaZipNewInfo instance.
|
||||
/** Initializes name with \a name and dateTime with timestamp of the
|
||||
* file named \a file. If the \a file does not exists or its timestamp
|
||||
* is inaccessible (e. g. you do not have read permission for the
|
||||
* directory file in), uses current date and time. Attributes are
|
||||
* initialized with zeros, comment and extra field with null values.
|
||||
*
|
||||
* \sa setFileDateTime()
|
||||
**/
|
||||
QuaZipNewInfo(const QString& name, const QString& file);
|
||||
/// Sets the file timestamp from the existing file.
|
||||
/** Use this function to set the file timestamp from the existing
|
||||
* file. Use it like this:
|
||||
* \code
|
||||
* QuaZipFile zipFile(&zip);
|
||||
* QFile file("file-to-add");
|
||||
* file.open(QIODevice::ReadOnly);
|
||||
* QuaZipNewInfo info("file-name-in-archive");
|
||||
* info.setFileDateTime("file-to-add"); // take the timestamp from file
|
||||
* zipFile.open(QIODevice::WriteOnly, info);
|
||||
* \endcode
|
||||
*
|
||||
* This function does not change dateTime if some error occured (e. g.
|
||||
* file is inaccessible).
|
||||
**/
|
||||
void setFileDateTime(const QString& file);
|
||||
};
|
||||
|
||||
#endif
|
354
saveToy/quazip/include/unzip.h
Normal file
354
saveToy/quazip/include/unzip.h
Normal file
@ -0,0 +1,354 @@
|
||||
/* unzip.h -- IO for uncompress .zip files using zlib
|
||||
Version 1.01e, February 12th, 2005
|
||||
|
||||
Copyright (C) 1998-2005 Gilles Vollant
|
||||
|
||||
This unzip package allow extract file from .ZIP file, compatible with PKZip 2.04g
|
||||
WinZip, InfoZip tools and compatible.
|
||||
|
||||
Multi volume ZipFile (span) are not supported.
|
||||
Encryption compatible with pkzip 2.04g only supported
|
||||
Old compressions used by old PKZip 1.x are not supported
|
||||
|
||||
|
||||
I WAIT FEEDBACK at mail info@winimage.com
|
||||
Visit also http://www.winimage.com/zLibDll/unzip.htm for evolution
|
||||
|
||||
Condition of use and distribution are the same than zlib :
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
|
||||
|
||||
*/
|
||||
|
||||
/* for more info about .ZIP format, see
|
||||
http://www.info-zip.org/pub/infozip/doc/appnote-981119-iz.zip
|
||||
http://www.info-zip.org/pub/infozip/doc/
|
||||
PkWare has also a specification at :
|
||||
ftp://ftp.pkware.com/probdesc.zip
|
||||
*/
|
||||
|
||||
#ifndef _unz_H
|
||||
#define _unz_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifndef _ZLIB_H
|
||||
#include "zlib.h"
|
||||
#endif
|
||||
|
||||
#ifndef _ZLIBIOAPI_H
|
||||
#include "ioapi.h"
|
||||
#endif
|
||||
|
||||
#if defined(STRICTUNZIP) || defined(STRICTZIPUNZIP)
|
||||
/* like the STRICT of WIN32, we define a pointer that cannot be converted
|
||||
from (void*) without cast */
|
||||
typedef struct TagunzFile__ { int unused; } unzFile__;
|
||||
typedef unzFile__ *unzFile;
|
||||
#else
|
||||
typedef voidp unzFile;
|
||||
#endif
|
||||
|
||||
|
||||
#define UNZ_OK (0)
|
||||
#define UNZ_END_OF_LIST_OF_FILE (-100)
|
||||
#define UNZ_ERRNO (Z_ERRNO)
|
||||
#define UNZ_EOF (0)
|
||||
#define UNZ_PARAMERROR (-102)
|
||||
#define UNZ_BADZIPFILE (-103)
|
||||
#define UNZ_INTERNALERROR (-104)
|
||||
#define UNZ_CRCERROR (-105)
|
||||
|
||||
/* tm_unz contain date/time info */
|
||||
typedef struct tm_unz_s
|
||||
{
|
||||
uInt tm_sec; /* seconds after the minute - [0,59] */
|
||||
uInt tm_min; /* minutes after the hour - [0,59] */
|
||||
uInt tm_hour; /* hours since midnight - [0,23] */
|
||||
uInt tm_mday; /* day of the month - [1,31] */
|
||||
uInt tm_mon; /* months since January - [0,11] */
|
||||
uInt tm_year; /* years - [1980..2044] */
|
||||
} tm_unz;
|
||||
|
||||
/* unz_global_info structure contain global data about the ZIPfile
|
||||
These data comes from the end of central dir */
|
||||
typedef struct unz_global_info_s
|
||||
{
|
||||
uLong number_entry; /* total number of entries in
|
||||
the central dir on this disk */
|
||||
uLong size_comment; /* size of the global comment of the zipfile */
|
||||
} unz_global_info;
|
||||
|
||||
|
||||
/* unz_file_info contain information about a file in the zipfile */
|
||||
typedef struct unz_file_info_s
|
||||
{
|
||||
uLong version; /* version made by 2 bytes */
|
||||
uLong version_needed; /* version needed to extract 2 bytes */
|
||||
uLong flag; /* general purpose bit flag 2 bytes */
|
||||
uLong compression_method; /* compression method 2 bytes */
|
||||
uLong dosDate; /* last mod file date in Dos fmt 4 bytes */
|
||||
uLong crc; /* crc-32 4 bytes */
|
||||
uLong compressed_size; /* compressed size 4 bytes */
|
||||
uLong uncompressed_size; /* uncompressed size 4 bytes */
|
||||
uLong size_filename; /* filename length 2 bytes */
|
||||
uLong size_file_extra; /* extra field length 2 bytes */
|
||||
uLong size_file_comment; /* file comment length 2 bytes */
|
||||
|
||||
uLong disk_num_start; /* disk number start 2 bytes */
|
||||
uLong internal_fa; /* internal file attributes 2 bytes */
|
||||
uLong external_fa; /* external file attributes 4 bytes */
|
||||
|
||||
tm_unz tmu_date;
|
||||
} unz_file_info;
|
||||
|
||||
extern int ZEXPORT unzStringFileNameCompare OF ((const char* fileName1,
|
||||
const char* fileName2,
|
||||
int iCaseSensitivity));
|
||||
/*
|
||||
Compare two filename (fileName1,fileName2).
|
||||
If iCaseSenisivity = 1, comparision is case sensitivity (like strcmp)
|
||||
If iCaseSenisivity = 2, comparision is not case sensitivity (like strcmpi
|
||||
or strcasecmp)
|
||||
If iCaseSenisivity = 0, case sensitivity is defaut of your operating system
|
||||
(like 1 on Unix, 2 on Windows)
|
||||
*/
|
||||
|
||||
|
||||
extern unzFile ZEXPORT unzOpen OF((const char *path));
|
||||
/*
|
||||
Open a Zip file. path contain the full pathname (by example,
|
||||
on a Windows XP computer "c:\\zlib\\zlib113.zip" or on an Unix computer
|
||||
"zlib/zlib113.zip".
|
||||
If the zipfile cannot be opened (file don't exist or in not valid), the
|
||||
return value is NULL.
|
||||
Else, the return value is a unzFile Handle, usable with other function
|
||||
of this unzip package.
|
||||
*/
|
||||
|
||||
extern unzFile ZEXPORT unzOpen2 OF((const char *path,
|
||||
zlib_filefunc_def* pzlib_filefunc_def));
|
||||
/*
|
||||
Open a Zip file, like unzOpen, but provide a set of file low level API
|
||||
for read/write the zip file (see ioapi.h)
|
||||
*/
|
||||
|
||||
extern int ZEXPORT unzClose OF((unzFile file));
|
||||
/*
|
||||
Close a ZipFile opened with unzipOpen.
|
||||
If there is files inside the .Zip opened with unzOpenCurrentFile (see later),
|
||||
these files MUST be closed with unzipCloseCurrentFile before call unzipClose.
|
||||
return UNZ_OK if there is no problem. */
|
||||
|
||||
extern int ZEXPORT unzGetGlobalInfo OF((unzFile file,
|
||||
unz_global_info *pglobal_info));
|
||||
/*
|
||||
Write info about the ZipFile in the *pglobal_info structure.
|
||||
No preparation of the structure is needed
|
||||
return UNZ_OK if there is no problem. */
|
||||
|
||||
|
||||
extern int ZEXPORT unzGetGlobalComment OF((unzFile file,
|
||||
char *szComment,
|
||||
uLong uSizeBuf));
|
||||
/*
|
||||
Get the global comment string of the ZipFile, in the szComment buffer.
|
||||
uSizeBuf is the size of the szComment buffer.
|
||||
return the number of byte copied or an error code <0
|
||||
*/
|
||||
|
||||
|
||||
/***************************************************************************/
|
||||
/* Unzip package allow you browse the directory of the zipfile */
|
||||
|
||||
extern int ZEXPORT unzGoToFirstFile OF((unzFile file));
|
||||
/*
|
||||
Set the current file of the zipfile to the first file.
|
||||
return UNZ_OK if there is no problem
|
||||
*/
|
||||
|
||||
extern int ZEXPORT unzGoToNextFile OF((unzFile file));
|
||||
/*
|
||||
Set the current file of the zipfile to the next file.
|
||||
return UNZ_OK if there is no problem
|
||||
return UNZ_END_OF_LIST_OF_FILE if the actual file was the latest.
|
||||
*/
|
||||
|
||||
extern int ZEXPORT unzLocateFile OF((unzFile file,
|
||||
const char *szFileName,
|
||||
int iCaseSensitivity));
|
||||
/*
|
||||
Try locate the file szFileName in the zipfile.
|
||||
For the iCaseSensitivity signification, see unzStringFileNameCompare
|
||||
|
||||
return value :
|
||||
UNZ_OK if the file is found. It becomes the current file.
|
||||
UNZ_END_OF_LIST_OF_FILE if the file is not found
|
||||
*/
|
||||
|
||||
|
||||
/* ****************************************** */
|
||||
/* Ryan supplied functions */
|
||||
/* unz_file_info contain information about a file in the zipfile */
|
||||
typedef struct unz_file_pos_s
|
||||
{
|
||||
uLong pos_in_zip_directory; /* offset in zip file directory */
|
||||
uLong num_of_file; /* # of file */
|
||||
} unz_file_pos;
|
||||
|
||||
extern int ZEXPORT unzGetFilePos(
|
||||
unzFile file,
|
||||
unz_file_pos* file_pos);
|
||||
|
||||
extern int ZEXPORT unzGoToFilePos(
|
||||
unzFile file,
|
||||
unz_file_pos* file_pos);
|
||||
|
||||
/* ****************************************** */
|
||||
|
||||
extern int ZEXPORT unzGetCurrentFileInfo OF((unzFile file,
|
||||
unz_file_info *pfile_info,
|
||||
char *szFileName,
|
||||
uLong fileNameBufferSize,
|
||||
void *extraField,
|
||||
uLong extraFieldBufferSize,
|
||||
char *szComment,
|
||||
uLong commentBufferSize));
|
||||
/*
|
||||
Get Info about the current file
|
||||
if pfile_info!=NULL, the *pfile_info structure will contain somes info about
|
||||
the current file
|
||||
if szFileName!=NULL, the filemane string will be copied in szFileName
|
||||
(fileNameBufferSize is the size of the buffer)
|
||||
if extraField!=NULL, the extra field information will be copied in extraField
|
||||
(extraFieldBufferSize is the size of the buffer).
|
||||
This is the Central-header version of the extra field
|
||||
if szComment!=NULL, the comment string of the file will be copied in szComment
|
||||
(commentBufferSize is the size of the buffer)
|
||||
*/
|
||||
|
||||
/***************************************************************************/
|
||||
/* for reading the content of the current zipfile, you can open it, read data
|
||||
from it, and close it (you can close it before reading all the file)
|
||||
*/
|
||||
|
||||
extern int ZEXPORT unzOpenCurrentFile OF((unzFile file));
|
||||
/*
|
||||
Open for reading data the current file in the zipfile.
|
||||
If there is no error, the return value is UNZ_OK.
|
||||
*/
|
||||
|
||||
extern int ZEXPORT unzOpenCurrentFilePassword OF((unzFile file,
|
||||
const char* password));
|
||||
/*
|
||||
Open for reading data the current file in the zipfile.
|
||||
password is a crypting password
|
||||
If there is no error, the return value is UNZ_OK.
|
||||
*/
|
||||
|
||||
extern int ZEXPORT unzOpenCurrentFile2 OF((unzFile file,
|
||||
int* method,
|
||||
int* level,
|
||||
int raw));
|
||||
/*
|
||||
Same than unzOpenCurrentFile, but open for read raw the file (not uncompress)
|
||||
if raw==1
|
||||
*method will receive method of compression, *level will receive level of
|
||||
compression
|
||||
note : you can set level parameter as NULL (if you did not want known level,
|
||||
but you CANNOT set method parameter as NULL
|
||||
*/
|
||||
|
||||
extern int ZEXPORT unzOpenCurrentFile3 OF((unzFile file,
|
||||
int* method,
|
||||
int* level,
|
||||
int raw,
|
||||
const char* password));
|
||||
/*
|
||||
Same than unzOpenCurrentFile, but open for read raw the file (not uncompress)
|
||||
if raw==1
|
||||
*method will receive method of compression, *level will receive level of
|
||||
compression
|
||||
note : you can set level parameter as NULL (if you did not want known level,
|
||||
but you CANNOT set method parameter as NULL
|
||||
*/
|
||||
|
||||
|
||||
extern int ZEXPORT unzCloseCurrentFile OF((unzFile file));
|
||||
/*
|
||||
Close the file in zip opened with unzOpenCurrentFile
|
||||
Return UNZ_CRCERROR if all the file was read but the CRC is not good
|
||||
*/
|
||||
|
||||
extern int ZEXPORT unzReadCurrentFile OF((unzFile file,
|
||||
voidp buf,
|
||||
unsigned len));
|
||||
/*
|
||||
Read bytes from the current file (opened by unzOpenCurrentFile)
|
||||
buf contain buffer where data must be copied
|
||||
len the size of buf.
|
||||
|
||||
return the number of byte copied if somes bytes are copied
|
||||
return 0 if the end of file was reached
|
||||
return <0 with error code if there is an error
|
||||
(UNZ_ERRNO for IO error, or zLib error for uncompress error)
|
||||
*/
|
||||
|
||||
extern z_off_t ZEXPORT unztell OF((unzFile file));
|
||||
/*
|
||||
Give the current position in uncompressed data
|
||||
*/
|
||||
|
||||
extern int ZEXPORT unzeof OF((unzFile file));
|
||||
/*
|
||||
return 1 if the end of file was reached, 0 elsewhere
|
||||
*/
|
||||
|
||||
extern int ZEXPORT unzGetLocalExtrafield OF((unzFile file,
|
||||
voidp buf,
|
||||
unsigned len));
|
||||
/*
|
||||
Read extra field from the current file (opened by unzOpenCurrentFile)
|
||||
This is the local-header version of the extra field (sometimes, there is
|
||||
more info in the local-header version than in the central-header)
|
||||
|
||||
if buf==NULL, it return the size of the local extra field
|
||||
|
||||
if buf!=NULL, len is the size of the buffer, the extra header is copied in
|
||||
buf.
|
||||
the return value is the number of bytes copied in buf, or (if <0)
|
||||
the error code
|
||||
*/
|
||||
|
||||
/***************************************************************************/
|
||||
|
||||
/* Get the current file offset */
|
||||
extern uLong ZEXPORT unzGetOffset (unzFile file);
|
||||
|
||||
/* Set the current file offset */
|
||||
extern int ZEXPORT unzSetOffset (unzFile file, uLong pos);
|
||||
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _unz_H */
|
235
saveToy/quazip/include/zip.h
Normal file
235
saveToy/quazip/include/zip.h
Normal file
@ -0,0 +1,235 @@
|
||||
/* zip.h -- IO for compress .zip files using zlib
|
||||
Version 1.01e, February 12th, 2005
|
||||
|
||||
Copyright (C) 1998-2005 Gilles Vollant
|
||||
|
||||
This unzip package allow creates .ZIP file, compatible with PKZip 2.04g
|
||||
WinZip, InfoZip tools and compatible.
|
||||
Multi volume ZipFile (span) are not supported.
|
||||
Encryption compatible with pkzip 2.04g only supported
|
||||
Old compressions used by old PKZip 1.x are not supported
|
||||
|
||||
For uncompress .zip file, look at unzip.h
|
||||
|
||||
|
||||
I WAIT FEEDBACK at mail info@winimage.com
|
||||
Visit also http://www.winimage.com/zLibDll/unzip.html for evolution
|
||||
|
||||
Condition of use and distribution are the same than zlib :
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
|
||||
|
||||
*/
|
||||
|
||||
/* for more info about .ZIP format, see
|
||||
http://www.info-zip.org/pub/infozip/doc/appnote-981119-iz.zip
|
||||
http://www.info-zip.org/pub/infozip/doc/
|
||||
PkWare has also a specification at :
|
||||
ftp://ftp.pkware.com/probdesc.zip
|
||||
*/
|
||||
|
||||
#ifndef _zip_H
|
||||
#define _zip_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifndef _ZLIB_H
|
||||
#include "zlib.h"
|
||||
#endif
|
||||
|
||||
#ifndef _ZLIBIOAPI_H
|
||||
#include "ioapi.h"
|
||||
#endif
|
||||
|
||||
#if defined(STRICTZIP) || defined(STRICTZIPUNZIP)
|
||||
/* like the STRICT of WIN32, we define a pointer that cannot be converted
|
||||
from (void*) without cast */
|
||||
typedef struct TagzipFile__ { int unused; } zipFile__;
|
||||
typedef zipFile__ *zipFile;
|
||||
#else
|
||||
typedef voidp zipFile;
|
||||
#endif
|
||||
|
||||
#define ZIP_OK (0)
|
||||
#define ZIP_EOF (0)
|
||||
#define ZIP_ERRNO (Z_ERRNO)
|
||||
#define ZIP_PARAMERROR (-102)
|
||||
#define ZIP_BADZIPFILE (-103)
|
||||
#define ZIP_INTERNALERROR (-104)
|
||||
|
||||
#ifndef DEF_MEM_LEVEL
|
||||
# if MAX_MEM_LEVEL >= 8
|
||||
# define DEF_MEM_LEVEL 8
|
||||
# else
|
||||
# define DEF_MEM_LEVEL MAX_MEM_LEVEL
|
||||
# endif
|
||||
#endif
|
||||
/* default memLevel */
|
||||
|
||||
/* tm_zip contain date/time info */
|
||||
typedef struct tm_zip_s
|
||||
{
|
||||
uInt tm_sec; /* seconds after the minute - [0,59] */
|
||||
uInt tm_min; /* minutes after the hour - [0,59] */
|
||||
uInt tm_hour; /* hours since midnight - [0,23] */
|
||||
uInt tm_mday; /* day of the month - [1,31] */
|
||||
uInt tm_mon; /* months since January - [0,11] */
|
||||
uInt tm_year; /* years - [1980..2044] */
|
||||
} tm_zip;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
tm_zip tmz_date; /* date in understandable format */
|
||||
uLong dosDate; /* if dos_date == 0, tmu_date is used */
|
||||
/* uLong flag; */ /* general purpose bit flag 2 bytes */
|
||||
|
||||
uLong internal_fa; /* internal file attributes 2 bytes */
|
||||
uLong external_fa; /* external file attributes 4 bytes */
|
||||
} zip_fileinfo;
|
||||
|
||||
typedef const char* zipcharpc;
|
||||
|
||||
|
||||
#define APPEND_STATUS_CREATE (0)
|
||||
#define APPEND_STATUS_CREATEAFTER (1)
|
||||
#define APPEND_STATUS_ADDINZIP (2)
|
||||
|
||||
extern zipFile ZEXPORT zipOpen OF((const char *pathname, int append));
|
||||
/*
|
||||
Create a zipfile.
|
||||
pathname contain on Windows XP a filename like "c:\\zlib\\zlib113.zip" or on
|
||||
an Unix computer "zlib/zlib113.zip".
|
||||
if the file pathname exist and append==APPEND_STATUS_CREATEAFTER, the zip
|
||||
will be created at the end of the file.
|
||||
(useful if the file contain a self extractor code)
|
||||
if the file pathname exist and append==APPEND_STATUS_ADDINZIP, we will
|
||||
add files in existing zip (be sure you don't add file that doesn't exist)
|
||||
If the zipfile cannot be opened, the return value is NULL.
|
||||
Else, the return value is a zipFile Handle, usable with other function
|
||||
of this zip package.
|
||||
*/
|
||||
|
||||
/* Note : there is no delete function into a zipfile.
|
||||
If you want delete file into a zipfile, you must open a zipfile, and create another
|
||||
Of couse, you can use RAW reading and writing to copy the file you did not want delte
|
||||
*/
|
||||
|
||||
extern zipFile ZEXPORT zipOpen2 OF((const char *pathname,
|
||||
int append,
|
||||
zipcharpc* globalcomment,
|
||||
zlib_filefunc_def* pzlib_filefunc_def));
|
||||
|
||||
extern int ZEXPORT zipOpenNewFileInZip OF((zipFile file,
|
||||
const char* filename,
|
||||
const zip_fileinfo* zipfi,
|
||||
const void* extrafield_local,
|
||||
uInt size_extrafield_local,
|
||||
const void* extrafield_global,
|
||||
uInt size_extrafield_global,
|
||||
const char* comment,
|
||||
int method,
|
||||
int level));
|
||||
/*
|
||||
Open a file in the ZIP for writing.
|
||||
filename : the filename in zip (if NULL, '-' without quote will be used
|
||||
*zipfi contain supplemental information
|
||||
if extrafield_local!=NULL and size_extrafield_local>0, extrafield_local
|
||||
contains the extrafield data the the local header
|
||||
if extrafield_global!=NULL and size_extrafield_global>0, extrafield_global
|
||||
contains the extrafield data the the local header
|
||||
if comment != NULL, comment contain the comment string
|
||||
method contain the compression method (0 for store, Z_DEFLATED for deflate)
|
||||
level contain the level of compression (can be Z_DEFAULT_COMPRESSION)
|
||||
*/
|
||||
|
||||
|
||||
extern int ZEXPORT zipOpenNewFileInZip2 OF((zipFile file,
|
||||
const char* filename,
|
||||
const zip_fileinfo* zipfi,
|
||||
const void* extrafield_local,
|
||||
uInt size_extrafield_local,
|
||||
const void* extrafield_global,
|
||||
uInt size_extrafield_global,
|
||||
const char* comment,
|
||||
int method,
|
||||
int level,
|
||||
int raw));
|
||||
|
||||
/*
|
||||
Same than zipOpenNewFileInZip, except if raw=1, we write raw file
|
||||
*/
|
||||
|
||||
extern int ZEXPORT zipOpenNewFileInZip3 OF((zipFile file,
|
||||
const char* filename,
|
||||
const zip_fileinfo* zipfi,
|
||||
const void* extrafield_local,
|
||||
uInt size_extrafield_local,
|
||||
const void* extrafield_global,
|
||||
uInt size_extrafield_global,
|
||||
const char* comment,
|
||||
int method,
|
||||
int level,
|
||||
int raw,
|
||||
int windowBits,
|
||||
int memLevel,
|
||||
int strategy,
|
||||
const char* password,
|
||||
uLong crcForCtypting));
|
||||
|
||||
/*
|
||||
Same than zipOpenNewFileInZip2, except
|
||||
windowBits,memLevel,,strategy : see parameter strategy in deflateInit2
|
||||
password : crypting password (NULL for no crypting)
|
||||
crcForCtypting : crc of file to compress (needed for crypting)
|
||||
*/
|
||||
|
||||
|
||||
extern int ZEXPORT zipWriteInFileInZip OF((zipFile file,
|
||||
const void* buf,
|
||||
unsigned len));
|
||||
/*
|
||||
Write data in the zipfile
|
||||
*/
|
||||
|
||||
extern int ZEXPORT zipCloseFileInZip OF((zipFile file));
|
||||
/*
|
||||
Close the current file in the zipfile
|
||||
*/
|
||||
|
||||
extern int ZEXPORT zipCloseFileInZipRaw OF((zipFile file,
|
||||
uLong uncompressed_size,
|
||||
uLong crc32));
|
||||
/*
|
||||
Close the current file in the zipfile, for fiel opened with
|
||||
parameter raw=1 in zipOpenNewFileInZip2
|
||||
uncompressed_size and crc32 are value for the uncompressed size
|
||||
*/
|
||||
|
||||
extern int ZEXPORT zipClose OF((zipFile file,
|
||||
const char* global_comment));
|
||||
/*
|
||||
Close the zipfile
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _zip_H */
|
@ -17,16 +17,69 @@ SOURCES += main.cpp\
|
||||
../WiiQt/tools.cpp \
|
||||
../WiiQt/savebanner.cpp \
|
||||
../WiiQt/aes.c \
|
||||
../WiiQt/sha1.c
|
||||
../WiiQt/sha1.c \
|
||||
../WiiQt/md5.cpp \
|
||||
../WiiQt/sharedcontentmap.cpp \
|
||||
../WiiQt/tiktmd.cpp \
|
||||
../WiiQt/uidmap.cpp \
|
||||
../WiiQt/nanddump.cpp \
|
||||
../WiiQt/wad.cpp \
|
||||
../WiiQt/bn.cpp \
|
||||
../WiiQt/ec.cpp \
|
||||
../WiiQt/savedatabin.cpp \
|
||||
../WiiQt/keysbin.cpp \
|
||||
ngdialog.cpp \
|
||||
textdialog.cpp
|
||||
|
||||
HEADERS += mainwindow.h \
|
||||
savelistitem.h \
|
||||
saveloadthread.h\
|
||||
../WiiQt/tools.h
|
||||
../WiiQt/tools.h \
|
||||
../WiiQt/savebanner.h \
|
||||
../WiiQt/sharedcontentmap.h \
|
||||
../WiiQt/tiktmd.h \
|
||||
../WiiQt/uidmap.h \
|
||||
../WiiQt/nanddump.h \
|
||||
../WiiQt/wad.h \
|
||||
../WiiQt/savedatabin.h \
|
||||
../WiiQt/ec.h \
|
||||
../WiiQt/keysbin.h \
|
||||
quazip/include/zip.h \
|
||||
quazip/include/unzip.h \
|
||||
quazip/include/quazipnewinfo.h \
|
||||
quazip/include/quazipfileinfo.h \
|
||||
quazip/include/quazipfile.h \
|
||||
quazip/include/quazip.h \
|
||||
quazip/include/quacrc32.h \
|
||||
quazip/include/quachecksum32.h \
|
||||
quazip/include/quaadler32.h \
|
||||
quazip/include/JlCompress.h \
|
||||
quazip/include/ioapi.h \
|
||||
quazip/include/crypt.h \
|
||||
ngdialog.h \
|
||||
textdialog.h
|
||||
|
||||
FORMS += mainwindow.ui
|
||||
FORMS += mainwindow.ui \
|
||||
ngdialog.ui \
|
||||
textdialog.ui
|
||||
|
||||
RESOURCES += \
|
||||
rc.qrc
|
||||
|
||||
INCPATH += "../WiiQt"
|
||||
INCLUDEPATH += . ./quazip/include
|
||||
#different paths for different zip libraries
|
||||
win32 {
|
||||
message("still need to build quazlib for windows")
|
||||
}
|
||||
unix {
|
||||
!contains(QMAKE_HOST.arch, x86_64) {
|
||||
message("x86 build")
|
||||
LIBS += -L./quazip/lib/linux_x86 -lquazip
|
||||
} else {
|
||||
message("x86_64 build")
|
||||
LIBS += -L./quazip/lib/linux_x64 -lquazip
|
||||
}
|
||||
}
|
||||
macx{
|
||||
message("still need to build quazlib for mac")
|
||||
}
|
||||
|
@ -2,8 +2,8 @@
|
||||
#define SAVELISTITEM_H
|
||||
|
||||
|
||||
#include "savebanner.h"
|
||||
#include "includes.h"
|
||||
#include "../WiiQt/savebanner.h"
|
||||
#include "../WiiQt/includes.h"
|
||||
|
||||
|
||||
class SaveListItem : public QListWidgetItem
|
||||
@ -15,8 +15,6 @@ public:
|
||||
SaveBanner *Banner(){ return &sb; }
|
||||
QString Tid(){ return id; }
|
||||
quint32 Size(){ return size; }
|
||||
//quint32 Blocks(){ return size / 0x20000; }
|
||||
//quint32 MiB(){ return size / 0x100000; }
|
||||
|
||||
private:
|
||||
SaveBanner sb;
|
||||
|
@ -1,9 +1,13 @@
|
||||
#include "saveloadthread.h"
|
||||
#include "quazip.h"
|
||||
#include "quazipfile.h"
|
||||
#include "../WiiQt/savedatabin.h"
|
||||
|
||||
Q_DECLARE_METATYPE( PcSaveInfo )
|
||||
SaveLoadThread::SaveLoadThread( QObject *parent ) : QThread( parent )
|
||||
{
|
||||
abort = false;
|
||||
//qRegisterMetaType< SaveListItem* >();
|
||||
qRegisterMetaType< PcSaveInfo >();
|
||||
}
|
||||
|
||||
void SaveLoadThread::ForceQuit()
|
||||
@ -22,14 +26,44 @@ SaveLoadThread::~SaveLoadThread()
|
||||
wait();
|
||||
}
|
||||
|
||||
|
||||
void SaveLoadThread::GetBanners( const QString &bPath, int mode )
|
||||
void SaveLoadThread::GetBanners( const QString &bPath )
|
||||
{
|
||||
if( isRunning() )
|
||||
{
|
||||
qWarning() << "SaveLoadThread::GetBanners -> already running";
|
||||
return;
|
||||
}
|
||||
basePath = bPath;
|
||||
type = mode;
|
||||
if( basePath.isEmpty() )
|
||||
type = LOAD_SNEEK;
|
||||
else
|
||||
type = LOAD_PC;
|
||||
start( NormalPriority );
|
||||
}
|
||||
|
||||
bool SaveLoadThread::SetNandPath( const QString &bPath )
|
||||
{
|
||||
if( isRunning() )
|
||||
return false;
|
||||
|
||||
if( nand.BasePath() == bPath )
|
||||
return true;
|
||||
|
||||
return nand.SetPath( bPath );
|
||||
}
|
||||
|
||||
SaveGame SaveLoadThread::GetSave( quint64 tid )
|
||||
{
|
||||
SaveGame ret;
|
||||
ret.tid = 0;
|
||||
|
||||
if( isRunning() )
|
||||
return ret;
|
||||
|
||||
return nand.GetSaveData( tid );
|
||||
}
|
||||
|
||||
|
||||
void SaveLoadThread::run()
|
||||
{
|
||||
if ( abort )
|
||||
@ -38,108 +72,28 @@ void SaveLoadThread::run()
|
||||
return;
|
||||
}
|
||||
mutex.lock();
|
||||
if( basePath.isEmpty() )
|
||||
/*if( basePath.isEmpty() )
|
||||
{
|
||||
qDebug() << "SaveLoadThread::run -> its empty";
|
||||
return;
|
||||
}
|
||||
}*/
|
||||
mutex.unlock();
|
||||
|
||||
QFileInfo fi( basePath );
|
||||
if( !fi.exists() || !fi.isDir() )
|
||||
switch( type )
|
||||
{
|
||||
qWarning() << "SaveLoadThread::run ->" << basePath << "is not a directory";
|
||||
case LOAD_SNEEK:
|
||||
GetSavesFromNandDump();
|
||||
break;
|
||||
case LOAD_PC:
|
||||
if( basePath.isEmpty() )
|
||||
return;
|
||||
GetPCSaves();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
fi.setFile(basePath + "/title/00010000" );
|
||||
if( !fi.exists() || !fi.isDir() )
|
||||
{
|
||||
qWarning() << "SaveLoadThread::run ->" << QString( basePath + "/title/00010000" ) << "is not a directory";
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
QDir subDir( basePath + "/title/00010000" );
|
||||
subDir.setFilter( QDir::Dirs | QDir::NoDotAndDotDot );
|
||||
QFileInfoList fiL = subDir.entryInfoList();
|
||||
quint32 cnt = fiL.size();
|
||||
|
||||
int i = 0;
|
||||
subDir.setPath( basePath + "/title/00010001" );
|
||||
QFileInfoList fiL2 = subDir.entryInfoList();
|
||||
cnt += fiL2.size();
|
||||
|
||||
subDir.setPath( basePath + "/title/00010002" );
|
||||
QFileInfoList fiL3 = subDir.entryInfoList();
|
||||
cnt += fiL3.size();
|
||||
|
||||
subDir.setPath( basePath + "/title/00010004" );
|
||||
QFileInfoList fiL4 = subDir.entryInfoList();
|
||||
cnt += fiL4.size();
|
||||
|
||||
foreach( QFileInfo f, fiL )
|
||||
{
|
||||
i++;
|
||||
emit SendProgress( (int)( ( (float)( i ) / (float)cnt ) * (float)100 ) );
|
||||
|
||||
QFile ff( f.absoluteFilePath() + "/data/banner.bin" );
|
||||
if( !ff.exists() || !ff.open( QIODevice::ReadOnly ) )
|
||||
continue;
|
||||
|
||||
QByteArray stuff = ff.readAll();
|
||||
ff.close();
|
||||
|
||||
quint32 size = GetFolderSize( f.absoluteFilePath() + "/data" );
|
||||
emit SendItem( stuff, QString( "00010000" + f.fileName() ), type, size );
|
||||
}
|
||||
foreach( QFileInfo f, fiL2 )
|
||||
{
|
||||
i++;
|
||||
emit SendProgress( (int)( ( (float)( i ) / (float)cnt ) * (float)100 ) );
|
||||
|
||||
QFile ff( f.absoluteFilePath() + "/data/banner.bin" );
|
||||
if( !ff.exists() || !ff.open( QIODevice::ReadOnly ) )
|
||||
continue;
|
||||
|
||||
QByteArray stuff = ff.readAll();
|
||||
ff.close();
|
||||
|
||||
quint32 size = GetFolderSize( f.absoluteFilePath() + "/data" );
|
||||
emit SendItem( stuff, QString( "00010001" + f.fileName() ), type, size );
|
||||
}
|
||||
foreach( QFileInfo f, fiL3 )
|
||||
{
|
||||
i++;
|
||||
emit SendProgress( (int)( ( (float)( i ) / (float)cnt ) * (float)100 ) );
|
||||
|
||||
QFile ff( f.absoluteFilePath() + "/data/banner.bin" );
|
||||
if( !ff.exists() || !ff.open( QIODevice::ReadOnly ) )
|
||||
continue;
|
||||
|
||||
QByteArray stuff = ff.readAll();
|
||||
ff.close();
|
||||
|
||||
quint32 size = GetFolderSize( f.absoluteFilePath() + "/data" );
|
||||
emit SendItem( stuff, QString( "00010002" + f.fileName() ), type, size );
|
||||
}
|
||||
foreach( QFileInfo f, fiL4 )
|
||||
{
|
||||
i++;
|
||||
emit SendProgress( (int)( ( (float)( i ) / (float)cnt ) * (float)100 ) );
|
||||
|
||||
QFile ff( f.absoluteFilePath() + "/data/banner.bin" );
|
||||
if( !ff.exists() || !ff.open( QIODevice::ReadOnly ) )
|
||||
continue;
|
||||
|
||||
QByteArray stuff = ff.readAll();
|
||||
ff.close();
|
||||
|
||||
quint32 size = GetFolderSize( f.absoluteFilePath() + "/data" );
|
||||
emit SendItem( stuff, QString( "00010004" + f.fileName() ), type, size );
|
||||
}
|
||||
|
||||
emit SendProgress( 100 );
|
||||
emit SendDone( type );
|
||||
}
|
||||
|
||||
@ -160,3 +114,191 @@ int SaveLoadThread::GetFolderSize( const QString& path )
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
void SaveLoadThread::GetSavesFromPC()
|
||||
{
|
||||
emit SendProgress( 0 );
|
||||
|
||||
emit SendProgress( 100 );
|
||||
}
|
||||
|
||||
void SaveLoadThread::GetPCSaves()
|
||||
{
|
||||
emit SendProgress( 0 );
|
||||
if( basePath.isEmpty() )
|
||||
return;
|
||||
int total = 0;
|
||||
int done = 0;
|
||||
//first count all the saves
|
||||
//list all subdirs of the base ( TID upper )
|
||||
QDir base( basePath );
|
||||
QFileInfoList fi1 = base.entryInfoList( QDir::Dirs | QDir::NoDotAndDotDot );
|
||||
foreach( QFileInfo upper, fi1 )
|
||||
{
|
||||
//qDebug() << "looking in" << upper.absoluteFilePath();
|
||||
//get all subdirectories of the subfolder ( TID lower )
|
||||
QDir uDir( upper.absoluteFilePath() );
|
||||
QFileInfoList fi2 = uDir.entryInfoList( QDir::Dirs | QDir::NoDotAndDotDot );
|
||||
foreach( QFileInfo lower, fi2 )
|
||||
{
|
||||
//qDebug() << "looking in" << lower.absoluteFilePath();
|
||||
//list all .zip files in the game's folder
|
||||
QDir lDir( lower.absoluteFilePath() );
|
||||
QFileInfoList fi3 = lDir.entryInfoList( QStringList() << "*.zip", QDir::Files );
|
||||
//qDebug() << "found" << fi3.size() << "zip files in here";
|
||||
total += fi3.size();
|
||||
}
|
||||
}
|
||||
|
||||
//qDebug() << "SaveLoadThread::GetPCSaves(): will open" << total << "zip archives";
|
||||
//now actually read/send the saves
|
||||
foreach( QFileInfo upper, fi1 )
|
||||
{
|
||||
//get all subdirectories of the subfolder ( TID lower )
|
||||
QDir uDir( upper.absoluteFilePath() );
|
||||
QFileInfoList fi2 = uDir.entryInfoList( QDir::Dirs | QDir::NoDotAndDotDot );
|
||||
foreach( QFileInfo lower, fi2 )
|
||||
{
|
||||
//list all .zip files in the game's folder
|
||||
QDir lDir( lower.absoluteFilePath() );
|
||||
QFileInfoList fi3 = lDir.entryInfoList( QStringList() << "*.zip", QDir::Files );
|
||||
quint32 cnt = fi3.size();
|
||||
//QStringList descriptions;
|
||||
//QByteArray banner;
|
||||
//quint32 size = 0;
|
||||
PcSaveInfo info;
|
||||
info.tid = upper.fileName() + lower.fileName();
|
||||
for( quint32 i = 0; i < cnt; i++ )
|
||||
{
|
||||
//qDebug() << "opening archive" << fi3.at( i ).absoluteFilePath();
|
||||
bool bnrOk = false;
|
||||
bool txtOk = false;
|
||||
quint32 sSize = 0;
|
||||
QString desc;
|
||||
QuaZip zip( fi3.at( i ).absoluteFilePath() );
|
||||
if( !zip.open( QuaZip::mdUnzip ) )
|
||||
{
|
||||
qWarning("SaveLoadThread::GetPCSaves(): zip.open(): %d", zip.getZipError() );
|
||||
continue;
|
||||
}
|
||||
zip.setFileNameCodec("IBM866");
|
||||
if( zip.getEntriesCount() != 2 )
|
||||
{
|
||||
qWarning() << "SaveLoadThread::GetPCSaves() -> save contains more than 2 entries" << fi3.at( i ).absoluteFilePath();
|
||||
zip.close();
|
||||
continue;
|
||||
}
|
||||
QuaZipFile file(&zip);
|
||||
QString name;
|
||||
for( bool more = zip.goToFirstFile(); more; more = zip.goToNextFile() )
|
||||
{
|
||||
if( !file.open( QIODevice::ReadOnly ) )
|
||||
{
|
||||
qWarning("SaveLoadThread::GetPCSaves(): file.open(): %d", file.getZipError() );
|
||||
zip.close();
|
||||
continue;
|
||||
}
|
||||
name = file.getActualFileName();
|
||||
//qDebug() << "extracting" << name << "from the archive";
|
||||
if( file.getZipError() != UNZ_OK )
|
||||
{
|
||||
qWarning("SaveLoadThread::GetPCSaves(): file.getFileName(): %d", file.getZipError());
|
||||
file.close();
|
||||
zip.close();
|
||||
continue;
|
||||
}
|
||||
if( name != "data.bin" && name != "info.txt" )
|
||||
{
|
||||
qWarning() << "SaveLoadThread::GetPCSaves() -> zip contians bad filename" << fi3.at( i ).absoluteFilePath() << name;
|
||||
file.close();
|
||||
zip.close();
|
||||
continue;
|
||||
}
|
||||
/*if( name == "data.bin" && banner.size() )//theres already a banner been extracted, no need to get another one
|
||||
{
|
||||
file.close();
|
||||
continue;
|
||||
}*/
|
||||
QByteArray unc = file.readAll();
|
||||
//qDebug() << "read" << hex << unc.size();
|
||||
if( file.getZipError() != UNZ_OK )
|
||||
{
|
||||
qWarning("SaveLoadThread::GetPCSaves(): file.getFileName(): %d", file.getZipError());
|
||||
file.close();
|
||||
zip.close();
|
||||
continue;
|
||||
}
|
||||
file.close();
|
||||
//read the data.bin to get the banner
|
||||
if( name == "data.bin" )
|
||||
{
|
||||
if( info.banner.isEmpty() )
|
||||
info.banner = SaveDataBin::GetBanner( unc );
|
||||
|
||||
sSize = SaveDataBin::GetSize( unc );
|
||||
bnrOk = true;
|
||||
}
|
||||
else if( name == "info.txt" )
|
||||
{
|
||||
desc = QString( unc );
|
||||
txtOk = true;
|
||||
}
|
||||
}
|
||||
if( txtOk && bnrOk )
|
||||
{
|
||||
info.descriptions << desc;
|
||||
info.sizes << sSize;
|
||||
info.paths << fi3.at( i ).absoluteFilePath();
|
||||
}
|
||||
zip.close();
|
||||
emit SendProgress( (int)( ( (float)( ++done) / (float)total ) * (float)100 ) );
|
||||
}
|
||||
//QString tidStr = upper.fileName() + lower.fileName();
|
||||
//emit SendPcItem( banner, tidStr, descriptions, size );
|
||||
if( info.sizes.size() )
|
||||
emit SendPcItem( info );
|
||||
}
|
||||
}
|
||||
emit SendProgress( 100 );
|
||||
}
|
||||
|
||||
void SaveLoadThread::GetSavesFromNandDump()
|
||||
{
|
||||
emit SendProgress( 0 );
|
||||
QString base = nand.BasePath();
|
||||
if( base.isEmpty() )
|
||||
return;
|
||||
|
||||
QMap< quint64, quint32 > list = nand.GetSaveList();
|
||||
QMap< quint64, quint32 >::Iterator it = list.begin();
|
||||
int i = 0;
|
||||
int s = list.size();
|
||||
while( it != list.end() && !abort )
|
||||
{
|
||||
quint64 tid = it.key();
|
||||
quint32 size = it.value();
|
||||
it++;
|
||||
|
||||
QString tidStr = QString( "%1" ).arg( tid, 16, 16, QChar( '0' ) );
|
||||
QString bnrPath = tidStr;
|
||||
bnrPath.insert( 8, "/" );
|
||||
bnrPath.prepend( "/title/" );
|
||||
bnrPath.append( "/data/banner.bin" );
|
||||
|
||||
QByteArray bnr = nand.GetFile( bnrPath );
|
||||
emit SendProgress( (int)( ( (float)( ++i ) / (float)s ) * (float)100 ) );
|
||||
if( bnr.isEmpty() )
|
||||
continue;
|
||||
|
||||
emit SendSneekItem( bnr, tidStr, size );
|
||||
}
|
||||
|
||||
emit SendProgress( 100 );
|
||||
}
|
||||
|
||||
bool SaveLoadThread::DeleteSaveFromSneekNand( quint64 tid )
|
||||
{
|
||||
if( isRunning() )
|
||||
return false;
|
||||
return nand.DeleteSave( tid );
|
||||
}
|
||||
|
@ -1,13 +1,26 @@
|
||||
#ifndef SAVELOADTHREAD_H
|
||||
#define SAVELOADTHREAD_H
|
||||
|
||||
#include "savelistitem.h"
|
||||
#include "includes.h"
|
||||
//#include "savelistitem.h"
|
||||
#include "../WiiQt/includes.h"
|
||||
#include "../WiiQt/nanddump.h"
|
||||
#define DESC_VERSION 1
|
||||
enum
|
||||
{
|
||||
LOAD_SNEEK = 0x111,
|
||||
LOAD_PC
|
||||
};
|
||||
|
||||
//little struct to hold the info about all the saves for 1 game backed up on the PC
|
||||
struct PcSaveInfo
|
||||
{
|
||||
QString tid;
|
||||
QByteArray banner;
|
||||
QList<quint32> sizes;
|
||||
QStringList descriptions;
|
||||
QStringList paths;
|
||||
};
|
||||
|
||||
class SaveLoadThread : public QThread
|
||||
{
|
||||
Q_OBJECT
|
||||
@ -16,16 +29,33 @@ class SaveLoadThread : public QThread
|
||||
SaveLoadThread( QObject *parent = 0 );
|
||||
~SaveLoadThread();
|
||||
|
||||
void GetBanners( const QString &bPath, int mode );
|
||||
//get banners
|
||||
//if no path is given, it will try to get them from NandDump, otherwise it will use the path on the PC ( not implemented yet )
|
||||
void GetBanners( const QString &bPath = QString() );
|
||||
|
||||
//set this object's extracted nand path
|
||||
bool SetNandPath( const QString &bPath );
|
||||
|
||||
//TODO: these arent done on the work thread, but instead in the calling thread
|
||||
bool DeleteSaveFromSneekNand( quint64 tid );
|
||||
SaveGame GetSave( quint64 tid );
|
||||
|
||||
|
||||
void ForceQuit();
|
||||
|
||||
protected:
|
||||
void run();
|
||||
NandDump nand;
|
||||
void GetSavesFromNandDump();
|
||||
void GetSavesFromPC();
|
||||
void GetPCSaves();
|
||||
|
||||
signals:
|
||||
void SendProgress( int );
|
||||
void SendDone( int );
|
||||
void SendItem( QByteArray, const QString&, int, int );
|
||||
void SendSneekItem( QByteArray, const QString&, int );
|
||||
//void SendPcItem( QByteArray, const QString&, const QStringList&, int );
|
||||
void SendPcItem( PcSaveInfo );
|
||||
|
||||
private:
|
||||
QMutex mutex;
|
||||
@ -38,7 +68,4 @@ class SaveLoadThread : public QThread
|
||||
int GetFolderSize( const QString& path );
|
||||
};
|
||||
|
||||
//Q_DECLARE_METATYPE( SaveListItem* )
|
||||
|
||||
|
||||
#endif // SAVELOADTHREAD_H
|
||||
|
28
saveToy/textdialog.cpp
Normal file
28
saveToy/textdialog.cpp
Normal file
@ -0,0 +1,28 @@
|
||||
#include "textdialog.h"
|
||||
#include "ui_textdialog.h"
|
||||
|
||||
TextDialog::TextDialog(QWidget *parent, const QString &txt ) :
|
||||
QDialog(parent),
|
||||
ui(new Ui::TextDialog)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
ui->textEdit->append( txt );
|
||||
}
|
||||
|
||||
TextDialog::~TextDialog()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void TextDialog::on_buttonBox_accepted()
|
||||
{
|
||||
ret = ui->textEdit->document()->toPlainText();
|
||||
}
|
||||
|
||||
QString TextDialog::GetText( QWidget *parent, const QString &txt )
|
||||
{
|
||||
TextDialog d( parent, txt );
|
||||
if( !d.exec() )
|
||||
return QString();
|
||||
return d.ret;
|
||||
}
|
29
saveToy/textdialog.h
Normal file
29
saveToy/textdialog.h
Normal file
@ -0,0 +1,29 @@
|
||||
#ifndef TEXTDIALOG_H
|
||||
#define TEXTDIALOG_H
|
||||
|
||||
#include <QDialog>
|
||||
|
||||
namespace Ui {
|
||||
class TextDialog;
|
||||
}
|
||||
|
||||
//generic dialog to get text
|
||||
class TextDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit TextDialog(QWidget *parent = 0, const QString &txt = QString() );
|
||||
~TextDialog();
|
||||
|
||||
static QString GetText( QWidget *parent = 0, const QString &txt = QString() );
|
||||
|
||||
private:
|
||||
Ui::TextDialog *ui;
|
||||
QString ret;
|
||||
|
||||
private slots:
|
||||
void on_buttonBox_accepted();
|
||||
};
|
||||
|
||||
#endif // TEXTDIALOG_H
|
Loading…
Reference in New Issue
Block a user