文件IO:
? ? 1. lseek
? ? ? ?off_t lseek(int fd, off_t offset, int whence);
? ? ? ?功能:
? ? ? ? ? ? 重新設(shè)定文件描述符的偏移量
? ? ? ?參數(shù):
? ? ? ? ? ? fd:文件描述符
? ? ? ? ? ? offset:偏移量
? ? ? ? ? ? whence:
? ? ? ? ? ? ? ? SEEK_SET ? ?文件開頭
? ? ? ? ? ? ? ? SEEK_CUR ? ?文件當(dāng)前位置
? ? ? ? ? ? ? ? SEEK_END ? ?文件末尾
? ? ? ?返回值:
? ? ? ? ? ? 成功返回當(dāng)前偏移量
? ? ? ? ? ? 失敗返回-1?
目錄IO:
? ? 1.mkdir?
? ? ? int mkdir(const char *pathname, mode_t mode);
? ? ? 功能:
? ? ? ? 創(chuàng)建目錄文件
? ? ? 參數(shù):
? ? ? ? pathname:文件路徑
? ? ? ? mode:文件的權(quán)限
? ? ? 返回值:
? ? ? ? 成功返回0?
? ? ? ? 失敗返回-1?
? ? ? ? rwx rwx rwx
? ? ? ? 111 111 111
? ? ? ? 0777
? ? ? ? r: 目錄中是否能夠查看文件
? ? ? ? w: 目錄中是否能夠新建文件
? ? ? ? x: 目錄是否能夠進(jìn)入
? ??
? ? 2.rmdir
? ? ? int rmdir(const char *pathname);
? ? ? 功能:
? ? ? ? 刪除空目錄文件
? ? ? 返回值:
? ? ? ? 成功返回0?
? ? ? ? 失敗返回-1?
? ? 3.opendir
? ? ? DIR *opendir(const char *name);
? ? ? 功能:
? ? ? ? 打開目錄獲得目錄流指針
? ? ? 參數(shù):
? ? ? ? name:目錄文件路徑
? ? ? 返回值:
? ? ? ? 成功返回目錄流指針
? ? ? ? 失敗返回NULL
? ? ??
? ? 4.closedir
? ? ? int closedir(DIR *dirp);
? ? ? 功能:
? ? ? ? 關(guān)閉目錄流指針
? ? 5.readdir
? ? ? struct dirent *readdir(DIR *dirp);
? ? ? 功能:
? ? ? ? 從目錄流中讀取下一個(gè)目錄項(xiàng)的結(jié)構(gòu)體信息
? ? ? 參數(shù):
? ? ? ? dirp:目錄流指針
? ? ? 返回值:
? ? ? ? 成功返回包含目錄項(xiàng)信息的空間首地址
? ? ? ? 失敗返回NULL
? ? ? ? 讀到文件末尾返回NULL
? ? ? ? struct dirent {
? ? ? ? ? ? ino_t ? ? ? ? ?d_ino; ? ? ? /* Inode number */
? ? ? ? ? ? off_t ? ? ? ? ?d_off; ? ? ? /* Not an offset; see below */
? ? ? ? ? ? unsigned short d_reclen; ? ?/* Length of this record */
? ? ? ? ? ? unsigned char ?d_type; ? ? ?/* Type of file; not supported
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? by all filesystem types */
? ? ? ? ? ? char ? ? ? ? ? d_name[256]; /* Null-terminated filename */
? ? ? ? };
? ? 6.chdir?
? ? ? int chdir(const char *path);
? ? ? 功能:
? ? ? ? 切換當(dāng)前代碼的工作路徑
? ? 7.getcwd
? ? ? char *getcwd(char *buf, size_t size);
? ? ? 功能:
? ? ? ? 獲得當(dāng)前目錄的絕對(duì)路徑文章來源:http://www.zghlxwxcb.cn/news/detail-832837.html
? ?8.access?
? ? ? int access(const char *pathname, int mode);
? ? ? 功能:
? ? ? ? 檢測調(diào)用函數(shù)的程序?qū)ξ募欠駬碛兄付?quán)限
? ? ? 參數(shù):
? ? ? ? pathname:文件路徑
? ? ? ? mode:
? ? ? ? ? ? R_OK? ? ?檢測是否擁有讀權(quán)限
? ? ? ? ? ? W_OK ? ?檢測是否擁有寫權(quán)限
? ? ? ? ? ? X_OK? ? ?檢測是否擁有執(zhí)行權(quán)限
? ? ? ? ? ? F_OK? ? ?檢測文件是否存在
? ? ? 返回值:
? ? ? ? 有該權(quán)限返回0
? ? ? ? 出錯(cuò)返回-1文章來源地址http://www.zghlxwxcb.cn/news/detail-832837.html
到了這里,關(guān)于嵌入式學(xué)習(xí)day22 Linux的文章就介紹完了。如果您還想了解更多內(nèi)容,請(qǐng)?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!