diff --git a/nandExtract/nandbin.cpp b/nandExtract/nandbin.cpp
index 054dd9e..3dacc98 100755
--- a/nandExtract/nandbin.cpp
+++ b/nandExtract/nandbin.cpp
@@ -6,6 +6,7 @@ NandBin::NandBin( QObject * parent, const QString &path ) : QObject( parent )
type = -1;
fatNames = false;
root = NULL;
+
if( !path.isEmpty() )
SetPath( path );
}
@@ -51,7 +52,7 @@ bool NandBin::ExtractToDir( QTreeWidgetItem *item, const QString &path )
emit SendError( tr( "Error converting entry(%1) to a number" ).arg( item->text( 1 ) ) );
return false;
}
- return ExtractFST( entry, path );
+ return ExtractFST( entry, path, true );//dont bother extracting this item's siblings
return true;
}
@@ -89,10 +90,26 @@ bool NandBin::AddChildren( QTreeWidgetItem *parent, quint16 entry )
text << name << en << size << uid << gid << x3 << mode << attr;
QTreeWidgetItem *child = new QTreeWidgetItem( parent, text );
+ child->setTextAlignment( 1, Qt::AlignRight | Qt::AlignVCenter );//align to the right
+ child->setTextAlignment( 2, Qt::AlignRight | Qt::AlignVCenter );
+ child->setTextAlignment( 3, Qt::AlignRight | Qt::AlignVCenter );
+ child->setTextAlignment( 4, Qt::AlignRight | Qt::AlignVCenter );
+ child->setTextAlignment( 5, Qt::AlignRight | Qt::AlignVCenter );
+ child->setTextAlignment( 6, Qt::AlignRight | Qt::AlignVCenter );
+ child->setTextAlignment( 7, Qt::AlignRight | Qt::AlignVCenter );
- //try to add subfolder contents to the tree
- if( !fst.mode && fst.sub != 0xffff && !AddChildren( child, fst.sub ) )
- return false;
+ //set some icons
+ if( fst.mode )
+ {
+ child->setIcon( 0, keyIcon );
+ }
+ else
+ {
+ child->setIcon( 0, groupIcon );
+ //try to add subfolder contents to the tree
+ if( fst.sub != 0xffff && !AddChildren( child, fst.sub ) )
+ return false;
+ }
return true;
}
@@ -106,7 +123,7 @@ QString NandBin::FstName( fst_t fst )
return ret;
}
-bool NandBin::ExtractFST( quint16 entry, const QString &path )
+bool NandBin::ExtractFST( quint16 entry, const QString &path, bool singleFile )
{
//qDebug() << "NandBin::ExtractFST(" << hex << entry << "," << path << ")";
fst_t fst = GetFST( entry );
@@ -114,7 +131,7 @@ bool NandBin::ExtractFST( quint16 entry, const QString &path )
if( !fst.filename[ 0 ] )//something is amiss, better quit now
return false;
- if( fst.sib != 0xffff && !ExtractFST( fst.sib, path ) )
+ if( !singleFile && fst.sib != 0xffff && !ExtractFST( fst.sib, path ) )
return false;
switch( fst.mode )
@@ -176,7 +193,7 @@ bool NandBin::ExtractFile( fst_t fst, QString parent )
return true;
}
-bool NandBin::InitNand()
+bool NandBin::InitNand( QIcon dirs, QIcon files )
{
type = GetDumpType( f.size() );
if( type < 0 || type > 3 )
@@ -197,6 +214,9 @@ bool NandBin::InitNand()
if( root )
delete root;
+ groupIcon = dirs;
+ keyIcon = files;
+
root = new QTreeWidgetItem( QStringList() << nandPath );
AddChildren( root, 0 );
@@ -493,12 +513,6 @@ void NandBin::SetFixNamesForFAT( bool fix )
fatNames = fix;
}
-/*
- * 0xFFFB - last cluster within a chain
- * 0xFFFC - reserved cluster
- * 0xFFFD - bad block (marked at factory) -- you should always see these in groups of 8 (8 clusters per NAND block)
- * 0xFFFE - empty (unused / available) space
- */
void NandBin::ShowInfo()
{
quint16 badBlocks = 0;
diff --git a/nandExtract/nandbin.h b/nandExtract/nandbin.h
index c7b186d..d4ef9ae 100755
--- a/nandExtract/nandbin.h
+++ b/nandExtract/nandbin.h
@@ -25,7 +25,10 @@ public:
NandBin( QObject * parent = 0, const QString &path = QString() );
~NandBin();
bool SetPath( const QString &path );
- bool InitNand();
+
+ //try to read the filesystem and create a tree from its contents
+ //icons given here will be the ones used when asking for that tree
+ bool InitNand( QIcon dirs = QIcon(), QIcon files = QIcon() );
//get a root item containing children that are actually entries in the nand dump
//the root itself is just a container to hold them all and can be deleted once its children are taken
@@ -56,6 +59,8 @@ private:
int type;
bool fatNames;
+ QIcon groupIcon;
+ QIcon keyIcon;
int GetDumpType( quint64 fileSize );
bool GetKey( int type );
@@ -68,7 +73,7 @@ private:
QByteArray GetFile( fst_t fst );
QString FstName( fst_t fst );
- bool ExtractFST( quint16 entry, const QString &path );
+ bool ExtractFST( quint16 entry, const QString &path, bool singleFile = false );
bool ExtractDir( fst_t fst, QString parent );
bool ExtractFile( fst_t fst, QString parent );
diff --git a/nandExtract/nandwindow.cpp b/nandExtract/nandwindow.cpp
index f298a6f..5a0dc2c 100755
--- a/nandExtract/nandwindow.cpp
+++ b/nandExtract/nandwindow.cpp
@@ -8,7 +8,16 @@ NandWindow::NandWindow(QWidget *parent) :
nandBin( this )
{
ui->setupUi(this);
- ui->treeWidget->header()->resizeSection( 0, 300 );//name
+ //ui->treeWidget->header()->resizeSection( 0, 300 );//name
+ QFontMetrics fm( fontMetrics() );
+ ui->treeWidget->header()->resizeSection( 0, fm.width( QString( 22, 'W' ) ) );//name
+ ui->treeWidget->header()->resizeSection( 1, fm.width( "WWWWW" ) );//entry #
+ ui->treeWidget->header()->resizeSection( 2, fm.width( "WWWWW" ) );//size
+ ui->treeWidget->header()->resizeSection( 3, fm.width( "WWWWWWWWWW" ) );//uid
+ ui->treeWidget->header()->resizeSection( 4, fm.width( "WWWWWWWWWW" ) );//gid
+ ui->treeWidget->header()->resizeSection( 5, fm.width( "WWWWWWWWWW" ) );//x3
+ ui->treeWidget->header()->resizeSection( 6, fm.width( "WWWWW" ) );//mode
+ ui->treeWidget->header()->resizeSection( 7, fm.width( "WWWWW" ) );//attr
connect( &nandBin, SIGNAL( SendError( QString ) ), this, SLOT( GetError( QString ) ) );
@@ -85,6 +94,7 @@ void NandWindow::on_treeWidget_customContextMenuRequested( QPoint pos )
}
}
+//file->open
void NandWindow::on_actionOpen_Nand_triggered()
{
QString path = QFileDialog::getOpenFileName( this, tr( "Select a Nand to open" ) );
@@ -98,7 +108,12 @@ void NandWindow::on_actionOpen_Nand_triggered()
return;
}
ui->statusBar->showMessage( "Loading " + path );
- if( !nandBin.InitNand() )
+ QIcon groupIcon;
+ QIcon keyIcon;
+ groupIcon.addPixmap( style()->standardPixmap( QStyle::SP_DirClosedIcon ), QIcon::Normal, QIcon::Off );
+ groupIcon.addPixmap( style()->standardPixmap( QStyle::SP_DirOpenIcon ), QIcon::Normal, QIcon::On );
+ keyIcon.addPixmap( style()->standardPixmap( QStyle::SP_FileIcon ) );
+ if( !nandBin.InitNand( groupIcon, keyIcon ) )
{
qDebug() << " error in nandBin.InitNand()";
ui->statusBar->showMessage( "Error reading " + path );
diff --git a/nandExtract/nandwindow.ui b/nandExtract/nandwindow.ui
index 062daa1..8624dac 100755
--- a/nandExtract/nandwindow.ui
+++ b/nandExtract/nandwindow.ui
@@ -6,8 +6,8 @@
0
0
- 657
- 499
+ 901
+ 472
@@ -69,7 +69,7 @@
0
0
- 657
+ 901
27