|
11 | 11 |
|
12 | 12 | using namespace nix; |
13 | 13 |
|
| 14 | +namespace nix::fs { using namespace std::filesystem; } |
| 15 | + |
14 | 16 | struct CmdEval : MixJSON, InstallableValueCommand, MixReadOnlyOption |
15 | 17 | { |
16 | 18 | bool raw = false; |
17 | 19 | std::optional<std::string> apply; |
18 | | - std::optional<Path> writeTo; |
| 20 | + std::optional<fs::path> writeTo; |
19 | 21 |
|
20 | 22 | CmdEval() : InstallableValueCommand() |
21 | 23 | { |
@@ -75,20 +77,20 @@ struct CmdEval : MixJSON, InstallableValueCommand, MixReadOnlyOption |
75 | 77 | if (writeTo) { |
76 | 78 | stopProgressBar(); |
77 | 79 |
|
78 | | - if (pathExists(*writeTo)) |
79 | | - throw Error("path '%s' already exists", *writeTo); |
| 80 | + if (fs::symlink_exists(*writeTo)) |
| 81 | + throw Error("path '%s' already exists", writeTo->string()); |
80 | 82 |
|
81 | | - std::function<void(Value & v, const PosIdx pos, const std::filesystem::path & path)> recurse; |
| 83 | + std::function<void(Value & v, const PosIdx pos, const fs::path & path)> recurse; |
82 | 84 |
|
83 | | - recurse = [&](Value & v, const PosIdx pos, const std::filesystem::path & path) |
| 85 | + recurse = [&](Value & v, const PosIdx pos, const fs::path & path) |
84 | 86 | { |
85 | 87 | state->forceValue(v, pos); |
86 | 88 | if (v.type() == nString) |
87 | 89 | // FIXME: disallow strings with contexts? |
88 | 90 | writeFile(path.string(), v.string_view()); |
89 | 91 | else if (v.type() == nAttrs) { |
90 | | - // TODO abstract mkdir perms for Windows |
91 | | - createDir(path.string(), 0777); |
| 92 | + // Directory should not already exist |
| 93 | + assert(fs::create_directory(path.string())); |
92 | 94 | for (auto & attr : *v.attrs()) { |
93 | 95 | std::string_view name = state->symbols[attr.name]; |
94 | 96 | try { |
|
0 commit comments