How would I go about replacing a specific part of the parent_path using std::filesystem?
Originally I was converting an entry to a path then to a string like so:
Then using string modifiers to rename a specific part then using ifstream or ofstream to open the file using that string.
However, I was told it'd be better to use filesystem instead of string modifiers. But after looking into it for a while, I don't see how that is possible.
My program will recursively go through a directory and convert every entry to a path variable one at a time.
- I want it to replace "InputFiles" with "OutputFiles" in each path name.
- Then I want it to check if the entire path exists and if not, create the directories.
For example, I could have the file path:
And I want my code to:
1. Search the file path for "InputFiles" and if found then replace it with "OutputFiles"
2. Determine if the new file path already exists:
3. If it does not already exist, create the directories (not the text file).
If needed, my old code can be seen here - https://pastebin.com/7YKECYZX
* Specifically the iterateInDirectory() and writeJsonAsTxt() functions.
My new code is honestly such a mess at this point in time that it's not worth looking at.
Edit 2: Here are some useful links -