210 questions
3
votes
1
answer
120
views
std::filesystem::path::parent_path() GCC vs Clang behavior with multiple leading separators
I stumbled upon different behavior of std::filesystem::path::parent_path() when a path contains leading slashes. Clang says that the parent of ///a is /// (which is what I would expect), but GCC says ...
0
votes
1
answer
149
views
Syncronizing files between threads
Assume 2 threads, t1 and t2, mutex m and file f running on a RPi.
t1 waits at m, creates a file f with some content, close f and verify that f exists. Finally m is relased and t1 does a short delay to ...
1
vote
4
answers
133
views
How to convert std::filesystem::path to QString
I am currently working with QPixmap to set an image to a label, but improvising a way around since my qrc file isn't working. I am trying to access the image folder in the project directory and trying ...
0
votes
0
answers
117
views
Can std::(weakly)canonical return an error for existing directory absolute path?
Based on cppreference, I was under impression that std::canonical and std::weakly_canonical return the input path if it is an absolute directory path to existing directory that has no dot, dot-dot ...
3
votes
1
answer
131
views
Is it possible to access std::filesystem::path components as views / without copying?
When using std::filesystem::{recursive_}directory_iterator, it's common to want to filter the results based on some pattern. I typically implement it something like:
template <typename ...
8
votes
0
answers
406
views
Is there a safe way to create directories with std::filesystem?
I have compared the description of POSIX mkdir against
the description of std::filesystem::create_directory,
the specification draft for std::filesystem::create_directory, and
the specification draft ...
1
vote
1
answer
115
views
Can std::filesystem::path::wstring() modify errno?
I have a function that reports errno errors:
void reportError(int err, const std::wstring& fname);
The pattern of invocation goes like this:
int fd = open(fileName.c_str(), O_RDONLY);
if (...
26
votes
2
answers
2k
views
When is p.stem() + p.extension() != p.filename()?
In the std::filesystem::path::extension() page on cppreference.com, it says the following:
On a non-POSIX system, it is possible that p.stem() + p.extension() != p.filename() even though generic-...
3
votes
0
answers
126
views
Why does std::filesystem::relative_path() only sometimes return empty strings for nonexistent paths?
I'm trying to use the C++ filesystem API to figure out if some paths are relative to the current directory or not. I thought I might be able to use the std::filesystem::relative() API but it's giving ...
0
votes
1
answer
126
views
Change c++ filesystem exception language
How can I change the language on which std::filesystem::filesystem_error creates message?
By default it creates message on my native language and when I try to output it to console - it messes up the ...
-2
votes
1
answer
418
views
build problem with cmake C++ boost::filesystem and CMP0167
I stumbled over a boost related problem when building with cmake (in Msys2).
a bit of history:
It started with a tool I developed in linux and now I want to build it also in msys for windows.
Here I ...
1
vote
0
answers
119
views
Checking existence of multiple files with std:filesystem::exists is faster than using a set of file names with std::filesystem::directory_iterator?
I want to know if checking multiples files in a directory using a std::unordered_set of files names using std::filesystem::directory_iterator is faster than using std::filesystem::exists. There's some ...
0
votes
1
answer
121
views
std::filesystem::path in a Linux/POSIX environment: root_drive vs root_directory vs root_path
Given an instance of std::filesytem::path in a Linux environment, what exactly do the root_name, root_directory, and root_path methods return?
I understand that in the Linux/POSIX environment, the UNC ...
1
vote
1
answer
201
views
std::filesystem::canonical converts the mapped network drive to network path
For the below code:
std::error_code ec;
auto long_path = std::filesystem::canonical("W:\\31\\arawat.fielsystem_default_check\\matlab\\check_std\\check_std\\").string();
I am getting the ...
1
vote
2
answers
141
views
Use of `std::variant` to select types after command prompt input, is that even possible?
I am at a very early stage in writing a C++ program replicating the most basic functions of the ls bash command.
I use the <filesystem> header.
The std::filesystem::directory_iterator and std::...