用C ++创建目录 [英] Create directory in C++

查看:133
本文介绍了用C ++创建目录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在用DirectX和C ++制作一个简单的游戏. 但是我想在文档"中为设置等创建目录.

I'm making a simple game in DirectX and C++. But I want to create a directory in Documents for the settings etc.

但是我不知道该怎么做?

But I don't know how I need to do this?

有人可以帮助我吗?

推荐答案

C ++ 11标准目录. C ++ 17具有 <filesystem> 标准标头.

The C++11 standard n3337 does not know about directories. C++17 has <filesystem> standard header.

如果您的实现兼容C ++ 17(可能不兼容),请使用 std::filesystem::create_directory

If your implementation is C++17 compliant (it probably is not), use std::filesystem::create_directory

否则,请使用操作系统原语.请注意,目录的概念可能是特定于操作系统的(即,一个操作系统与另一个操作系统是不同的,甚至在不同的文件系统).对于Windows,请研究 WinAPI (因此考虑 CreateDirectoryA ).对于Linux,请查看其 syscalls(2)(因此考虑 mkdir(2))

Otherwise, use operating system primitives. Be aware that the notion of directory can be OS specific (i.e. different in one OS from another, perhaps even between different file systems). For Windows, study the WinAPI (so consider CreateDirectoryA). For Linux, look into its syscalls(2) (so consider mkdir(2))

某些框架,尤其是 Qt POCO Boost ,在其上方提供通用包装.

Some frameworks, notably Qt, POCO, Boost, provide common wrappers above them.

这篇关于用C ++创建目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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