Support ignore_access_denied in realpath on Window.
GitOrigin-RevId: 4fed501fee67b8533920fd729f1aa1944642db60
This commit is contained in:
parent
1a8eb4b4e5
commit
67b1cce74e
@ -231,14 +231,21 @@ Status rename(CSlice from, CSlice to) {
|
||||
return Status::OK();
|
||||
}
|
||||
|
||||
Result<string> realpath(CSlice slice, bool /*ignore_access_denied*/) {
|
||||
Result<string> realpath(CSlice slice, bool ignore_access_denied) {
|
||||
wchar_t buf[MAX_PATH + 1];
|
||||
TRY_RESULT(wslice, to_wstring(slice));
|
||||
auto status = GetFullPathNameW(wslice.c_str(), MAX_PATH, buf, nullptr);
|
||||
string res;
|
||||
if (status == 0) {
|
||||
return OS_ERROR(PSLICE() << "GetFullPathNameW failed for \"" << slice << '"');
|
||||
if (ignore_access_denied && errno == ERROR_ACCESS_DENIED) {
|
||||
res = slice.str();
|
||||
} else {
|
||||
return OS_ERROR(PSLICE() << "GetFullPathNameW failed for \"" << slice << '"');
|
||||
}
|
||||
} else {
|
||||
TRY_RESULT(t_res, from_wstring(buf));
|
||||
res = std::move(t_res);
|
||||
}
|
||||
TRY_RESULT(res, from_wstring(buf));
|
||||
if (res.empty()) {
|
||||
return Status::Error("Empty path");
|
||||
}
|
||||
|
Reference in New Issue
Block a user