Home > php教程 > PHP开发 > The difference between the mkdir function in Linux and the _mkdir function in Windows

The difference between the mkdir function in Linux and the _mkdir function in Windows

高洛峰
Release: 2016-12-21 15:31:59
Original
1643 people have browsed it

Let’s first introduce to you the _mkdir function under Windows

#include<direct.h>
int _mkdir( const char *dirname );
Copy after login

Parameters:

dirname is the pathname pointer of the directory

Return value:

If the creation time of the new directory, each of these functions returns a value of 0. In error, the function returns – 1

Detailed explanation of mode_t parameters of mkdir function under Linux

#include <sys/stat.h>
int mkdir(const char *path, mode_t mode);
Copy after login

Parameters:

path is the directory name

mode is the directory permissions

Return value:

Return 0 for success, return -1 Indicates an error and the errno value will be set.

mode mode bit:

mode represents the permissions of the new directory and can take the following values:

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. 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. 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 permission, which means the file owner has read, write and execute permissions
S_IRUSR(S_IREAD) 00400 permissions, which means the file owner has readable permissions
S_IWUSR(S_IWRITE) 00200 permissions, which means the file owner has writable permissions

S_IXUSR(S_IEXEC) 00100 permissions, which means the file owner has writable permissions Execution permissions

S_IRWXG 00070 permissions, which means that the file user group has the permissions to read, write and execute operations
S_IRGRP 00040 permissions, which means that the file user group has readable permissions
S_IWGRP 00020 permissions, which means that the file user group has the writable permissions
S_IXGRP 00010 permission, which means that the file user group has execution permissions
S_IRWXO 00007 permissions, which means other users have the permissions to read, write and execute operations
S_IROTH 00004 permissions, which means other users have readable permissions
S_IWOTH 00002 permissions , which means other users have writable permissions
S_IXOTH 00001 permission, which means other users have execution permissions

The following will give you a detailed introduction to the mkdir function in Linux

mkdir function

Header file library:

#include < ;sys/stat.h>

#include

Function prototype:


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

Function description:


mkdir() function starts with Mode mode creates a directory named with the parameter pathname, and mode defines the permissions of the newly created directory.

Return value:


If the directory is successfully created, 0 is returned; otherwise -1 is returned, and the error is recorded in the global variable errno.

mode mode:


S_IRWXU 00700 permission, which means that the file owner has the permission to read, write and execute operations

S_IRUSR(S_IREAD) 00400 permission, which means that the file owner has readability

S_IWUSR(S_IWRITE) 00200 Permissions, which means that the file owner has writable permissions

S_IXUSR(S_IEXEC) 00100 permissions, which means that the file owner has execution permissions

S_IRWXG 00070 permissions, which means that the file user group has read, write and execute permissions
S_IRGRP 00040 permissions, which means that the file user group has readable permissions
S_IWGRP 00020 permissions, which means that the file user group has writeable permissions
S_IXGRP 00010 permissions, which means that the file user group has execution permissions
S_IRWXO 00007 permissions, which represents other users Have permissions to read, write and execute operations
S_IROTH 00004 permissions, representing other users with readable permissions
S_IWOTH 00002 permissions, representing other users with writable permissions
S_IXOTH 00001 permissions, representing other users with execution permissions




For more related articles on the difference between the mkdir function in Linux and the _mkdir function in Windows, please pay attention to the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template