QDir qDirFindLargest, qDirLargestFile, qDirFilesChange;
QString qStrDir, qStrDir2, qStrTemp;
// a.argv()[i] == argv[i] qStrTemp = a.argv()[0];
qStrDir = a.argv()[1];
qStrDir2 = a.argv()[2];
//cout << "Total agrc: " << argc << ", Directories 0: " << qStrTemp << ", 1: " << qStrDir << ", 2: " << qStrDir2 << endl;
qDirFindLargest.setPath ( qStrDir );
qDirFindLargest.
setFilter( QDir::Dirs );
// sets only the directory: shows the directories only qDirFindLargest.
setSorting( QDir::Name |
QDir::Reversed );
const QFileInfoList *qFileInfoDirList = qDirFindLargest.entryInfoList();
QFileInfoListIterator qFileInfoListIteratorDir( *qFileInfoDirList );
int fileNumber = 0;
while ( ( qFileInfoDirInfo = qFileInfoListIteratorDir.current() ) != 0 ) {
if (qFileInfoDirInfo->fileName() == "." ) { // first item in the directory: . (let pass)
++qFileInfoListIteratorDir;
}
else if (qFileInfoDirInfo->fileName() == ".." ) { // first item in the directory: .. (let pass)
++qFileInfoListIteratorDir;
}
else {
qDirLargestFile.setPath ( qStrDir + qFileInfoDirInfo->fileName() );
qDirLargestFile.
setFilter( QDir::Files );
// qFiles to only show the files qDirLargestFile.
setSorting( QDir::Name |
QDir::Reversed );
// sorting the files in the directory in reverse order: to find the last file alphabetically cout << "04. qStrDir: " << qStrDir << ", qFileInfoDirInfo->fileName: " << qFileInfoDirInfo->fileName() << endl;
const QFileInfoList *filesList = qDirLargestFile.entryInfoList();
cout << "05. Before QFileInfoListIterator filesIterator( *filesList );" << endl;
QFileInfoListIterator filesIterator( *filesList );
cout << "06. After QFileInfoListIterator filesIterator( *filesList );" << endl;
cout << "07. After QFileInfo *files;" << endl;
files = filesIterator.current();
cout << "07A. After files = filesIterator.current(), files = filesIterator.current(): " << filesIterator.current() << endl;
cout << "08. After files = filesIterator.current(), files->fileName: " << files->fileName() << endl;
... }
QDir qDirFindLargest, qDirLargestFile, qDirFilesChange;
QFile qf;
QString qStrDir, qStrDir2, qStrTemp; // a.argv()[i] == argv[i]
qStrTemp = a.argv()[0];
qStrDir = a.argv()[1];
qStrDir2 = a.argv()[2];
//cout << "Total agrc: " << argc << ", Directories 0: " << qStrTemp << ", 1: " << qStrDir << ", 2: " << qStrDir2 << endl;
qDirFindLargest.setPath ( qStrDir );
qDirFindLargest.setFilter( QDir::Dirs ); // sets only the directory: shows the directories only
qDirFindLargest.setSorting( QDir::Name | QDir::Reversed );
const QFileInfoList *qFileInfoDirList = qDirFindLargest.entryInfoList();
QFileInfoListIterator qFileInfoListIteratorDir( *qFileInfoDirList );
QFileInfo *qFileInfoDirInfo;
QString qFileName;
int fileNumber = 0;
while ( ( qFileInfoDirInfo = qFileInfoListIteratorDir.current() ) != 0 ) {
if (qFileInfoDirInfo->fileName() == "." ) { // first item in the directory: . (let pass)
++qFileInfoListIteratorDir;
}
else if (qFileInfoDirInfo->fileName() == ".." ) { // first item in the directory: .. (let pass)
++qFileInfoListIteratorDir;
}
else {
qDirLargestFile.setPath ( qStrDir + qFileInfoDirInfo->fileName() );
qDirLargestFile.setFilter( QDir::Files ); // qFiles to only show the files
qDirLargestFile.setSorting( QDir::Name | QDir::Reversed ); // sorting the files in the directory in reverse order: to find the last file alphabetically
cout << "04. qStrDir: " << qStrDir << ", qFileInfoDirInfo->fileName: " << qFileInfoDirInfo->fileName() << endl;
const QFileInfoList *filesList = qDirLargestFile.entryInfoList();
cout << "05. Before QFileInfoListIterator filesIterator( *filesList );" << endl;
QFileInfoListIterator filesIterator( *filesList );
cout << "06. After QFileInfoListIterator filesIterator( *filesList );" << endl;
QFileInfo *files;
cout << "07. After QFileInfo *files;" << endl;
files = filesIterator.current();
cout << "07A. After files = filesIterator.current(), files = filesIterator.current(): " << filesIterator.current() << endl;
cout << "08. After files = filesIterator.current(), files->fileName: " << files->fileName() << endl;
... }
To copy to clipboard, switch view to plain text mode
Bookmarks