`<filesystem>`: `std::filesystem::exists` returns false for path longer than 260 symbols
Maintainer thường phản hồi trong vòng 2 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 48/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Ít trao đổi
- Công nghệ
- cpp
- Lĩnh vực
- operating-systems
Hướng nghiên cứu
Bắt đầu bằng cách biên dịch và chạy trình tái hiện Windows/MSVC được cung cấp để xác nhận hành vi đối với đường dẫn dài 262 ký tự. Sau đó, tìm cách triển khai std::filesystem::exists và điểm vào xử lý đường dẫn Windows của nó; công việc được hoàn tất khi một đường dẫn tồn tại dài hơn 260 ký tự trả về true với kết quả error-code rõ ràng và thành công.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Describe the bug
std::filesystem::exists returns false for an existing path longer than 260 characters and doesn't return an error (the error code is 0).
Command-line test case
C:\Temp>type repro.cpp
#include <cstdlib>
#include <filesystem>
#include <iostream>
#include <string>
#include <system_error>
#include <format>
#include <cassert>
int main()
{
// File name longer than 260 characters
const std::filesystem::path filePath = LR"(Reproduction_scenario_uniquie_folder\dddddddddddddddddddddddddddddd\aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.txt)";
std::wcout << std::format(L"filePath length: {}\n", filePath.wstring().size()); // 262
// Create the folder path recursively if it is not already there.
const auto mkdirResult = std::system(std::format("cmd.exe /c if not exist \"{}\" mkdir \"{}\"", filePath.parent_path().string(), filePath.parent_path().string()).c_str());
assert(mkdirResult == 0);
// Create the file
const auto echoResult = std::system(std::format("cmd.exe /c echo AAAA> \"{}\"", filePath.string()).c_str());
assert(echoResult == 0);
// Check if the file exists
std::error_code errorCode;
bool exists = std::filesystem::exists(filePath, errorCode);
std::cout << std::format("exists: {}\n", exists);
std::cout << std::format("errorCode value: {}\n", errorCode.value());
std::cout << std::format("errorCode category: {}\n", errorCode.category().name());
std::cout << std::format("errorCode message: {}\n", errorCode.message());
return 1;
}
C:\Temp>cl /EHsc /W4 /std:c++latest .\repro.cpp
Microsoft (R) C/C++ Optimizing Compiler Version 19.51.36248 for x64
Copyright (C) Microsoft Corporation. All rights reserved.
/std:c++latest is provided as a preview of language features from the latest C++
working draft, and we're eager to hear about bugs and suggestions for improvements.
However, note that these features are provided as-is without support, and subject
to changes or removal as the working draft evolves. See
https://go.microsoft.com/fwlink/?linkid=2045807 for details.
repro.cpp
Microsoft (R) Incremental Linker Version 14.51.36248.0
Copyright (C) Microsoft Corporation. All rights reserved.
/out:repro.exe
repro.obj
C:\Temp>.\repro.exe
filePath length: 262
exists: false
errorCode value: 0
errorCode category: system
errorCode message: The operation completed successfully.
Expected behavior
std::filesystem::exists should return true if the file with a path longer than 260 characters exists.
- Ngôn ngữ chính
- C++
- Star
- 11.2k
- Fork
- 1.7k
- Merge trung bình
- 4 ngày 4 giờ
- Pull request đã merge (30 ngày)
- 14
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của microsoft/STL
-
LWG
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
Maintainer thường phản hồi trong vòng 2 ngày
-
generator LWG
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
Maintainer thường phản hồi trong vòng 2 ngày
-
LWG
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
Maintainer thường phản hồi trong vòng 2 ngày
-
`<__msvc_math.hpp>`: `_USE_MATH_DEFINES` is ignored after the first `<math.h>` include under `/Zc:cmath`Có thể đã có người làm @tiagomacarios đã nhận 10 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
Maintainer thường phản hồi trong vòng 2 ngày
-
enhancement
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
Maintainer thường phản hồi trong vòng 2 ngày
Tất cả issue của microsoft/STL
Issue tương tự
-
bug data-types
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 71/100
ClickHouse/clickhouse-odbc#680 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
enhancement
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
ionut-mihalache/aqua#31 · 1 bình luận ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
Maintainer thường phản hồi trong vòng 1 ngày
-
needs-kind
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 63/100
villagesql/villagesql-server#1702 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 2 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
microsoft/vcpkg-tool#2191 · 1 reaction ·
Maintainer thường phản hồi trong vòng 1 ngày