复制代码 代码如下:

#include<direct.h>
int _mkdir( const char *dirname );
登录后复制

参数:

dirname是目录的路径名指针

返回值:

如果新目录的创建时间,这些功能中的每一个返回值 0。 在错误,则函数返回 – 1

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权限,代表其他用户拥有执行的权限

下面再给大家详细介绍下linux中mkdir函数详解

mkdir函数

头文件库:

#include <sys/stat.h>
#include <sys/types.h>

函数原型:

int mkdir(const char *pathname, mode_t mode);

函数说明:

mkdir()函数以mode方式创建一个以参数pathname命名的目录,mode定义新创建目录的权限。

返回值:

若目录创建成功,则返回0;否则返回-1,并将错误记录到全局变量errno中。

mode方式:

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权限,代表其他用户拥有执行的权限

以上就是mkdir函数在Linux中与Windows中的区别是什么的详细内容,更多请关注Work网其它相关文章!

09-18 07:45