Can someone guide me on a possible solution? I don’t want to use /bin/cp or any other foreign apps. I want my program to be independent. Also I know that every system is quite specific, so I’m interested in UNIX/Linux compatibility.
How can I solve it? Just going down the source directory and creating a new directories in the target one and copying files in them, or there is a better solution?
BTW my goal is: copy all first level subdirs recursively into target dir if they are not present there
You really need some kind of recursive descent into the directory tree. Doing this, you can actually make this very portable (using
opendir/readdiron Linux andFindFirstFile/FindNextFileon Windows). The problem that remains is the actual copying. You can use the C standard library for that with the following algorithm:freada block of constant size from the source, thenfwriteit to the target. Stop if the source file contains no more dataHope this helps 🙂