1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2025-06-27 04:21:16 +02:00

* Added an option "fsync-metadata" to fsync() changes to

/nix/var/nix/db.
* Removed the function writeStringToFile since it does (almost) the
  same thing as writeFile.
This commit is contained in:
Eelco Dolstra 2010-01-29 12:22:58 +00:00
parent ad529fb89f
commit 07ffdc2862
6 changed files with 37 additions and 28 deletions

View file

@ -15,6 +15,7 @@
#include <sys/wait.h>
#include <sys/types.h>
#include <fcntl.h>
#include <unistd.h>
#include "util.hh"
@ -220,12 +221,13 @@ string readFile(const Path & path)
}
void writeFile(const Path & path, const string & s)
void writeFile(const Path & path, const string & s, bool doFsync)
{
AutoCloseFD fd = open(path.c_str(), O_WRONLY | O_TRUNC | O_CREAT, 0666);
if (fd == -1)
throw SysError(format("opening file `%1%'") % path);
writeFull(fd, (unsigned char *) s.c_str(), s.size());
if (doFsync) fdatasync(fd);
}
@ -413,16 +415,6 @@ Paths createDirs(const Path & path)
}
void writeStringToFile(const Path & path, const string & s)
{
AutoCloseFD fd(open(path.c_str(),
O_CREAT | O_EXCL | O_WRONLY, 0666));
if (fd == -1)
throw SysError(format("creating file `%1%'") % path);
writeFull(fd, (unsigned char *) s.c_str(), s.size());
}
LogType logType = ltPretty;
Verbosity verbosity = lvlInfo;