|
7 | 7 | #include <iterator>
|
8 | 8 |
|
9 | 9 | #include "common/exe_path.h"
|
| 10 | +#include "common/filesystem.h" |
10 | 11 | #include "llvm/ADT/StringRef.h"
|
11 | 12 |
|
12 | 13 | namespace Carbon {
|
@@ -46,7 +47,8 @@ auto GetBusyboxInfo(const char* argv0) -> ErrorOr<BusyboxInfo> {
|
46 | 47 | // handled in the other return path.
|
47 | 48 | std::string prefix_root = info.bin_path.parent_path().string() +
|
48 | 49 | "/prefix_root/lib/carbon/carbon-busybox";
|
49 |
| - if (std::filesystem::exists(prefix_root)) { |
| 50 | + if (auto access = Filesystem::Cwd().Access(prefix_root); |
| 51 | + access.ok() && *access) { |
50 | 52 | info.bin_path = prefix_root;
|
51 | 53 | }
|
52 | 54 | return info;
|
@@ -75,24 +77,23 @@ auto GetBusyboxInfo(const char* argv0) -> ErrorOr<BusyboxInfo> {
|
75 | 77 | ? parent_path / ".." / "lib" / "carbon"
|
76 | 78 | : parent_path / ".." / "..";
|
77 | 79 | auto busybox_path = lib_path / "carbon-busybox";
|
78 |
| - std::error_code ec; |
79 |
| - if (std::filesystem::exists(busybox_path, ec)) { |
| 80 | + if (auto access = Filesystem::Cwd().Access(busybox_path); |
| 81 | + access.ok() && *access) { |
80 | 82 | info.bin_path = busybox_path;
|
81 | 83 | return info;
|
82 | 84 | }
|
83 | 85 | }
|
84 | 86 |
|
85 | 87 | // Try to walk through another layer of symlinks and see if we can find the
|
86 | 88 | // installation there or are linked directly to the busybox.
|
87 |
| - std::error_code ec; |
88 |
| - auto symlink_target = std::filesystem::read_symlink(info.bin_path, ec); |
89 |
| - if (ec) { |
| 89 | + auto readlink = Filesystem::Cwd().Readlink(info.bin_path); |
| 90 | + if (!readlink.ok()) { |
90 | 91 | return ErrorBuilder()
|
91 | 92 | << "expected carbon-busybox symlink at `" << info.bin_path << "`";
|
92 | 93 | }
|
93 | 94 |
|
94 | 95 | // Do a path join, to handle relative symlinks.
|
95 |
| - info.bin_path = parent_path / symlink_target; |
| 96 | + info.bin_path = parent_path / *readlink; |
96 | 97 | }
|
97 | 98 | }
|
98 | 99 |
|
|
0 commit comments