I have an assignment that require me to develop a program that is passed either a file name or a directory name.
if what is passed is a directory name then i have to read all the files in that directory and basically do some processing on them.
the problem is that I am using c++ and c++ out of the box doesn't really play nice with file systems without third party/system libs.
how can I read all the files from a directory without platform dependency because I am using a windows machine and the grader is using linux machine.
I tried to use filesystem and I have gcc 9.2 but it doesn't compile
it doesn't compile this file:
#include <iostream>
#include <filesystem>
namespace fs = std::filesystem;
int main(){
fs::path p("some-path");
}
it results in this compiler error:
testfs.cpp:4:21: error: 'filesystem' is not a namespace-name
4 | namespace fs = std::filesystem;
| ^~~~~~~~~~
testfs.cpp: In function 'int main()':
testfs.cpp:8:5: error: 'fs' has not been declared
8 | fs::path p("some-path");