通过WIN32宏进行判断
 
window下mkdir函数
 
#include<direct.h>
int _mkdir( const char *dirname );
 
linux下mkdir函数mode_t参数详解

#include <sys/stat.h>
int mkdir(const char *path, mode_t mode);
 
参数:
path是目录名
mode是目录权限

返回值:
返回0 表示成功, 返回 -1表示错误,并且会设置errno值。

mode模式位:
mode 表示新目录的权限,可以取以下值:
S_IRUSR 
S_IREAD
S_IWUSR 
S_IWRITE 
S_IXUSR 
S_IEXEC 
S_IRWXU 
This is equivalent to (S_IRUSR | S_IWUSR | S_IXUSR). 
S_IRGRP 
Read permission bit for the group owner of the file. Usually 040. 
S_IWGRP 
Write permission bit for the group owner of the file. Usually 020. 
S_IXGRP 
Execute or search permission bit for the group owner of the file. Usually 010. 
S_IRWXG 
This is equivalent to (S_IRGRP | S_IWGRP | S_IXGRP). 
S_IROTH 
Read permission bit for other users. Usually 04. 
S_IWOTH 
Write permission bit for other users. Usually 02. 
S_IXOTH 
Execute or search permission bit for other users. Usually 01. 
S_IRWXO 
This is equivalent to (S_IROTH | S_IWOTH | S_IXOTH). 
S_ISUID 
This is the set-user-ID on execute bit, usually 04000. See How Change Persona. 
S_ISGID 
This is the set-group-ID on execute bit, usually 02000. See How Change Persona. 
S_ISVTX 
This is the sticky bit, usually 01000.
 
S_IRWXU 00700权限,代表该文件所有者拥有读,写和执行操作的权限
S_IRUSR(S_IREAD) 00400权限,代表该文件所有者拥有可读的权限
S_IWUSR(S_IWRITE) 00200权限,代表该文件所有者拥有可写的权限
S_IXUSR(S_IEXEC) 00100权限,代表该文件所有者拥有执行的权限
S_IRWXG 00070权限,代表该文件用户组拥有读,写和执行操作的权限
S_IRGRP 00040权限,代表该文件用户组拥有可读的权限
S_IWGRP 00020权限,代表该文件用户组拥有可写的权限
S_IXGRP 00010权限,代表该文件用户组拥有执行的权限
S_IRWXO 00007权限,代表其他用户拥有读,写和执行操作的权限
S_IROTH 00004权限,代表其他用户拥有可读的权限
S_IWOTH 00002权限,代表其他用户拥有可写的权限
S_IXOTH 00001权限,代表其他用户拥有执行的权限
 
例子:
#include <sys/types.h> #include <sys/stat.h> 
int status;
status = mkdir("/home/newdir", S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
这样就创建了一个newdir目录,权限通过ls -al 查看为
drwxr-xr-x
跟用linux命令mkdir创建的目录权限位一致。

linux和window下mkdir函数的更多相关文章

  1. linux和window下mkdir函数问题(转-锦曦月)

    通过WIN32宏进行判断   window下mkdir函数   #include<direct.h> int _mkdir( const char *dirname );   linux下 ...

  2. (转)关于linux挂载window下共享文件

    关于linux挂载window下共享文件的方法: ①事先建立linux下文件夹,例如“ /mnt/linux-folder”②用mount命令挂载    mount -o username=windo ...

  3. weblogic在linux和window下的安装

    weblogic在linux和window下的安装 weblogic下载地址 Windows server2008 一直下一步没什么坑 centos6.5 使用rpm安装jdk8 JDK下载 安装jd ...

  4. 测试linux和window下 jdk最大能使用多大内存

    在命令行下用 java -XmxXXXXM -version 命令来进行测试,然后逐渐的增大XXXX的值,如果执行正常就表示指定的内存大小可用,否则会打印错误信息. 发现在linux先 最多用java ...

  5. 远程登录Linux(window下操作Linux)

    参考文章:http://www.runoob.com/linux/linux-remote-login.html 1.Window系统上 Linux 远程登录客户端有SecureCRT, Putty, ...

  6. linux和window下生成任意大小的文件

    在Windows环境下的实现方法   使用fsutil命令,在windows xp和win 7下应该都自带了这个命令.命令的格式是 fsutil file createnew 新文件名 文件大小.例如 ...

  7. 对于linux下system()函数的深度理解(整理)

    原谅: http://blog.sina.com.cn/s/blog_8043547601017qk0.html 这几天调程序(嵌入式linux),发现程序有时就莫名其妙的死掉,每次都定位在程序中不同 ...

  8. 转:对于linux下system()函数的深度理解(整理)

    这几天调程序(嵌入式linux),发现程序有时就莫名其妙的死掉,每次都定位在程序中不同的system()函数,直接在shell下输入system()函数中调用的命令也都一切正常.就没理这个bug,以为 ...

  9. (笔记)Linux下system()函数的深度理解(整理)

    注:从其它地方转的非常好的一篇文章,值得深究! 这几天调程序(嵌入式linux),发现程序有时就莫名其妙的死掉,每次都定位在程序中不同的system()函数,直接在shell下输入system()函数 ...

随机推荐

  1. .Net平台开源作业调度框架Quartz.Net

    Quartz.NET介绍: Quartz.NET是一个开源的作业调度框架,是OpenSymphony 的 Quartz API的.NET移植,它用C#写成,可用于winform和asp.net应用中. ...

  2. 【Leetcode】357. Count Numbers with Unique Digits

    题目描述: Given a non-negative integer n, count all numbers with unique digits, x, where 0 ≤ x < 10n. ...

  3. 提升程序的特权(AdjustTokenPrivileges)

    首先列出需要的函数 1.OpenProcessToken 2.AdjustTokenPrivileges 3. LookupPrivilegeValue ----------------------- ...

  4. qml实现窗口拖动

    在去掉窗口标题栏后窗口会失去鼠标拖动效果,所以需要自己添加拖动效果. 实现代码: ApplicationWindow {     id: mainWindow     visible: true    ...

  5. sublime text2之js压缩-Js Minifier

    一款基于Google Closure compiler压缩Js文件插件. 快捷键: Ctrl+Alt+M            当前文件内压缩Js代码(不推荐) Ctrl+Alt+Shift+M   ...

  6. [大牛翻译系列]Hadoop系列性能部分完结

    Hadoop系列性能部分完结.其它的部分发布时间待定. Hadoop系列将不再一日一篇,开始不定期发布.

  7. C# 学习之旅(1)

    第一, 输入输出流都来自控制台. using System; using System.Collections.Generic; using System.Linq; using System.Tex ...

  8. 三类,23种设计模式,速记理解法!PHP

    一,创建型设计模式 1.FACTORY—追MM少不了请吃饭了,麦当劳的鸡翅和肯德基的鸡翅都是MM爱吃的东西,虽然口味有所不同,但不管你带MM去麦当劳或肯德基,只管向服务员说“来四个鸡翅”就行了.麦当劳 ...

  9. svn团队环境

    1.安装VisualSVN Server VisualSVN-Server-3.3.1-x64.msi 下载,并安装标准版(免费) 2.下载TortoiseSVN TortoiseSVN-1.8.11 ...

  10. [摘] SQLPLUS Syntax

    You use the SQLPLUS command at the operating system prompt to start command-line SQL*Plus: SQLPLUS [ ...