std-filesystem Questions
2
Solved
Why is it that is_regular_file function that is part of std::filesystem reports true for a symbolic link? I have looked at the documentation for the call and can't find the reason and the examples ...
Archangel asked 5/2 at 22:46
2
Solved
The traditional Unix shell utility, dirname, finds the name of the directory that contains the given file. This is useful if you want to find other sister files in the same directory. Here are a fe...
Rosenarosenbaum asked 24/1 at 10:48
4
It is possible to append multiple paths in a row using the / operator:
std::filesystem::path p1{"A"};
auto p2 = p1 / "B" / "C";
which is rather convenient. However,...
Pahl asked 27/1, 2021 at 11:3
2
I have the following code:
for (const auto& x : std::filesystem::directory_iterator(dir)) {
// do stuff with x
}
dir might not exist, and I want to treat this case as if the dir is empty. I c...
Etherege asked 7/8, 2021 at 16:45
3
Solved
My program is supposed to create two files with user-specified paths.
I need to know if the paths lead to the same location, to end with an error before I start changing the filesystem.
Because the...
Mixologist asked 19/6, 2022 at 16:20
1
Solved
About std::filesystem::is_regular_file(path), cppreference.com says:
Checks if the given file status or path corresponds to a regular file […] Equivalent to s.type() == file_type::regular.
For ex...
Detwiler asked 18/4, 2022 at 7:15
1
Solved
std::filesystem::path doesn't seem to be aware of the windows long path magic prefix.
Is this per design or is there a mode/flag/compiler switch/3rd party library which can be used?
f.e.
for a pat...
Mycosis asked 23/3, 2022 at 16:24
4
Solved
I'm using gcc 7.2 on Ubuntu 16.04, and I need to use the new filesystem library from C++17. Even though there is indeed a library called experimental/filesystem, I can't use any of its members. For...
Batruk asked 11/2, 2018 at 7:29
2
Solved
I have a string that contains the path to some file. The file doesn't need to exist (in my function it can be created), but it's necessary that directory must exist. So I want to check it using the...
Carbajal asked 31/1, 2022 at 11:12
2
Solved
In order to use: std::filesystem from the C++17 library, my project was migrated from vs2015 to vs2017.
My project compiles and runs without error, the lib is included without error, but when tryin...
Hosbein asked 3/6, 2018 at 16:57
1
Solved
I am writing a linux command line program that will return the size of a directory. The program works as expected, except when specifically dealing with root directories. I know many files in the r...
Stokehold asked 10/3, 2021 at 6:4
2
I am trying to get the last file name.
Below code does it very elegantly. But it is iterating through all the files inside the directory.
Is it possible to get the last file without iteration?
#inc...
Lavish asked 10/12, 2020 at 23:7
1
Solved
I'm trying to include <filesystem>, but when I use a namespace, it shows this error:
std:: has no member "filesystem"
I know in older times it is <experimental/filesystem> and...
Clincher asked 24/9, 2020 at 8:44
1
Solved
The following program crashes:
#include <iostream>
#include <filesystem>
namespace fs = std::filesystem;
int main()
{
fs::path p1 = "/usr/lib/sendmail.cf";
std::cout <&...
Disillusionize asked 15/9, 2020 at 13:8
2
I have a public folder pub with subfolders and files in it. A user gives me now a relative filepath, I perform some mappings, and I read the file with fstream and return it to the user.
The proble...
Febrific asked 10/4, 2019 at 10:40
2
Solved
I have this piece of code
auto path = std::filesystem::path("/root/home/../opt/.");
I had tried std::filesystem::absolute() but then realized it is for something else than the reasult I ...
Jedjedd asked 4/7, 2020 at 11:42
1
Solved
I began using experimental::filesystem when it had just come out and I was advised to link in stdc++fs using target_link_libraries(MyTarget stdc++fs) in CMake. My programme builds either way but ma...
Roxy asked 19/6, 2020 at 10:45
1
Solved
I have a path to a directory and I want to get the name of that directory, using C++'s std::filesystem. For example, if the path was:
std::filesystem::path fake_path("C:\\fake\\path\\to\\my_direc...
Overpass asked 26/5, 2020 at 9:16
1
Solved
I have a root path represented by an std::filesystem::path. I want to add some user provided filename to this path and make sure the resulting path is not out of the root directory.
For example:
...
Igraine asked 9/4, 2020 at 14:34
2
Solved
I have a sample piece of C++ code that is throwing an exception on Linux:
namespace fs = std::filesystem;
const fs::path pathDir(L"/var/media");
const fs::path pathMedia = pathDir / L"COMPACTO - D...
Kapoor asked 23/10, 2019 at 11:29
1
Solved
I can't seem to find a list of error codes that might be passed into the ec parameter for std::filesystem::copy.
cppreference.com seems to indicate that the error codes are OS-specific.Looking at ...
Sacellum asked 18/11, 2019 at 9:17
1
Solved
Using Xcode 11.1, building on MacOS 10.14.6 (Mojave), the following lines:
#include <filesystem>
typedef std::filesystem::path my_path;
...generate this compiler error:
'path' is unavaila...
Gains asked 2/11, 2019 at 2:42
1
I'm trying to format the modification time of a file as a string (UTC). The following code compiles with GCC 8, but not GCC 9.
#include <chrono>
#include <filesystem>
#include <ioma...
Sheya asked 27/6, 2019 at 10:9
1
Solved
Consider this minimal example:
#include <filesystem>
#include <iostream>
int main()
{
std::cout << std::filesystem::current_path() << '\n';
}
It works as expected in GC...
Kreda asked 16/9, 2019 at 19:43
3
Solved
When I attempt to use std::filesystem::path as a function argument, it segfaults on my machine. Here is a minimal example:
#include <filesystem>
void thing(const std::filesystem::path& ...
Hen asked 16/6, 2019 at 3:29
1 Next >
© 2022 - 2024 — McMap. All rights reserved.