mirror of
https://gitea.home.endeavr.de/Marcel/Tarstats-pp.git
synced 2025-12-10 00:39:01 +01:00
this added a first rough version of a stat printout
This commit is contained in:
23
main.cpp
23
main.cpp
@@ -4,6 +4,7 @@
|
|||||||
#include <vector>
|
#include <vector>
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
#include <map>
|
#include <map>
|
||||||
|
#include <filesystem>
|
||||||
|
|
||||||
// checks if a 512byte block consist only of 0 or \0
|
// checks if a 512byte block consist only of 0 or \0
|
||||||
bool eof (const char* buf) {
|
bool eof (const char* buf) {
|
||||||
@@ -40,15 +41,15 @@ std::string getitemtype(char &n) {
|
|||||||
// read itemtype
|
// read itemtype
|
||||||
switch (n){
|
switch (n){
|
||||||
case '0': case '\0':
|
case '0': case '\0':
|
||||||
return "FILE";
|
return "FILE ";
|
||||||
case '1':
|
case '1':
|
||||||
return "HARDLINK";
|
return "HARDLINK ";
|
||||||
case '2':
|
case '2':
|
||||||
return "SYMLINK";
|
return "SYMLINK ";
|
||||||
case '5':
|
case '5':
|
||||||
return "DIRECTORY";
|
return "DIRECTORY ";
|
||||||
default:
|
default:
|
||||||
return "OTHER";
|
return "OTHER ";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -59,8 +60,8 @@ int main(int argc, char** argv) {
|
|||||||
// GENERAL VARIABLES
|
// GENERAL VARIABLES
|
||||||
//count the types of all items
|
//count the types of all items
|
||||||
std::map <std::string, uint> typecount{
|
std::map <std::string, uint> typecount{
|
||||||
{"FILE", 0}, {"HARDLINK", 0}, {"SYMLINK", 0},
|
{"FILE ", 0}, {"HARDLINK ", 0}, {"SYMLINK ", 0},
|
||||||
{"DIRECTORY", 0}, {"OTHER", 0}
|
{"DIRECTORY ", 0}, {"OTHER ", 0}
|
||||||
};
|
};
|
||||||
|
|
||||||
uint64_t sizeof_allfiles{}; // total size of all files in the archive
|
uint64_t sizeof_allfiles{}; // total size of all files in the archive
|
||||||
@@ -118,8 +119,12 @@ int main(int argc, char** argv) {
|
|||||||
// empty the headerbuffer
|
// empty the headerbuffer
|
||||||
delete[] headbuffer;
|
delete[] headbuffer;
|
||||||
}
|
}
|
||||||
|
file.close();
|
||||||
std::cout << sizeof_allfiles << std::endl;
|
std::cout << "Archive size: " << std::filesystem::file_size(archiveFilename) << " Bytes"<< '\n';
|
||||||
|
std::cout << "Size of all items: " << sizeof_allfiles << " Bytes" << '\n' << '\n';
|
||||||
|
for (auto i : typecount) {
|
||||||
|
std::cout << i.first <<": " << i.second << '\n';
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user