Give file_id_t a real constructor

Initialize it to invalid by default.
This commit is contained in:
ridiculousfish 2021-05-02 13:55:41 -07:00
parent c435d8b9b3
commit 8344289fac
2 changed files with 10 additions and 14 deletions

View file

@ -31,13 +31,7 @@
using cstring = std::string;
const file_id_t kInvalidFileID = {static_cast<dev_t>(-1LL),
static_cast<ino_t>(-1LL),
static_cast<uint64_t>(-1LL),
-1,
-1,
-1,
-1};
const file_id_t kInvalidFileID{};
/// Map used as cache by wgettext.
static owning_lock<std::unordered_map<wcstring, wcstring>> wgettext_map;

View file

@ -137,13 +137,15 @@ double fish_wcstod(const wchar_t *str, wchar_t **endptr);
/// seems to aggressively re-use inodes, so it cannot determine if a file has been deleted (ABA
/// problem). Therefore we include richer information.
struct file_id_t {
dev_t device;
ino_t inode;
uint64_t size;
time_t change_seconds;
long change_nanoseconds;
time_t mod_seconds;
long mod_nanoseconds;
dev_t device{static_cast<dev_t>(-1LL)};
ino_t inode{static_cast<ino_t>(-1LL)};
uint64_t size{static_cast<uint64_t>(-1LL)};
time_t change_seconds{-1};
long change_nanoseconds{-1};
time_t mod_seconds{-1};
long mod_nanoseconds{-1};
constexpr file_id_t() = default;
bool operator==(const file_id_t &rhs) const;
bool operator!=(const file_id_t &rhs) const;