mirror of
https://github.com/NixOS/nix
synced 2025-06-27 08:31:16 +02:00
Drop fs alias in favour of std::filesystem
Since we dropped fs::symlink_exists, we no longer have a need for the fs namespace. Having less abstractions makes it easier to lookup the functions in reference documentations.
This commit is contained in:
parent
5b59be914d
commit
979d5a7cae
20 changed files with 129 additions and 160 deletions
|
@ -24,7 +24,7 @@ bool dryRun = false;
|
|||
* Of course, this makes rollbacks to before this point in time
|
||||
* impossible. */
|
||||
|
||||
void removeOldGenerations(fs::path dir)
|
||||
void removeOldGenerations(std::filesystem::path dir)
|
||||
{
|
||||
if (access(dir.string().c_str(), R_OK) != 0) return;
|
||||
|
||||
|
@ -36,11 +36,11 @@ void removeOldGenerations(fs::path dir)
|
|||
auto path = i.path().string();
|
||||
auto type = i.symlink_status().type();
|
||||
|
||||
if (type == fs::file_type::symlink && canWrite) {
|
||||
if (type == std::filesystem::file_type::symlink && canWrite) {
|
||||
std::string link;
|
||||
try {
|
||||
link = readLink(path);
|
||||
} catch (fs::filesystem_error & e) {
|
||||
} catch (std::filesystem::filesystem_error & e) {
|
||||
if (e.code() == std::errc::no_such_file_or_directory) continue;
|
||||
throw;
|
||||
}
|
||||
|
@ -52,7 +52,7 @@ void removeOldGenerations(fs::path dir)
|
|||
} else
|
||||
deleteOldGenerations(path, dryRun);
|
||||
}
|
||||
} else if (type == fs::file_type::directory) {
|
||||
} else if (type == std::filesystem::file_type::directory) {
|
||||
removeOldGenerations(path);
|
||||
}
|
||||
}
|
||||
|
@ -84,10 +84,10 @@ static int main_nix_collect_garbage(int argc, char * * argv)
|
|||
});
|
||||
|
||||
if (removeOld) {
|
||||
std::set<fs::path> dirsToClean = {
|
||||
std::set<std::filesystem::path> dirsToClean = {
|
||||
profilesDir(),
|
||||
fs::path{settings.nixStateDir} / "profiles",
|
||||
fs::path{getDefaultProfile()}.parent_path(),
|
||||
std::filesystem::path{settings.nixStateDir} / "profiles",
|
||||
std::filesystem::path{getDefaultProfile()}.parent_path(),
|
||||
};
|
||||
for (auto & dir : dirsToClean)
|
||||
removeOldGenerations(dir);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue