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

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

问题描述

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

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.

本质上,我想做一些与

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

您能否建议在 C++ 中执行此操作的最佳方法以及所需的头文件.是否可以使用 sys/stat.h 或 sys/types.h 或 sys/dir.h 执行此操作?!

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

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天全站免登陆