当前位置: 技术问答>linux和unix
在linux中利用C++实现新建目录的功能
来源: 互联网 发布时间:2016-09-05
本文导语: 如题: 请问如何实现: 能不使用shell命令去调用linux的新建目录命令来进行实现吗? | $ man 2 mkdir NAME mkdir - create a directory SYNOPSIS #include #include int mkdir(const char *pathname, mode_t mo...
如题:
请问如何实现:
能不使用shell命令去调用linux的新建目录命令来进行实现吗?
请问如何实现:
能不使用shell命令去调用linux的新建目录命令来进行实现吗?
|
$ man 2 mkdir
NAME
mkdir - create a directory
SYNOPSIS
#include
#include
int mkdir(const char *pathname, mode_t mode);
DESCRIPTION
mkdir attempts to create a directory named pathname.
The parameter mode specifies the permissions to use. It is modified by the process's umask in the usual way: the permissions of the created directory are (mode & ~umask & 0777). Other mode bits of the created directory depend on the operating system. For Linux, see below.
The newly created directory will be owned by the effective uid of the process. If the directory containing the file has the set group id bit set, or if the filesystem is mounted with BSD group semantics, the new directory will inherit the group ownership from its parent; otherwise it will be owned by the effective gid of the process.
If the parent directory has the set group id bit set then so will the newly created directory.
......
NAME
mkdir - create a directory
SYNOPSIS
#include
#include
int mkdir(const char *pathname, mode_t mode);
DESCRIPTION
mkdir attempts to create a directory named pathname.
The parameter mode specifies the permissions to use. It is modified by the process's umask in the usual way: the permissions of the created directory are (mode & ~umask & 0777). Other mode bits of the created directory depend on the operating system. For Linux, see below.
The newly created directory will be owned by the effective uid of the process. If the directory containing the file has the set group id bit set, or if the filesystem is mounted with BSD group semantics, the new directory will inherit the group ownership from its parent; otherwise it will be owned by the effective gid of the process.
If the parent directory has the set group id bit set then so will the newly created directory.
......
|
system("mkdir /tmp/test");
|
能!