Moving a directory tree in C ++

UPDATE: Since the adoption of C ++ 17, there is a <filesystem> header included in a language that does just that. See the compiler documentation to see if it is supported.

The original question:

It was my curiosity for a while: how do you go through a directory tree without using boost or a third-party library? Just plain ol 'C ++ (examples from 98, 99, 01, 0x and 1x specifications are ok.)? This was done the day before the impulse appeared, so there should be a way to do it.

+7
source share
2 answers

Please take a look at http://en.wikipedia.org/wiki/Dirent.h

The link also contains a link to the dirent.h implementation for Windows, or you can use cygwin

If you want to just do it for Windows, you can use this example

http://msdn.microsoft.com/en-us/library/aa365200%28VS.85%29.aspx

+6
source

There are no standard file system functions, so you wonโ€™t get answers that use "plain C ++". For POSIX systems, opendir is used. For Windows FindFirstFile . I am not sure about other OS.

There is a reason people recommend Boost Filesystem - it is portable and takes care of all these details for you.

+4
source

All Articles