mirror of
https://github.com/izzy2lost/Diddy-Kong-Racing.git
synced 2026-06-19 01:16:26 -07:00
Added custom hash for filesystem path strings
This commit is contained in:
@@ -373,7 +373,7 @@ std::string FileHelper::get_last_modified_timestamp(const fs::path &path) {
|
||||
return out;
|
||||
}
|
||||
|
||||
void FileHelper::insert_timestamps_from_directory(const fs::path &dirPath, std::unordered_map<fs::path, std::string> ×tamps) {
|
||||
void FileHelper::insert_timestamps_from_directory(const fs::path &dirPath, std::unordered_map<fs::path, std::string, PathHash> ×tamps) {
|
||||
// TODO: Make this multithreaded?
|
||||
for (const auto &filepath : fs::recursive_directory_iterator(dirPath)) {
|
||||
timestamps[filepath] = get_last_modified_timestamp(filepath);
|
||||
|
||||
@@ -12,6 +12,13 @@
|
||||
#include <filesystem>
|
||||
namespace fs = std::filesystem;
|
||||
|
||||
// Using path as a key doesn't seem to work on raspberry pi OS?
|
||||
struct PathHash {
|
||||
std::size_t operator()(const std::filesystem::__cxx11::path& p) const {
|
||||
return std::filesystem::hash_value(p);
|
||||
}
|
||||
};
|
||||
|
||||
class FileHelper {
|
||||
public:
|
||||
static std::vector<uint8_t> read_binary_file(const fs::path &filename);
|
||||
@@ -60,7 +67,7 @@ public:
|
||||
static void endianswap(std::vector<uint8_t> &bytes);
|
||||
|
||||
static std::string get_last_modified_timestamp(const fs::path &path);
|
||||
static void insert_timestamps_from_directory(const fs::path &dirPath, std::unordered_map<fs::path, std::string> ×tamps);
|
||||
static void insert_timestamps_from_directory(const fs::path &dirPath, std::unordered_map<fs::path, std::string, PathHash> ×tamps);
|
||||
private:
|
||||
|
||||
};
|
||||
|
||||
@@ -20,8 +20,8 @@ private:
|
||||
JsonFile *_modOrderFile;
|
||||
size_t _modOrderCount;
|
||||
|
||||
std::unordered_map<fs::path, std::string> _lastModifiedDates;
|
||||
std::unordered_map<fs::path, std::vector<fs::path>> _modFiles;
|
||||
std::unordered_map<fs::path, std::string, PathHash> _lastModifiedDates;
|
||||
std::unordered_map<fs::path, std::vector<fs::path>, PathHash> _modFiles;
|
||||
std::vector<fs::path> _modFilesModified;
|
||||
|
||||
void _check_mod_path(fs::path &modPath);
|
||||
|
||||
Reference in New Issue
Block a user