1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2024-09-19 10:50:24 -04:00

Use std::filesystem::path in more executables

This commit is contained in:
siddhantCodes 2024-08-11 20:13:47 +05:30
parent 8e70f6f850
commit d98e06a581
2 changed files with 5 additions and 5 deletions

View file

@ -17,7 +17,7 @@ using namespace nix;
typedef std::map<std::string, std::string> Channels;
static Channels channels;
static Path channelsList;
static std::filesystem::path channelsList;
// Reads the list of channels.
static void readChannels()
@ -41,7 +41,7 @@ static void writeChannels()
{
auto channelsFD = AutoCloseFD{open(channelsList.c_str(), O_WRONLY | O_CLOEXEC | O_CREAT | O_TRUNC, 0644)};
if (!channelsFD)
throw SysError("opening '%1%' for writing", channelsList);
throw SysError("opening '%1%' for writing", channelsList.string());
for (const auto & channel : channels)
writeFull(channelsFD.get(), channel.second + " " + channel.first + "\n");
}
@ -165,7 +165,7 @@ static int main_nix_channel(int argc, char ** argv)
{
// Figure out the name of the `.nix-channels' file to use
auto home = getHome();
channelsList = settings.useXDGBaseDirectories ? createNixStateDir() + "/channels" : home + "/.nix-channels";
channelsList = settings.useXDGBaseDirectories ? createNixStateDir() + OS_STR("/channels") : home + OS_STR("/.nix-channels");
nixDefExpr = getNixDefExpr();
// Figure out the name of the channels profile.

View file

@ -21,7 +21,7 @@ bool dryRun = false;
* Of course, this makes rollbacks to before this point in time
* impossible. */
void removeOldGenerations(std::string dir)
void removeOldGenerations(std::filesystem::path dir)
{
if (access(dir.c_str(), R_OK) != 0) return;
@ -81,7 +81,7 @@ static int main_nix_collect_garbage(int argc, char * * argv)
});
if (removeOld) {
std::set<Path> dirsToClean = {
std::set<std::filesystem::path> dirsToClean = {
profilesDir(), settings.nixStateDir + "/profiles", dirOf(getDefaultProfile())};
for (auto & dir : dirsToClean)
removeOldGenerations(dir);