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