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
1 answer

How to check if std::filesystem::copy is ended?

Copying files to a directory to another directory using this code auto const copyOption = std::filesystem::copy_options::recursive | std::filesystem::copy_options::skip_symlinks; std::filesystem::copy("/mnt/iso", "/mnt/usb", copyOption); Copying…
kramer
  • 177
  • 1
  • 4
  • 15
0
votes
2 answers

iterating through all the directories and subdirectories in c++

I wanted to use the std::filesystem::recursive_directory_iterator class to create a class method iterating through all subdirectories and processing found xml files. The only way I have found on the internet to do this was using a for loop like…
skrzypin
  • 3
  • 4
0
votes
1 answer

How to reset filesystem::current_path() in C++17?

I am writing a C++ program in which I change the working directory with std::filesystem::current_path(working_directory), where working_directory is a string. Is there a good way to, later in the program, reset the working directory to its original…
0
votes
1 answer

Why abort() method is called sometimes when I iterate over directory using std::filesystem::directory_terator?

I am creating a simple file watcher in C++. I am using std::filesystem::directory_iterator and sometimes it crashes with abort() being called. It works perfectly when I track creating and editing of files (which is not strange, because for that I…
CuriousPan
  • 783
  • 1
  • 8
  • 14
0
votes
0 answers

Check if user has the permission to create a file at path p, without creating a file at the path

In C++ is there a way to check, if we have the permission to create a file at a certain path without actually creating a file? I already read How do I create a file with boost filesystem without opening it Here is how we can do it by creating the…
Abhinav
  • 11
  • 3
0
votes
0 answers

Visual Studio 2019 C++ and std::filesystem changing to ISO C++17 Standard or adding _HAS_CXX17 1 do not work

based on this thread it is still not working although i changed to ISO C++17 Standard (/std:c++17) in c++ -> language in VS 2019 config. also try to set : #ifdef _WIN32 #define _HAS_CXX17 1 #endif it worked but to day it gave me compilation error…
user63898
  • 29,839
  • 85
  • 272
  • 514
0
votes
4 answers

std::filesystem:file_size send me an incoherent value

In order to read a file in my code, I use std::filesystem::file_size (https://en.cppreference.com/w/cpp/filesystem/file_size) to get his size. I use this code : template inline void read_binary_file(const fs::path filename,…
Kafka
  • 720
  • 6
  • 21
0
votes
1 answer

Determine if some relative directory is part of absolute path using std::filesystem::path

I can't figure out how to identify if absolute path contains some relative directory inside it using std::filesystem::path but still with no luck. I have the following peace of code: const std::filesystem::path absolutePath =…
Oleg
  • 1,027
  • 1
  • 8
  • 18
0
votes
1 answer

How can I erase first and last character in string?

This function returns an array of strings with a list of files in a folder. It looks like this: "folder//xyz.txt" How can I make it look like this? folder//xyz.txt Its the same but without "". vector list_of_files(string folder_name) …
0
votes
1 answer

fs::recursive_directory_iterator exception unhandled

I wrote code that searchs ".data" files in directory, when i do it in this way, works perfectly: std::string path("C:\\Users\\MyPC\\OneDrive\\Desktop\\Database"); std::string ext(".data"); std::string Datas[50]; int DataCounter = 0; …
0
votes
0 answers

Mingw bug?: std::filesystem::copy fails with filesystem error when file exist, even when the copy_option to overwrite_existing is defined

MINGW v. 8.0 -- The C compiler identification is GNU 10.2.0 -- The CXX compiler identification is GNU 10.2.0 -- Check for working C compiler: P:/MSYS2/mingw64/bin/gcc.exe -- Check for working C compiler: P:/MSYS2/mingw64/bin/gcc.exe - works trying…
Fabian Keßler
  • 563
  • 3
  • 12
0
votes
0 answers

Issue with sorting a vector of C++17 Filesystem::last_write_time

I'm having an issue trying to sort a vector of files by their last write time. Sorting seems to work as intended, however sometimes even though the time string shows a higher date, the time_t is lower. Example Output: Wed Aug 19 01:51:07 2020 ||…
0
votes
0 answers

why path::root_name() has different behavior with and

For last couple of days I have been experimenting the behavior of few of the functions of filesystem and experimental/filesystem library. Note: I ran the code on https://godbolt.org/ below is the code snippet with its output 1.…
Praveer Kumar
  • 912
  • 1
  • 12
  • 25
0
votes
1 answer

Uninitialized Usage in libstdc++ filesystem?

Consider the following code: #include int main() { std::filesystem::path p{"/"}; } When compiling with clang10 with the flags -std=c++17 -fsanitize=memory -g -O1 -stdlib=libstdc++ it compiles totally fine, but when running, the…
n314159
  • 4,990
  • 1
  • 5
  • 20
0
votes
2 answers

Cross platform file list using wildcard

I'm looking for a cross platform function that supports wildcard listing of a directory contents similar to what FindFirstFile on windows. Is the wildcard pattern accepted in windows very specific to windows? I want something that supports…
Captain Jack sparrow
  • 959
  • 1
  • 13
  • 28
1 2 3
10
11