mirror of
https://github.com/avinal/Krypto.git
synced 2026-01-09 22:58:36 +05:30
filesystem added
This commit is contained in:
13
src/Main.cpp
13
src/Main.cpp
@@ -7,14 +7,11 @@
|
||||
* The driver code
|
||||
*/
|
||||
|
||||
#include "Utils.hpp"
|
||||
using namespace MCPS;
|
||||
int main(int argc, char const *argv[]) {
|
||||
fileop start;
|
||||
auto data = start.scan_current_directory();
|
||||
#include "Utils.h"
|
||||
|
||||
int main(int argc, char const *argv[]) {
|
||||
krypto::fileop test;
|
||||
std::vector<char> buffer;
|
||||
|
||||
for (auto d : data) {
|
||||
d.second.print();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
55
test/check.cpp
Normal file
55
test/check.cpp
Normal file
@@ -0,0 +1,55 @@
|
||||
/**
|
||||
* /mnt/z/my_git/RCRS-CSD-327/test/check.cpp
|
||||
* @file check.cpp
|
||||
* @author Avinal Kumar
|
||||
* @since March 25, 2021
|
||||
*
|
||||
* Check filesystem
|
||||
*/
|
||||
|
||||
|
||||
#include <chrono>
|
||||
#include <filesystem>
|
||||
#include <fstream>
|
||||
#include <iomanip>
|
||||
#include <iostream>
|
||||
namespace fs = std::filesystem;
|
||||
|
||||
template <typename TP> std::time_t to_time_t(TP tp) {
|
||||
using namespace std::chrono;
|
||||
auto sctp = time_point_cast<system_clock::duration>(tp - TP::clock::now() +
|
||||
system_clock::now());
|
||||
return system_clock::to_time_t(sctp);
|
||||
}
|
||||
|
||||
struct fileprop {
|
||||
|
||||
std::string filename;
|
||||
unsigned long file_size;
|
||||
fs::file_type type;
|
||||
std::time_t modify;
|
||||
fileprop(std::string filename) : filename(filename) {}
|
||||
void file_stat() {
|
||||
fs::path p = fs::current_path() / filename;
|
||||
|
||||
auto ftime = fs::last_write_time(p);
|
||||
modify = to_time_t(ftime);
|
||||
type = fs::status(p).type();
|
||||
file_size = fs::file_size(p);
|
||||
}
|
||||
|
||||
void print() {
|
||||
std::cout << "Name: " << filename << std::endl
|
||||
<< "Modify time" << std::asctime(std::localtime(&modify))
|
||||
<< std::endl
|
||||
<< "File Size: " << file_size << std::endl;
|
||||
}
|
||||
};
|
||||
|
||||
int main(int argc, char const *argv[]) {
|
||||
|
||||
fs::path p = fs::current_path();
|
||||
std::cout << p;
|
||||
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user