1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2025-06-27 12:41:15 +02:00

* A GC setting `gc-keep-outputs' to specify whether output paths of

derivations should be kept.
This commit is contained in:
Eelco Dolstra 2005-02-01 22:07:48 +00:00
parent 2e6bf723e4
commit a37338815d
7 changed files with 102 additions and 7 deletions

View file

@ -164,6 +164,27 @@ Strings readDirectory(const Path & path)
}
string readFile(int fd)
{
struct stat st;
if (fstat(fd, &st) == -1)
throw SysError("statting file");
unsigned char buf[st.st_size]; /* !!! stack space */
readFull(fd, buf, st.st_size);
return string((char *) buf, st.st_size);
}
string readFile(const Path & path)
{
AutoCloseFD fd = open(path.c_str(), O_RDONLY);
if (fd == -1)
throw SysError(format("opening file `%1%'") % path);
return readFile(fd);
}
static void _deletePath(const Path & path)
{
checkInterrupt();

View file

@ -90,6 +90,10 @@ bool isLink(const Path & path);
removed. */
Strings readDirectory(const Path & path);
/* Read the contents of a file into a string. */
string readFile(int fd);
string readFile(const Path & path);
/* Delete a path; i.e., in the case of a directory, it is deleted
recursively. Don't use this at home, kids. */
void deletePath(const Path & path);