温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

Linux的mkdir函数与Windows的mkdir函数有什么区别

发布时间:2022-03-23 15:50:45 来源:亿速云 阅读:315 作者:iii 栏目:web开发

这篇文章主要介绍“Linux的mkdir函数与Windows的mkdir函数有什么区别”,在日常操作中,相信很多人在Linux的mkdir函数与Windows的mkdir函数有什么区别问题上存在疑惑,小编查阅了各式资料,整理出简单好用的操作方法,希望对大家解答”Linux的mkdir函数与Windows的mkdir函数有什么区别”的疑惑有所帮助!接下来,请跟着小编一起来学习吧!

下面先来给大家介绍windows下_mkdir函数

复制代码 代码如下:


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

到此,关于“Linux的mkdir函数与Windows的mkdir函数有什么区别”的学习就结束了,希望能够解决大家的疑惑。理论与实践的搭配能更好的帮助大家学习,快去试试吧!若想继续学习更多相关知识,请继续关注亿速云网站,小编会继续努力为大家带来更多实用的文章!

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI