在OS X的tmp文件夹中创建一个临时文件夹 [英] Creating a temporary folder in tmp folder on OS X

查看:312
本文介绍了在OS X的tmp文件夹中创建一个临时文件夹的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用C ++语言在tmp文件夹中创建一个临时文件夹.

How can i create a temporary folder in tmp folder using C++ language.

我有3卷. Leopard,Development和10.6(在Mac OS X中),我想在当前主目录中创建一个临时目录.

I have 3 volumes. Leopard, Development and 10.6 (in Mac OS X) and I want to create a temp directory in current home directory.

这是我的代码.我对这行char* tempdir = "/Volumes/Development/NewFolder.XXXXXX"感到困惑:

Here is my code. I am confused about this line char* tempdir = "/Volumes/Development/NewFolder.XXXXXX":

if (!mkdtemp(tempdir)) 

   fprintf(stderr, "Not able to create directory"); 

推荐答案

在POSIX下,您可以使用 mkdtemp 创建具有唯一名称的目录.在Windows上,使用 GetTempPath 进行检索临时目录的名称,然后在其中创建一个具有随机名称的目录.

Under POSIX, you can use mkdtemp to create a directory with a unique name. On Windows, use GetTempPath to retrieve the name of the temp directory, then create a directory with a random name there.

这篇关于在OS X的tmp文件夹中创建一个临时文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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