我正在使用open函数创建一个文件并使用O_CREAT | O_EXCEL。我已经通过了“0666”模式。但通过最终掩盖分配给它的许可是-rw-r-r--而不是 -rw-rw-rw-。有人告诉我,我可以使用umask(011),然后重新设置原始蒙版。 但我不知道如何通过这个在c + +程序。这是我在做什么的小片段。如何忽略umask以创建具有给定权限的文件
# include <iostream>
# include <stdio.h>
# include <conio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
using namespace std;
int main()
{
int fd = open("C:\\Users\\Ritesh\\Music\\music.txt", O_CREAT | O_EXCL, 0666);
getch();
return 0;
}
创建文件C:\Users\Ritesh\Music\music.txt with permission -rw-r--r-- .
我想这是-rw-rw-rw-
我很困惑。你如何拥有Unix权限位和DOS路径名的文件系统?什么O/S同时提供''和''? –
2012-02-21 16:04:01
@Rob不要担心我只是复制它而寻找打开的头文件。我只是在我的Windows系统上使用DEV C++。实际上,我在工作场所中使用了solaris。很抱歉,如果它让你感到困惑。 – Invictus 2012-02-21 16:09:46
那么,你问的是哪个系统? Windows还是Solaris? – 2012-02-21 18:18:02