12#include <unordered_map>
16#define LIB_BIN_NAME "lib.bin"
21 unordered_map<ino_t, string> inodeToPath;
25 void addMapping(ino_t inode,
const string& filePath,
bool writeSyncFile)
27 if (inodeToPath.find(inode) == inodeToPath.end())
29 inodeToPath[inode] = filePath;
30 if (writeSyncFile && syncFile.is_open())
32 syncFile << inode << endl;
33 syncFile << filePath << endl;
40 for (
const auto& pair : inodeToPath)
42 cout <<
"Inode: " << pair.first <<
" -> " << pair.second << endl;
49 DIR* dir = opendir(dirPath.c_str());
52 cerr <<
"Error: Could not open directory " << dirPath << endl;
57 while ((entry = readdir(dir)) !=
nullptr)
59 if (strcmp(entry->d_name,
".") == 0 || strcmp(entry->d_name,
"..") == 0)
64 string fullPath = dirPath +
"/" + entry->d_name;
66 if (stat(fullPath.c_str(), &fileStat) == 0)
68 rbt.
insert(fileStat.st_ino);
69 mapper.
addMapping(fileStat.st_ino, fullPath,
true);
73 cerr <<
"Warning: Could not stat file " << fullPath << endl;
Definition inode_mapper.hpp:19
void addMapping(ino_t inode, const string &filePath, bool writeSyncFile)
Definition inode_mapper.hpp:25
void printMappings() const
Definition inode_mapper.hpp:38
void insert(ino_t data)
Definition rbtree.hpp:174
void processDirectory(const string &dirPath, RedBlackTree &rbt, InodeFileMapper &mapper)
Definition inode_mapper.hpp:47