-
Notifications
You must be signed in to change notification settings - Fork 1.5k
<filesystem>
: filesystem::exists
returns false
for c:\hiberfil.sys
#2370
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Results of investigation: First, I created the following program for testing: #include <filesystem>
#include <iostream>
namespace fs = std::filesystem;
int wmain(int argc, wchar_t** argv) {
if (argc < 2) {
std::wcerr << L"Not enough arguments\n";
return 1;
}
std::error_code ec;
for (int i = 1; i < argc; ++i) {
std::wcout << L"on file: " << argv[i] << L'\n';
(void) fs::exists(argv[i], ec);
std::cout << " exists: ";
if (ec) {
std::cout << "error: " << ec.message() << '\n';
} else {
std::cout << "no error\n";
}
(void) fs::symlink_status(argv[i], ec);
std::cout << " symlink_status: ";
if (ec) {
std::cout << "error: " << ec.message() << '\n';
} else {
std::cout << "no error\n";
}
(void) fs::status(argv[i], ec);
std::cout << " status: ";
if (ec) {
std::cout << "error: " << ec.message() << '\n';
} else {
std::cout << "no error\n";
}
}
} For
I will also note the following files act the same as
InvestigationI had a few thoughts on why this would be; here are the results of my investigation:
Given this, I'm not sure what's special about these four files. How do other programs treat these filesShells - PowerShell and CMDPowerShell:
CMD:
It seems like shells treat these as normal hidden files here. Rust
|
Given that the c++ spec says that |
This changes from using GetFileAttributesExW to FindFirstFileW, since FindFirstFileW gets the information from the directory and thus doesn't error out. Fixes microsoft#2370 This will require serious testing to make sure the behavior is the same.
This changes from using GetFileAttributesExW to FindFirstFileW, since FindFirstFileW gets the information from the directory and thus doesn't error out. Fixes microsoft#2370 This will require serious testing to make sure the behavior is the same.
Discussed in #2365
Originally posted by s-kipnis November 29, 2021
This behavior is at least strange. The file does exist, but has quite limited permissions.
Is it bug or side effect of Win32 API?
We need to look at all of the filesystem operation functions and determine what level of accurate answers we can provide for various questions.
The text was updated successfully, but these errors were encountered: