如何在Linux上清除c ++中的目录内容(基本上,我想做'rm -rf< directorypath> / *' [英] How to clear directory contents in c++ on Linux (basically, i want to do 'rm -rf <directorypath>/*'

查看:146
本文介绍了如何在Linux上清除c ++中的目录内容(基本上,我想做'rm -rf< directorypath> / *'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在Linux(Ubuntu)上编写一个c ++程序。我想删除一个目录的内容。它可以是松散的文件或子目录。



本质上,我想做一些相当于

  rm -rf< path-to-directory> / * 

你可以建议在c ++中执行此操作的最佳方法以及所需的头文件。
可以使用sys / stat.h或sys / types.h或sys / dir.h吗?

解决方案

Boost remove_all http:// www .boost.org / doc / libs / 1_31_0 / libs / filesystem / doc / index.htm


I am writing a c++ program on Linux (Ubuntu). I would like to delete the contents of a directory. It can be loose files or sub-directories.

Essentially, i would like to do something equivalent to

rm -rf <path-to-directory>/*

Can you suggest the best way of doing this in c++ along with the required headers. Is it possible to do this with sys/stat.h or sys/types.h or sys/dir.h ?!

解决方案

Boost remove_all http://www.boost.org/doc/libs/1_31_0/libs/filesystem/doc/index.htm

这篇关于如何在Linux上清除c ++中的目录内容(基本上,我想做'rm -rf&lt; directorypath&gt; / *'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆