#define _XOPEN_SOURCE 600 #include "config.h" #include #include #include #include #include // for strcasecmp #include #include #include #include #include #include "archive.hh" #include "util.hh" namespace nix { static string archiveVersion1 = "nix-archive-1"; static string caseHackSuffix = "~nix~case~hack~"; PathFilter defaultPathFilter; static void dumpContents(const Path & path, size_t size, Sink & sink) { writeString("contents", sink); writeLongLong(size, sink); AutoCloseFD fd = open(path.c_str(), O_RDONLY); if (fd == -1) throw SysError(format("opening file `%1%'") % path); unsigned char buf[65536]; size_t left = size; while (left > 0) { size_t n = left > sizeof(buf) ? sizeof(buf) : left; readFull(fd, buf, n); left -= n; sink(buf, n); } writePadding(size, sink); } static void dump(const Path & path, Sink & sink, PathFilter & filt
aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRicardo Wurmus <rekado@elephly.net>2018-10-30 07:52:38 +0100
committerRicardo Wurmus <rekado@elephly.net>2018-10-30 21:47:06 +0100
commitfda8dd58c2ceb32e96e1ed02630d7edb162a4914 (patch)
treebf958c94c1b2b65ce27f5bc5d2f424ee4de46ca5 /gnu/packages
parent02c57c018a617abd3fcfd83a1a29074048b25dc7 (diff)
downloadguix-fda8dd58c2ceb32e96e1ed02630d7edb162a4914.tar.gz
guix-fda8dd58c2ceb32e96e1ed02630d7edb162a4914.zip
gnu: r-shinyace: Update to 0.3.2.
* gnu/packages/cran.scm (r-shinyace): Update to 0.3.2.
Diffstat (limited to 'gnu/packages')
((char) 0) != string::npos) throw Error(format("NAR contains invalid file name `%1%'") % name); if (name <= prevName) throw Error("NAR directory is not sorted"); prevName = name; } else if (s == "node") { if (s.empty()) throw badArchive("entry name missing"); parse(sink, source, path + "/" + name); } else throw badArchive("unknown field " + s); } } else if (s == "target" && type == tpSymlink) { string target = readString(source); sink.createSymlink(path, target); } else throw badArchive("unknown field " + s); } } void parseDump(ParseSink & sink, Source & source) { string version; try { version = readString(source); } catch (SerialisationError & e) { /* This generally means the integer at the start couldn't be decoded. Ignore and throw the exception below. */ } if (version != archiveVersion1) throw badArchive("input doesn't look like a Nix archive"); parse(sink, source, ""); } struct RestoreSink : ParseSink { Path dstPath; AutoCloseFD fd; void createDirectory(const Path & path) { Path p = dstPath + path; if (mkdir(p.c_str(), 0777) == -1) throw SysError(format("creating directory `%1%'") % p); }; void createRegularFile(const Path & path) { Path p = dstPath + path; fd.close(); fd = open(p.c_str(), O_CREAT | O_EXCL | O_WRONLY, 0666); if (fd == -1) throw SysError(format("creating file `%1%'") % p); } void isExecutable() { struct stat st; if (fstat(fd, &st) == -1) throw SysError("fstat"); if (fchmod(fd, st.st_mode | (S_IXUSR | S_IXGRP | S_IXOTH)) == -1) throw SysError("fchmod"); } void preallocateContents(unsigned long long len) { #if HAVE_POSIX_FALLOCATE if (len) { errno = posix_fallocate(fd, 0, len); /* Note that EINVAL may indicate that the underlying filesystem doesn't support preallocation (e.g. on OpenSolaris). Since preallocation is just an optimisation, ignore it. */ if (errno && errno != EINVAL) throw SysError(format("preallocating file of %1% bytes") % len); } #endif } void receiveContents(unsigned char * data, unsigned int len) { writeFull(fd, data, len); } void createSymlink(const Path & path, const string & target) { Path p = dstPath + path; nix::createSymlink(target, p); } }; void restorePath(const Path & path, Source & source) { RestoreSink sink; sink.dstPath = path; parseDump(sink, source); } }