Browse Source

Added function for printing filetime & fixed compilation error on windows

refactor
3 years ago
parent
commit
c59967aa00
2 changed files with 29 additions and 13 deletions
  1. 28
    6
      source/Global.h
  2. 1
    7
      source/Printer.h

+ 28
- 6
source/Global.h View File

@@ -67,7 +67,7 @@ typedef struct t_data { // Block on paper
ushort crc; // Cyclic redundancy of addr and data
uchar ecc[32]; // Reed-Solomon's error correction code
} t_data;
static_assert(sizeof(t_data)==128);
//static_assert(sizeof(t_data)==128);

#define PBM_COMPRESSED 0x01 // Paper backup is compressed
#define PBM_ENCRYPTED 0x02 // Paper backup is encrypted
@@ -93,7 +93,7 @@ typedef struct t_superdata { // Identification block on paper
ushort crc; // Cyclic redundancy of previous fields
uchar ecc[32]; // Reed-Solomon's error correction code
} t_superdata;
static_assert(sizeof(t_superdata)==sizeof(t_data));
//static_assert(sizeof(t_superdata)==sizeof(t_data));

typedef struct t_block { // Block in memory
ulong addr; // Offset of the block
@@ -171,8 +171,25 @@ inline int Filetimetotext(FILETIME *fttime,char *s,int n) {
l+=GetTimeFormat(LOCALE_USER_DEFAULT,TIME_NOSECONDS,&sttime,NULL,s+l,n-l);
return l;
};

inline void print_filetime(FILETIME ftime) {
char str[30];
int ok = Filetimetotext(&ftime, str, 30);
if (ok) {
std::cout << str << std::endl;
}
}

#elif __linux__

inline void print_filetime(time_t &ftime) {
std::cout << ftime << std::endl;
}

#endif



inline void print_data(t_data &x) {
std::cout
<< "addr: " << x.addr
@@ -182,6 +199,9 @@ inline void print_data(t_data &x) {
<< std::endl;
}




//prints because debugging is not so effective with giant structs
inline void print_superblock(t_superblock &x) {
std::cout
@@ -190,8 +210,9 @@ inline void print_superblock(t_superblock &x) {
<< " pagesize: " << x.pagesize
<< " origsize: " << x.origsize
<< " mode: " << x.mode
<< " page: " << x.page
<< " modified: " << x.modified
<< " page: " << x.page;
print_filetime(x.modified);
std::cout
<< " attributes: " << x.attributes
<< " filecrc: " << x.filecrc
<< " name: " << x.name
@@ -207,8 +228,9 @@ inline void print_superdata(t_superdata &x) {
<< " origsize: " << x.origsize
<< " mode: " << x.mode
<< " attributes: " << x.attributes
<< " page: " << x.page
<< " modified: " << x.modified
<< " page: " << x.page;
print_filetime(x.modified);
std::cout
<< " filecrc: " << x.filecrc
<< " name: " << x.name
<< " crc: " << x.crc

+ 1
- 7
source/Printer.h View File

@@ -102,13 +102,7 @@ inline void print_printdata(t_printdata& pd) {
#ifdef _WIN32
cout << "hfile: " << pd.hfile << endl;
// cout << "modified: " << pd.modified << endl;
{
char str[30];
int ok = Filetimetotext(&pd.modified, str, 30);
if (ok) {
cout << str << endl;
}
}
print_filetime(pd.modified);
cout << "hbmp: " << pd.hbmp << endl;
cout << "attributes: " << pd.attributes << endl;
#elif __linux__

Loading…
Cancel
Save