📄 imagespace.cpp
字号:
#include <qdir.h>#include <qstringlist.h>#include <iostream>using namespace std;int imageSpace(const QString &path){ QDir dir(path); QStringList::Iterator it; int size = 0; QStringList files = dir.entryList("*.png *.jpg *.jpeg", QDir::Files); it = files.begin(); while (it != files.end()) { size += QFileInfo(path, *it).size(); ++it; } QStringList dirs = dir.entryList(QDir::Dirs); it = dirs.begin(); while (it != dirs.end()) { if (*it != "." && *it != "..") size += imageSpace(path + "/" + *it); ++it; } return size;}int main(int argc, char *argv[]){ QString path = QDir::currentDirPath(); if (argc > 1) path = argv[1]; cerr << "Space used by images in " << endl << path.ascii() << endl << "and its subdirectories is " << (imageSpace(path) / 1024) << " KB" << endl; return 0;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -