mirror of
https://github.com/WerWolv/ImHex.git
synced 2026-04-01 21:17:44 -05:00
Show more information in data information window
This commit is contained in:
@@ -2,9 +2,16 @@
|
||||
|
||||
#include <cstdio>
|
||||
|
||||
#include <sys/stat.h>
|
||||
#include <time.h>
|
||||
|
||||
#include "utils.hpp"
|
||||
|
||||
namespace hex::prv {
|
||||
|
||||
FileProvider::FileProvider(std::string_view path) {
|
||||
FileProvider::FileProvider(std::string_view path) : Provider(), m_path(path) {
|
||||
this->m_fileStatsValid = stat(path.data(), &this->m_fileStats) == 0;
|
||||
|
||||
this->m_file = fopen(path.data(), "r+b");
|
||||
|
||||
this->m_readable = true;
|
||||
@@ -14,6 +21,7 @@ namespace hex::prv {
|
||||
this->m_file = fopen(path.data(), "rb");
|
||||
this->m_writable = false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
FileProvider::~FileProvider() {
|
||||
@@ -56,4 +64,19 @@ namespace hex::prv {
|
||||
return ftell(this->m_file);
|
||||
}
|
||||
|
||||
std::vector<std::pair<std::string, std::string>> FileProvider::getDataInformation() {
|
||||
std::vector<std::pair<std::string, std::string>> result;
|
||||
|
||||
result.emplace_back("File path", this->m_path);
|
||||
result.emplace_back("Size", hex::toByteString(this->getSize()));
|
||||
|
||||
if (this->m_fileStatsValid) {
|
||||
result.emplace_back("Creation time", ctime(&this->m_fileStats.st_ctime));
|
||||
result.emplace_back("Last access time", ctime(&this->m_fileStats.st_atime));
|
||||
result.emplace_back("Last modification time", ctime(&this->m_fileStats.st_mtime));
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user