aboutsummaryrefslogtreecommitdiff
path: root/src/libutil/archive.cc
diff options
context:
space:
mode:
authorEelco Dolstra <edolstra@gmail.com>2022-02-25 16:00:00 +0100
committerEelco Dolstra <edolstra@gmail.com>2022-02-25 16:13:02 +0100
commitdf552ff53e68dff8ca360adbdbea214ece1d08ee (patch)
tree9ed3cb700377d4731b4c234ebec16efb0099c71a /src/libutil/archive.cc
parent14b38d0887f8a8d6b75039113eface57cfb19d06 (diff)
Remove std::string alias (for real this time)
Also use std::string_view in a few more places.
Diffstat (limited to 'src/libutil/archive.cc')
-rw-r--r--src/libutil/archive.cc28
1 files changed, 14 insertions, 14 deletions
diff --git a/src/libutil/archive.cc b/src/libutil/archive.cc
index fdee643b1..eda004756 100644
--- a/src/libutil/archive.cc
+++ b/src/libutil/archive.cc
@@ -37,7 +37,7 @@ static GlobalConfig::Register rArchiveSettings(&archiveSettings);
const std::string narVersionMagic1 = "nix-archive-1";
-static string caseHackSuffix = "~nix~case~hack~";
+static std::string caseHackSuffix = "~nix~case~hack~";
PathFilter defaultPathFilter = [](const Path &) { return true; };
@@ -84,12 +84,12 @@ static void dump(const Path & path, Sink & sink, PathFilter & filter)
/* If we're on a case-insensitive system like macOS, undo
the case hack applied by restorePath(). */
- std::map<string, string> unhacked;
+ std::map<std::string, std::string> unhacked;
for (auto & i : readDirectory(path))
if (archiveSettings.useCaseHack) {
- string name(i.name);
+ std::string name(i.name);
size_t pos = i.name.find(caseHackSuffix);
- if (pos != string::npos) {
+ if (pos != std::string::npos) {
debug(format("removing case hack suffix from '%1%'") % (path + "/" + i.name));
name.erase(pos);
}
@@ -124,13 +124,13 @@ void dumpPath(const Path & path, Sink & sink, PathFilter & filter)
}
-void dumpString(const std::string & s, Sink & sink)
+void dumpString(std::string_view s, Sink & sink)
{
sink << narVersionMagic1 << "(" << "type" << "regular" << "contents" << s << ")";
}
-static SerialisationError badArchive(string s)
+static SerialisationError badArchive(const std::string & s)
{
return SerialisationError("bad archive: " + s);
}
@@ -171,7 +171,7 @@ static void parseContents(ParseSink & sink, Source & source, const Path & path)
struct CaseInsensitiveCompare
{
- bool operator() (const string & a, const string & b) const
+ bool operator() (const std::string & a, const std::string & b) const
{
return strcasecmp(a.c_str(), b.c_str()) < 0;
}
@@ -180,7 +180,7 @@ struct CaseInsensitiveCompare
static void parse(ParseSink & sink, Source & source, const Path & path)
{
- string s;
+ std::string s;
s = readString(source);
if (s != "(") throw badArchive("expected open tag");
@@ -201,7 +201,7 @@ static void parse(ParseSink & sink, Source & source, const Path & path)
else if (s == "type") {
if (type != tpUnknown)
throw badArchive("multiple type fields");
- string t = readString(source);
+ std::string t = readString(source);
if (t == "regular") {
type = tpRegular;
@@ -232,7 +232,7 @@ static void parse(ParseSink & sink, Source & source, const Path & path)
}
else if (s == "entry" && type == tpDirectory) {
- string name, prevName;
+ std::string name, prevName;
s = readString(source);
if (s != "(") throw badArchive("expected open tag");
@@ -246,7 +246,7 @@ static void parse(ParseSink & sink, Source & source, const Path & path)
break;
} else if (s == "name") {
name = readString(source);
- if (name.empty() || name == "." || name == ".." || name.find('/') != string::npos || name.find((char) 0) != string::npos)
+ if (name.empty() || name == "." || name == ".." || name.find('/') != std::string::npos || name.find((char) 0) != std::string::npos)
throw Error("NAR contains invalid file name '%1%'", name);
if (name <= prevName)
throw Error("NAR directory is not sorted");
@@ -269,7 +269,7 @@ static void parse(ParseSink & sink, Source & source, const Path & path)
}
else if (s == "target" && type == tpSymlink) {
- string target = readString(source);
+ std::string target = readString(source);
sink.createSymlink(path, target);
}
@@ -281,7 +281,7 @@ static void parse(ParseSink & sink, Source & source, const Path & path)
void parseDump(ParseSink & sink, Source & source)
{
- string version;
+ std::string version;
try {
version = readString(source, narVersionMagic1.size());
} catch (SerialisationError & e) {
@@ -345,7 +345,7 @@ struct RestoreSink : ParseSink
writeFull(fd.get(), data);
}
- void createSymlink(const Path & path, const string & target) override
+ void createSymlink(const Path & path, const std::string & target) override
{
Path p = dstPath + path;
nix::createSymlink(target, p);