Answer the question
In order to leave comments, you need to log in
How to structure files and folders?
Given
OS - Windows 7
Folder with many folders and files
Map all files and folders
Папка_1
//Папка_1_1
////Файл_1_1_1.jpg
////Файл_1_1_2.png
////Файл_1_1_3.html
//Папка_1_2
Папка_2
Папка_3
Answer the question
In order to leave comments, you need to log in
In cmd.exe use tree %ПУТЬ% /F >вывод.txt
more details: tree /?
;)
Cool, isn't it? I myself, however, until you asked, did not remember this feature
#include
#include
#include
#include
#include
#include
#include
#include
#include
static QJsonArray fList;
static int extraSize = 0;
using namespace std;
void folderHandler(QString folderPath) {
for (QFileInfo f : QDir(folderPath).entryInfoList()) {
if (!f.isDir()) {
QJsonObject fileInfo {
{"fileName", f.fileName()},
{"size ", f.size()},
{"path", f.filePath()}
};
fList.push_back(fileInfo);
} else if (f.fileName() != "." && f.fileName() !
folderHandler(f.absoluteFilePath());
}
}
}
void fileHandler() {
QJsonArray copyFileList = fList;
for (int i = 0; i < fList.size(); i++) {
QJsonArray duplicateList;
QJsonObject buf = fList[i].toObject();
for (int k = 0; k < copyFileList.size(); k++) {
if (copyFileList[k].toObject().value("fileName") == buf.value("fileName") &&
copyFileList[k] .toObject().value("size") == buf.value("size")) {
duplicateList.push_back(copyFileList[k].toObject());
copyFileList.removeAt(k);
k--;
if (duplicateList.size() > 1) {
extraSize += duplicateList[0].toObject().value("size").toInt() * (duplicateList.size()-1);
for (QJsonValueRef d : duplicateList) {
qDebug() << d.toObject().value("path").toString();
}
}
}
}
int main()
{
QString path = "C:\\Text";
qDebug() << "root dir" << QDir(path).absolutePath();
//folderHandler(path);
fileHandler();
qDebug() << "extra size" << extraSize << "b";
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question