//Author : cppgp
//Email?? : cppgp@163.com
//Time??? : 2007 03 30
//按照字母順序排列
1 . int _access( const char *path, int mode );
功?? 能 : 測(cè)定文件/目錄存取權(quán)限.
頭文件 : #include <io.h>
參?? 數(shù) : path:文件或者目錄
?? mode:權(quán)限設(shè)定,其值如下:
?? 00 Existence only
?? 02 Write permission
?? 04 Read permission
?? 06 Read and write permission
返回值 : 擁有該權(quán)限返回0
?? 沒(méi)有權(quán)限返回-1,且設(shè)置errno為如下值
?? ENOENT 路徑/文件不存在
?? EACCES 沒(méi)有相應(yīng)權(quán)限
2 . int _chdir( const char *dirname );
功?? 能 : 更改當(dāng)前工作目錄.
頭文件 : #include <direct.h>
返回值 : 成功返回0
?? 失敗返回-1,且設(shè)置errno如下:
?? ENOENT 該路徑不存在
3 . int _chdrive( int drive );
功?? 能 : 更改當(dāng)前工作驅(qū)動(dòng)器.
頭文件 : #include <direct.h>
返回值 : 成功返回0
?? 失敗返回-1
注?? 釋 : 參數(shù)說(shuō)明
???? drive =1<==> A盤
???? drive =2<==> B盤
???? drive =3<==> C盤
?? 如此等等,該函數(shù)可以由_chdir代替
4 . int _findclose( long handle );
功?? 能 : 關(guān)閉搜尋句柄并釋放相應(yīng)資源
頭文件 : #include <io.h>
參?? 數(shù) : long handle 搜索句柄(通常由緊靠其前的_findfirst()返回,_findfirst()見(jiàn)下)
?? fileinfo 文件信息buffer
返回值 : 成功返回0
?? 出錯(cuò)返回-1,且設(shè)置errno為如下值
?? ENOENT 沒(méi)有更多的符合該泛式的文件
5 . long _findfirst( char *filespec, struct _finddata_t *fileinfo );
功?? 能 : 提供與filespec指定入口泛式匹配的第一個(gè)文件.通常后繼用_findnext函數(shù)后續(xù)使用來(lái)完成某泛式下的文件遍歷.
頭文件 : #include <io.h>
參?? 數(shù) : filespec 目標(biāo)文件規(guī)范,可以包含通配符
?? fileinfo 文件信息buffer
返回值 : 成功返回唯一的搜索句柄
?? 出錯(cuò)返回-1,且設(shè)置errno為如下值
?? ENOENT 該泛式無(wú)法匹配
?? EINVAL 無(wú)效文件名
6 . int _findnext( long handle, struct _finddata_t *fileinfo );
功?? 能 : 按照前面_findfirst中的泛式規(guī)則,查找下一個(gè)符合該泛式的文件,并以 此為依據(jù)修改fileinfo中的值
頭文件 : #include <io.h>
參?? 數(shù) : long handle 搜索句柄(通常由緊靠其前的_findfirst()返回)
?? fileinfo 文件信息buffer
返回值 : 成功返回0
?? 出錯(cuò)返回-1,且設(shè)置errno為如下值
?? ENOENT 沒(méi)有更多的符合該泛式的文件
7 . char *_getcwd( char *buffer, int maxlen );
功?? 能 : 獲得當(dāng)前工作目錄.
頭文件 : #include <direct.h>
返回值 : 成功返回指向buffer的pointer
?? 失敗返回NULL,且設(shè)置errno為以下三個(gè)值之一:
?? ENODEV 無(wú)該設(shè)備
?? ENOMEM 內(nèi)存不夠
?? ERANGE 結(jié)果超出范圍
注?? 意 : 當(dāng)?shù)谝粋€(gè)參數(shù)為 NULL 時(shí),第二個(gè)參數(shù) maxlen 長(zhǎng)度設(shè)置無(wú)效,且函數(shù)使用malloc分配足夠內(nèi)存,需要將函數(shù)返回值傳遞給free()函數(shù)來(lái)釋放內(nèi)存.
?? 當(dāng)?shù)谝粋€(gè)參數(shù)不為 NULL 時(shí),maxlen 指定長(zhǎng)度不夠函數(shù)返回錯(cuò),設(shè)置errno為ERANGE
8 . char *_getdcwd( int drive, char *buffer, int maxlen );
功?? 能 : 獲得指定驅(qū)動(dòng)器的當(dāng)前工作路徑.
頭文件 : #include <direct.h>
返回值 : 成功返回指向buffer的pointer
?? 失敗返回NULL,且設(shè)置errno為以下三個(gè)值之一:
?? ENODEV 無(wú)該設(shè)備
?? ENOMEM 內(nèi)存不夠
?? ERANGE 結(jié)果超出范圍
注?? 意 : 當(dāng)?shù)谝粋€(gè)參數(shù)為 NULL 時(shí),該函數(shù)設(shè)置errno為ERANGE
9 . int _getdrive( void );
功?? 能 : 獲得當(dāng)前磁盤驅(qū)動(dòng)器.
頭文件 : #include <direct.h>
返回值 : 返回驅(qū)動(dòng)器值,1<==>A 2<==>B 如此等等;函數(shù)不會(huì)出錯(cuò)!
10 . unsigned long _getdrives(void);
功?? 能 : 獲得當(dāng)前所有驅(qū)動(dòng)器.
頭文件 : #include <direct.h>
返回值 : 各個(gè)位代表對(duì)應(yīng)驅(qū)動(dòng)器,
?? bit 0 <==> A
?? bit 1 <==> B
?? bit 2 <==> C
?? ... ...
注:bit x 表示unsigned long的第x位
11 . int _mkdir( const char *dirname );
功?? 能 : 創(chuàng)建一個(gè)新目錄,目錄名為dirname.
頭文件 : #include <direct.h>
返回值 : 成功返回0
?? 失敗返回-1,且設(shè)置errno為以下三個(gè)值之一
?? EACCESS 權(quán)限不允許
?? EEXIST?? 該目錄已存在
?? ENOENT?? 無(wú)該文件或目錄
12 . int _rmdir( const char *dirname );
功?? 能 : 刪除名為dirname的目錄.
頭文件 : #include <direct.h>
返回值 : 成功返回0
?? 失敗返回-1,且設(shè)置errno為以下三個(gè)值之一
?? EACCESS??? 權(quán)限不允許
?? ENOTEMPTY dirname不是文件夾;
????? 或者該文件夾不空;
????? 或者dirname為當(dāng)前工作文件夾;
????? 或者dirname為當(dāng)根文件夾;
?? ENOENT???? 無(wú)該文件或目錄
//--end--
//如有錯(cuò)誤,希望指出!
//聯(lián)系 : cppgp@163.com