Slightly more std::filesystem for nix eval#11650
Conversation
| namespace nix::fs { using namespace std::filesystem; } | ||
|
|
There was a problem hiding this comment.
nitpick(non-blocking): Could maybe even move this inside of the class declaration.
| namespace nix::fs { using namespace std::filesystem; } | |
| using fs = std::filesystem; | |
There was a problem hiding this comment.
Actually it can't be that, I'll say why below
| @@ -11,11 +11,13 @@ | |||
|
|
|||
| using namespace nix; | |||
There was a problem hiding this comment.
nitpick(non-blocking): Would prefer to see this wrap the whole file.
|
|
||
| using namespace nix; | ||
|
|
||
| namespace nix::fs { using namespace std::filesystem; } |
There was a problem hiding this comment.
I hadn't noticed this before, but there are a few of these nix::fs namespace declarations in src/nix now. I don't really understand what that's for? Just use std::filesystem so people don't have to wonder what nix::fs is.
There was a problem hiding this comment.
That's because of
nix/src/libutil/file-system.hh
Lines 129 to 144 in 26c3fc1
I hope that with more std::filesystem, most of file-system.hh goes away. However, there are a few things that aren't in there they we need, like this symlink_exists.
I put it in an fs namespace with the idea that if C++ files (not headers!) use fs:: as a shorthand for std::filesystem::, then it will nicely gell with the existing apis.
namespace nix::fs { using namespace std::filesystem; }I do because if I do
using fs = std::filesystem;then that fs will shadow, rather than expand, the namespace fs I put in file-system.hh.
I tried a few combinations, and the thing you commented on is the only one that will work (other than declaring symlink_exists in std::filesystem directly, which would be ill-advised.)
There was a problem hiding this comment.
clangd reports for an fs::current_path identifier:
function current_path
provided by→ path
// In namespace std::filesystem
path current_path()
This pattern also seems useful for polyfilling functions from new C++ versions.
53fa147 to
b5c8865
Compare
roberth
left a comment
There was a problem hiding this comment.
Refactor LGTM. Details can be improved if need be.
|
Am I missing something or is this borked with release builds without asserts? // TODO abstract mkdir perms for Windows
createDir(path.string(), 0777);// Directory should not already exist
assert(fs::create_directory(path.string()));Without asserts the call to [[maybe_unused]] bool created = fs::create_directory(path.string());
assert(created); |
|
@xokdvium Sorry I missed your message above! |
Context
Progress on #9205
Priorities and Process
Add 👍 to pull requests you find important.
The Nix maintainer team uses a GitHub project board to schedule and track reviews.