Questions tagged [std-filesystem]

c++ std::filesystem discussion, std::filesystem was added to the ISO C++ standard library in C++17

Specification available from http://en.cppreference.com/w/cpp/filesystem

165 questions
0
votes
0 answers

std::filesystem linker errors with Qt creator

First, yes, I saw this topic: How to avoid std::filesystem linker errors with Qt? I have my c++ project and there I used a std::filesystem .I can compile it with cmd ( g++ (GCC) 9.2.0 )and for example: g++ -std=c++17 -Wall -Wconversion-null -c…
0
votes
2 answers

How do I know when I found the end of the sub folder directory? c++

I am currently using a directory iterator to read through an entire directory, and it does it well because it reads through every file in any sub folder in the directory. Is there a way to know when it has hit the end of the sub folder and will be…
user11260823
0
votes
1 answer

Working with std::filesystem, error shows cannot convert int to _Valty

I'm making a program to help me understand the ins-and-outs of std::filesystem. However, when I went to build, I got an error (C2440) that I cannot convert type 'int' to '_Valty' when using directory_iterator in conjunction with directory_entry. It…
0
votes
3 answers

C++ std::filesystem::copy fail with "Network location cannot be reached"

I have written a small c++ application which is being automatically started after Windows boot on a couple of clients. This application will copy a file from a network share (same network share for all clients) to the local disk. When I reboot all…
0
votes
2 answers

How can I convert an std::filesystem::path to LPCSTR for use in one of the LoadLibrary() variants?

On Windows I'm trying to use one of the variants of LoadLibrary() to open a dll previously written to an std::filesystem::path with an ofstream. Note: I know the dll is written correctly as I can use it in the standard fashion by linking to it at…
Morgan
  • 5
  • 5
0
votes
1 answer

how can I use std::filesystem with mingw32-make and msys2 on windows

I'm trying to compile my linux code on windows. It blocks because of my use of std::filesystem. So I try to do a minimal example according to this post : C++17 filesystem using nuwen MinGW on Windows 10 I use the same code : #include…
Kafka
  • 720
  • 6
  • 21
0
votes
0 answers

Segmentation fault whenever fs::path is destroyed

Whenever I run this code I get segmentation fault(core dumped). It compiles without error or warnings but I still get the segfault. I'm running on Ubuntu 19.04 on amd ryzen 2400g I've compiled it on g++-8 and clang-8, and in both I get the seg…
Kenny Castro
  • 121
  • 11
0
votes
2 answers

is C++17 std::filesystem::recursive_directory_iterator::pop equal to boost::filesystem::recursive_directory_iterator::no_push

As the C++17 std::filesystem is very similar to the boost::filesystem, I was trying to do the same thing asked in this question: Escaping some Directories in iteration But I found out that in the std::filesystem::recursive_directory_iterator there…
Amir Rasti
  • 706
  • 7
  • 19
0
votes
0 answers

Cannot use `std::filesystem` even if declared supported

The latest versions of GCC and clang support C++17's std::filesystem (ref). Why does this program not compile? #include #include #include #include namespace fs = std::filesystem; int main() { …
Pietro
  • 12,086
  • 26
  • 100
  • 193
0
votes
1 answer

Is it possible to make non-existing directories automatically when copying a file?

I'm experimenting with the new std::filesystem library. I wish to make a program which copies files listed by the user into a given directory. But the naive approach using std::filesystem::copy or std::filesystem::copy_file didn't work when a listed…
Junekey Jeon
  • 1,496
  • 1
  • 11
  • 18
-1
votes
0 answers

How can I use std::filesystem::path with the std::system function?

I am trying to write a function that will launch a batch compiler if a file is out of date and needs to be recompiled, but I am really struggling to get the std::filesystem::path object to work nicely with the std::system function. I have gone…
-1
votes
1 answer

How can i get all files from disk?

I have to create a vector of all files on my disk, starting from root ("C:/"). I used filesystem library and recursive_directory_iterator, however program throws filesystem::filesystem_error when it reaches some of system directories which only the…
dummygum
  • 1
  • 1
-1
votes
1 answer

Emulating mkdir -p with the C++ standard library

This question: mkdir c++ function tells us how to create a directory programmatically in C++, introducing us to std::filesystem::create - which acts similarly to the mkdir command in Unix shells. However, this does not seem to allow for recursively…
einpoklum
  • 118,144
  • 57
  • 340
  • 684
-1
votes
1 answer

`std::filesystem::weakly_canonical` with special path parts fails

I have a path composed of some parts that end up containing special path parts /../../ and to the right side some hypothetical parts. To left of the special parts the path can evaluate to a real path. According to reference the hypothetical parts…
darune
  • 10,480
  • 2
  • 24
  • 62
-2
votes
1 answer

std::filesystem::canonical and std::filesystem::absolute are not working

I am using C++2a standard Visual Studio 2019 as compiler for the code. std::filesystem::path parentPathX(argv[0]); std::cout << "Running: " << argv[0] << std::endl; std::cout << "Path wise: " << parentPathX.string() <<…
Tarun Maganti
  • 3,076
  • 2
  • 35
  • 64
1 2 3
10
11