diff --git a/src/file.cc b/src/file.cc index 5d7326b5..a19d40bb 100644 --- a/src/file.cc +++ b/src/file.cc @@ -358,9 +358,11 @@ std::vector complete_command(StringView prefix, ByteCount cursor_pos) dir_end = i; } + typedef decltype(stat::st_mtime) TimeSpec; + struct CommandCache { - timespec mtime = {}; + TimeSpec mtime = {}; std::vector commands; }; static std::unordered_map command_cache; @@ -395,9 +397,9 @@ std::vector complete_command(StringView prefix, ByteCount cursor_pos) }; auto& cache = command_cache[dirname]; - if (memcmp(&cache.mtime, &st.st_mtim, sizeof(struct timespec)) != 0) + if (memcmp(&cache.mtime, &st.st_mtime, sizeof(TimeSpec)) != 0) { - cache.mtime = st.st_mtim; + memcpy(&cache.mtime, &st.st_mtime, sizeof(TimeSpec)); cache.commands = list_files("", dirname, filter); } for (auto& cmd : cache.commands)