diff options
Diffstat (limited to 'src/libstore')
-rw-r--r-- | src/libstore/build/local-derivation-goal.cc | 2 | ||||
-rw-r--r-- | src/libstore/builtins/buildenv.cc | 14 | ||||
-rw-r--r-- | src/libstore/builtins/fetchurl.cc | 4 | ||||
-rw-r--r-- | src/libstore/daemon.cc | 2 | ||||
-rw-r--r-- | src/libstore/derivations.cc | 4 | ||||
-rw-r--r-- | src/libstore/filetransfer.cc | 6 | ||||
-rw-r--r-- | src/libstore/globals.cc | 4 | ||||
-rw-r--r-- | src/libstore/http-binary-cache-store.cc | 2 | ||||
-rw-r--r-- | src/libstore/local-binary-cache-store.cc | 2 | ||||
-rw-r--r-- | src/libstore/machines.cc | 12 | ||||
-rw-r--r-- | src/libstore/path.cc | 2 | ||||
-rw-r--r-- | src/libstore/s3-binary-cache-store.cc | 12 | ||||
-rw-r--r-- | src/libstore/ssh.cc | 2 |
13 files changed, 34 insertions, 34 deletions
diff --git a/src/libstore/build/local-derivation-goal.cc b/src/libstore/build/local-derivation-goal.cc index c4fae0eaa..9dcde7f4a 100644 --- a/src/libstore/build/local-derivation-goal.cc +++ b/src/libstore/build/local-derivation-goal.cc @@ -596,7 +596,7 @@ void LocalDerivationGoal::startBuilder() else pathsInChroot[i.substr(0, p)] = {i.substr(p + 1), optional}; } - if (hasPrefix(worker.store.storeDir, tmpDirInSandbox)) + if (worker.store.storeDir.starts_with(tmpDirInSandbox)) { throw Error("`sandbox-build-dir` must not contain the storeDir"); } diff --git a/src/libstore/builtins/buildenv.cc b/src/libstore/builtins/buildenv.cc index c8911d153..eb68d5a33 100644 --- a/src/libstore/builtins/buildenv.cc +++ b/src/libstore/builtins/buildenv.cc @@ -53,13 +53,13 @@ static void createLinks(State & state, const Path & srcDir, const Path & dstDir, * Python package brings its own * `$out/lib/pythonX.Y/site-packages/easy-install.pth'.) */ - if (hasSuffix(srcFile, "/propagated-build-inputs") || - hasSuffix(srcFile, "/nix-support") || - hasSuffix(srcFile, "/perllocal.pod") || - hasSuffix(srcFile, "/info/dir") || - hasSuffix(srcFile, "/log") || - hasSuffix(srcFile, "/manifest.nix") || - hasSuffix(srcFile, "/manifest.json")) + if (srcFile.ends_with("/propagated-build-inputs") || + srcFile.ends_with("/nix-support") || + srcFile.ends_with("/perllocal.pod") || + srcFile.ends_with("/info/dir") || + srcFile.ends_with("/log") || + srcFile.ends_with("/manifest.nix") || + srcFile.ends_with("/manifest.json")) continue; else if (S_ISDIR(srcSt.st_mode)) { diff --git a/src/libstore/builtins/fetchurl.cc b/src/libstore/builtins/fetchurl.cc index 7d7924d77..3d87bdc21 100644 --- a/src/libstore/builtins/fetchurl.cc +++ b/src/libstore/builtins/fetchurl.cc @@ -41,7 +41,7 @@ void builtinFetchurl(const BasicDerivation & drv, const std::string & netrcData) request.decompress = false; auto decompressor = makeDecompressionSink( - unpack && hasSuffix(mainUrl, ".xz") ? "xz" : "none", sink); + unpack && mainUrl.ends_with(".xz") ? "xz" : "none", sink); fileTransfer->download(std::move(request), *decompressor); decompressor->finish(); }); @@ -62,7 +62,7 @@ void builtinFetchurl(const BasicDerivation & drv, const std::string & netrcData) if (getAttr("outputHashMode") == "flat") for (auto hashedMirror : settings.hashedMirrors.get()) try { - if (!hasSuffix(hashedMirror, "/")) hashedMirror += '/'; + if (!hashedMirror.ends_with("/")) hashedMirror += '/'; std::optional<HashType> ht = parseHashTypeOpt(getAttr("outputHashAlgo")); Hash h = newHashAllowEmpty(getAttr("outputHash"), ht); fetch(hashedMirror + printHashType(h.type) + "/" + h.to_string(Base16, false)); diff --git a/src/libstore/daemon.cc b/src/libstore/daemon.cc index 170d1fb35..993ade7dc 100644 --- a/src/libstore/daemon.cc +++ b/src/libstore/daemon.cc @@ -221,7 +221,7 @@ struct ClientSettings for (auto & s : ss) if (trusted.count(s)) subs.push_back(s); - else if (!hasSuffix(s, "/") && trusted.count(s + "/")) + else if (!s.ends_with("/") && trusted.count(s + "/")) subs.push_back(s + "/"); else warn("ignoring untrusted substituter '%s', you are not a trusted user.\n" diff --git a/src/libstore/derivations.cc b/src/libstore/derivations.cc index efba17c4b..ab84255d3 100644 --- a/src/libstore/derivations.cc +++ b/src/libstore/derivations.cc @@ -658,7 +658,7 @@ std::string Derivation::unparse(const Store & store, bool maskOutputs, // FIXME: remove bool isDerivation(std::string_view fileName) { - return hasSuffix(fileName, drvExtension); + return fileName.ends_with(drvExtension); } @@ -927,7 +927,7 @@ std::string_view BasicDerivation::nameFromPath(const StorePath & drvPath) { auto nameWithSuffix = drvPath.name(); constexpr std::string_view extension = ".drv"; - assert(hasSuffix(nameWithSuffix, extension)); + assert(nameWithSuffix.ends_with(extension)); nameWithSuffix.remove_suffix(extension.size()); return nameWithSuffix; } diff --git a/src/libstore/filetransfer.cc b/src/libstore/filetransfer.cc index 5664579e7..46cda62a1 100644 --- a/src/libstore/filetransfer.cc +++ b/src/libstore/filetransfer.cc @@ -670,8 +670,8 @@ struct curlFileTransfer : public FileTransfer void enqueueItem(std::shared_ptr<TransferItem> item) { if (item->request.data - && !hasPrefix(item->request.uri, "http://") - && !hasPrefix(item->request.uri, "https://")) + && !item->request.uri.starts_with("http://") + && !item->request.uri.starts_with("https://")) throw nix::Error("uploading to '%s' is not supported", item->request.uri); { @@ -703,7 +703,7 @@ struct curlFileTransfer : public FileTransfer Callback<FileTransferResult> callback) override { /* Ugly hack to support s3:// URIs. */ - if (hasPrefix(request.uri, "s3://")) { + if (request.uri.starts_with("s3://")) { // FIXME: do this on a worker thread try { #if ENABLE_S3 diff --git a/src/libstore/globals.cc b/src/libstore/globals.cc index 2929bd6e6..14437e2f0 100644 --- a/src/libstore/globals.cc +++ b/src/libstore/globals.cc @@ -241,7 +241,7 @@ bool Settings::isWSL1() uname(&utsbuf); // WSL1 uses -Microsoft suffix // WSL2 uses -microsoft-standard suffix - return hasSuffix(utsbuf.release, "-Microsoft"); + return std::string_view(utsbuf.release).ends_with("-Microsoft"); } Path Settings::getDefaultSSLCertFile() @@ -415,7 +415,7 @@ void initLibStore() { sshd). This breaks build users because they don't have access to the TMPDIR, in particular in ‘nix-store --serve’. */ #if __APPLE__ - if (hasPrefix(getEnv("TMPDIR").value_or("/tmp"), "/var/folders/")) + if (getEnv("TMPDIR").value_or("/tmp").starts_with("/var/folders/")) unsetenv("TMPDIR"); #endif diff --git a/src/libstore/http-binary-cache-store.cc b/src/libstore/http-binary-cache-store.cc index 85c5eed4c..9b980d81f 100644 --- a/src/libstore/http-binary-cache-store.cc +++ b/src/libstore/http-binary-cache-store.cc @@ -145,7 +145,7 @@ protected: FileTransferRequest makeRequest(const std::string & path) { return FileTransferRequest( - hasPrefix(path, "https://") || hasPrefix(path, "http://") || hasPrefix(path, "file://") + path.starts_with("https://") || path.starts_with("http://") || path.starts_with("file://") ? path : cacheUri + "/" + path); diff --git a/src/libstore/local-binary-cache-store.cc b/src/libstore/local-binary-cache-store.cc index 5481dd762..5684dcd80 100644 --- a/src/libstore/local-binary-cache-store.cc +++ b/src/libstore/local-binary-cache-store.cc @@ -85,7 +85,7 @@ protected: for (auto & entry : readDirectory(binaryCacheDir)) { if (entry.name.size() != 40 || - !hasSuffix(entry.name, ".narinfo")) + !entry.name.ends_with(".narinfo")) continue; paths.insert(parseStorePath( storeDir + "/" + entry.name.substr(0, entry.name.size() - 8) diff --git a/src/libstore/machines.cc b/src/libstore/machines.cc index f808b8592..ecae3054e 100644 --- a/src/libstore/machines.cc +++ b/src/libstore/machines.cc @@ -24,10 +24,10 @@ Machine::Machine(decltype(storeUri) storeUri, || storeUri == "auto" || storeUri == "daemon" || storeUri == "local" - || hasPrefix(storeUri, "auto?") - || hasPrefix(storeUri, "daemon?") - || hasPrefix(storeUri, "local?") - || hasPrefix(storeUri, "?") + || storeUri.starts_with("auto?") + || storeUri.starts_with("daemon?") + || storeUri.starts_with("local?") + || storeUri.starts_with("?") ? storeUri : "ssh://" + storeUri), systemTypes(systemTypes), @@ -67,12 +67,12 @@ bool Machine::mandatoryMet(const std::set<std::string> & features) const ref<Store> Machine::openStore() const { Store::Params storeParams; - if (hasPrefix(storeUri, "ssh://")) { + if (storeUri.starts_with("ssh://")) { storeParams["max-connections"] = "1"; storeParams["log-fd"] = "4"; } - if (hasPrefix(storeUri, "ssh://") || hasPrefix(storeUri, "ssh-ng://")) { + if (storeUri.starts_with("ssh://") || storeUri.starts_with("ssh-ng://")) { if (sshKey != "") storeParams["ssh-key"] = sshKey; if (sshPublicHostKey != "") diff --git a/src/libstore/path.cc b/src/libstore/path.cc index 3c6b9fc10..c896ff927 100644 --- a/src/libstore/path.cc +++ b/src/libstore/path.cc @@ -42,7 +42,7 @@ StorePath::StorePath(const Hash & hash, std::string_view _name) bool StorePath::isDerivation() const { - return hasSuffix(name(), drvExtension); + return name().ends_with(drvExtension); } StorePath StorePath::dummy("ffffffffffffffffffffffffffffffff-x"); diff --git a/src/libstore/s3-binary-cache-store.cc b/src/libstore/s3-binary-cache-store.cc index 1a62d92d4..cf5f125d4 100644 --- a/src/libstore/s3-binary-cache-store.cc +++ b/src/libstore/s3-binary-cache-store.cc @@ -213,7 +213,7 @@ struct S3BinaryCacheStoreConfig : virtual BinaryCacheStoreConfig support it. > **Note** - > + > > HTTPS should be used if the cache might contain sensitive > information. )"}; @@ -224,7 +224,7 @@ struct S3BinaryCacheStoreConfig : virtual BinaryCacheStoreConfig Do not specify this setting if you're using Amazon S3. > **Note** - > + > > This endpoint must support HTTPS and will use path-based > addressing instead of virtual host based addressing. )"}; @@ -448,11 +448,11 @@ struct S3BinaryCacheStoreImpl : virtual S3BinaryCacheStoreConfig, public virtual return std::make_shared<std::stringstream>(std::move(compressed)); }; - if (narinfoCompression != "" && hasSuffix(path, ".narinfo")) + if (narinfoCompression != "" && path.ends_with(".narinfo")) uploadFile(path, compress(narinfoCompression), mimeType, narinfoCompression); - else if (lsCompression != "" && hasSuffix(path, ".ls")) + else if (lsCompression != "" && path.ends_with(".ls")) uploadFile(path, compress(lsCompression), mimeType, lsCompression); - else if (logCompression != "" && hasPrefix(path, "log/")) + else if (logCompression != "" && path.starts_with("log/")) uploadFile(path, compress(logCompression), mimeType, logCompression); else uploadFile(path, istream, mimeType, ""); @@ -499,7 +499,7 @@ struct S3BinaryCacheStoreImpl : virtual S3BinaryCacheStoreConfig, public virtual for (auto object : contents) { auto & key = object.GetKey(); - if (key.size() != 40 || !hasSuffix(key, ".narinfo")) continue; + if (key.size() != 40 || !key.ends_with(".narinfo")) continue; paths.insert(parseStorePath(storeDir + "/" + key.substr(0, key.size() - 8) + "-" + MissingName)); } diff --git a/src/libstore/ssh.cc b/src/libstore/ssh.cc index fdae083ba..ea9cba578 100644 --- a/src/libstore/ssh.cc +++ b/src/libstore/ssh.cc @@ -12,7 +12,7 @@ SSHMaster::SSHMaster(const std::string & host, const std::string & keyFile, cons , compress(compress) , logFD(logFD) { - if (host == "" || hasPrefix(host, "-")) + if (host == "" || host.starts_with("-")) throw Error("invalid SSH host name '%s'", host); auto state(state_.lock()); |