boost::filesystem: removing directory recursively?
Is there an easy / elegant way to remove directory contents recursively using boost::filesystem? I see that there's a create_directories() convenience function, but there's no such convenience function for removing a directory and all its contents. moreover, recursive_directory_iterator() does not return an iterator that contains the directory contens in the order suitable for removal :( I wonder if there's an easy / elegant way to do this? Akos
On Mon, Sep 1, 2008 at 12:05, Ákos Maróy
Is there an easy / elegant way to remove directory contents recursively using boost::filesystem? I see that there's a create_directories() convenience function, but there's no such convenience function for removing a directory and all its contents.
moreover, recursive_directory_iterator() does not return an iterator that contains the directory contens in the order suitable for removal :(
I wonder if there's an easy / elegant way to do this?
Seems there's a remove_all in the operations: http://www.boost.org/doc/libs/1_36_0/libs/filesystem/doc/reference.html#Oper... I seems like it should be classified as a convenience function, though, since it appears to be implemented entirely in terms of other boost.filesystem features and does seem the same sort of thing as create_directories... HTH, ~ Scott
Scott,
Seems there's a remove_all in the operations: http://www.boost.org/doc/libs/1_36_0/libs/filesystem/doc/reference.html#Oper...
I seems like it should be classified as a convenience function, though, since it appears to be implemented entirely in terms of other boost.filesystem features and does seem the same sort of thing as create_directories...
Thanks for the pointer. I'm still using boost 1.35.0, and this seems to have been introduced in 1.36. When I'll upgrade, I'll be able to use it :) Thanks, Akos
Ákos Maróy wrote:
Thanks for the pointer. I'm still using boost 1.35.0, and this seems to have been introduced in 1.36. When I'll upgrade, I'll be able to use it :)
remove_all exists in boost for a long time - at least since version 1.32 (http://www.boost.org/doc/libs/1_32_0/libs/filesystem/doc/operations.htm#remo...). Somehow it is missing in the documentation in 1.34 and 1.35, but the implementation is there so you should be able to use it in 1.35.0! Best regards, Wolfgang
Wolfgang Fertsak wrote:
Ákos Maróy wrote:
Thanks for the pointer. I'm still using boost 1.35.0, and this seems to have been introduced in 1.36. When I'll upgrade, I'll be able to use it :)
remove_all exists in boost for a long time - at least since version 1.32 (http://www.boost.org/doc/libs/1_32_0/libs/filesystem/doc/operations.htm#remo...). Somehow it is missing in the documentation in 1.34 and 1.35, but the implementation is there so you should be able to use it in 1.35.0!
thanks - I'm using it right away! :) Akos
participants (3)
-
Scott McMurray
-
Wolfgang Fertsak
-
Ákos Maróy