// Update modification timestamp to save the file from LRU cleanup (and,
// if hard-linked, to make the object file newer than the source file).
- update_mtime(raw_file->c_str());
+ Util::update_mtime(*raw_file);
} else {
cc_log("Copying to %s", dest_path.c_str());
m_dest_fd = Fd(
# include <pwd.h>
#endif
+#ifdef HAVE_SYS_TIME_H
+# include <sys/time.h>
+#endif
+
#ifdef HAVE_LINUX_FS_H
# include <linux/magic.h>
# include <sys/statfs.h>
#endif
}
+void
+update_mtime(const std::string& path)
+{
+#ifdef HAVE_UTIMES
+ utimes(path.c_str(), nullptr);
+#else
+ utime(path.c_str(), nullptr);
+#endif
+}
+
void
wipe_path(const std::string& path)
{
// Unset environment variable `name`.
void unsetenv(const std::string& name);
+// Set mtime of `path` to the current timestamp.
+void update_mtime(const std::string& path);
+
// Remove `path` (and its contents if it's a directory). A non-existing path is
// not considered an error.
//
return;
}
- update_mtime(config.cache_dir().c_str());
+ Util::update_mtime(config.cache_dir());
const std::string& temp_dir = config.temporary_dir();
if (!Stat::lstat(temp_dir)) {
return nullopt;
} else {
// Update modification timestamp to save file from LRU cleanup.
- update_mtime(ctx.result_path().c_str());
+ Util::update_mtime(ctx.result_path());
}
cc_log("Succeeded getting cached result");
# include <sys/time.h>
#endif
-// Update the modification time of a file in the cache to save it from LRU
-// cleanup.
-void
-update_mtime(const char* path)
-{
-#ifdef HAVE_UTIMES
- utimes(path, nullptr);
-#else
- utime(path, NULL);
-#endif
-}
-
// If exit() already has been called, call _exit(), otherwise exit(). This is
// used to avoid calling exit() inside an atexit handler.
void
#include <string>
-void update_mtime(const char* path);
void x_exit(int status) ATTR_NORETURN;
int x_rename(const char* oldpath, const char* newpath);
void set_cloexec_flag(int fd);
mf = read_manifest(path);
if (mf) {
// Update modification timestamp to save files from LRU cleanup.
- update_mtime(path.c_str());
+ Util::update_mtime(path);
} else {
cc_log("No such manifest file");
return nullopt;