mkdir函數介紹

文章摘自:http://biancheng.dnbcw.info/c/271018.html


int mkdir(char * dir, int mode):目錄創建函數
運用條件:只能在已存在的目錄下建立一級子目錄
返回值:
返回0表示成功,返回-1表述出錯。
頭文件:sys/stat.h
mode 表示新目錄的權限,可以取以下值:

S_IRUSR
S_IREAD
Read permission bit for the owner of the file. On many systems this bit is 0400. S_IREAD is an obsolete synonym provided for BSD compatibility.
//這是對文件用戶的讀權限賦予

S_IWUSR
S_IWRITE
Write permission bit for the owner of the file. Usually 0200. S_IWRITE is an obsolete synonym provided for BSD compatibility.
//這是對文件用戶的寫權限賦予

S_IXUSR
S_IEXEC
Execute (for ordinary files) or search (for directories) permission bit for the owner of the file. Usually 0100. S_IEXEC is an obsolete synonym provided for BSD compatibility.
//這是對文件用戶執行權限賦予

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.
//這下面就不說明了,因爲這又涉及set uid ,set gid,sticky bit這三個權限,後面有一篇轉貼再說明,不過這也只有我這樣的菜鳥不知道的啦.

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.

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章