关于Linux目录访问函数总结
Linux下目录访问函数总结,主要是涉及到的函数,以及所在头文件。
获得工作目录:
#include <unistd.h>
char *getcwd(char *buf,size_t size);char *getwd(char *buf);/*this is for FreeBSD*/
改变当前目录:
#include <unistd.h>
int chdir(const char *path);
保存当前目录:
#include <unistd.h>
int fchdir(int fd);
建立新目录:
#include <sys/type.h>
#include <sys/stat.h>
int mkdir(const char *path,mode_t mode);
删除目录:
#include <unistd.h>
int rmdir(const char* path);
打开目录进行搜索:
#include <sys/type.h>
#include <dirent.h>
DIR *opendir(const char *pathname); int dirfd(DIR *dirp);
关闭目录:
#include <sys/types.h>
#include <dirent.h> int closedir(DIR *dirp);
搜索目录:
#include <sys/type.h>
#include <dirent.h>
struct dirent *readdir(DIR *dirp);
重新回到目录的开始:
#include <sys/type.h>
#include <dirent.h>
void rewinddir(DIR *dirp);
保存目录中的位置:
#include <sys/type.h>
#include <dirent.h>
long telldir(const DIR *dirp);
在目录内恢复位置:
#include <sys/type.h>
#include <dirent.h>
void seekdir(DIR *dirp,long loc);
扫描目录:
#include <sys/type.h>
#include <dirent.h>
int scandir(const char *diename,struct dirent ***namelist,int (*select)(struct dirent *),int (*compar)(const void *,const viod*));
遍历目录结构:
#include <ftw.h>
int ftw(const char* path,int(*fn)(const char *obj_path,const struct stat *obj_stat,int obj_flags),int depth);
int nftw(const char* path,int(*fn)(const char *obj_path,const struct stat *obj_stat,int obj_flags,struct FTW obj_FTW),int depth,int flags);
改变根目录:
#include <unistd.h>
int chroot(const char *dirname);
关于Linux目录访问函数总结的更多相关文章
- linux查看访问windows共享目录NT_STATUS_DUPLICATE_NAME问题解决
linux查看访问windows共享目录NT_STATUS_DUPLICATE_NAME问题解决 [jason@superfreak ~]$ smbclient //powerhouse-smb.my ...
- 在Linux下访问Windows共享目录的配置方法
在Linux下访问Windows共享目录的配置方法 1.在Windows上设置一个共享目录 如:将d:\RedHat_disk设置为共享目录 2.在Windows上创建一个用户,如tommy,密码11 ...
- 【Linux C中文函数手册】之 目录操作函数
目录操作函数 1)closedir 关闭目录 相关函数: opendir表头文件: #include<sys/types.h> #include<dirent.h>定义函数: ...
- linux系统编程之文件与IO(四):目录访问相关系统调用
1. 目录操作相关的系统调用 1.1 mkdir和rmdir系统调用 1.1.1 实例 1.2 chdir, getcwd系统调用 1.2.1 实例 1.3 o ...
- CentOS Linux SVN服务器 配置用户目录访问 权限 Authorization failed
SVN 修改 aurhz 文件设置用户目录访问权限格式: [/code] user=rw user 用户对code目录拥有读和写的权限. 但是访问 svn://192.168.1.59 的时候却提示A ...
- 详解Linux目录(目录树详细解释)
给大家一篇关于Linux目录 方面的详细说明,好好读一下! Linux目录详解(RHEL5.4) linux有四种基本文件系统类型:--普通文件:如文本文件.c语言源代码.shell脚本等,可以用ca ...
- Linux 目录配置
一.Linux 目录配置标准:FHS FHS(Filessystem Hierarchy Standard) 的重点在于规范每个特定的目录下应该要放置什么样子的数据. FHS依据文件系统使用的频繁与否 ...
- day 2 Linux目录结构
Linux系统的目录结构的基本介绍: 1)在逻辑上的所有目录(包括目录下的子目录)都在最高级别的目录“/”下. 根(/)目录是Linux系统中所有目录的起始点(顶点),根下面的目录及子目录是一个有层次 ...
- 【Linux】Linux 目录结构
博客已转移,请借一步说话 .http://www.weixuehao.com/archives/492 初学Linux,首先需要弄清Linux 标准目录结构 / root --- 启动Linux时使用 ...
随机推荐
- 【RCTF-2015】bug
信息: 题目来源: RCTF-2015 标签:PHP.SQL注入 解题过程 访问网址,提示需要登陆: 使用admin用户名进行注册,提示: 对登陆页面与注册页面进行Fuzz,没有发现注入点. 登陆后页 ...
- Python函数02/函数的动态参数/函数的注释/名称空间/函数的嵌套/global以及nolocal的用法
Python函数02/函数的动态参数/函数的注释/名称空间/函数的嵌套/global以及nolocal的用法 目录 Python函数02/函数的动态参数/函数的注释/名称空间/函数的嵌套/global ...
- vue 仿掘金评论列表
先来个最终效果 代码: template代码: <template> <div class="main"> <div class="titl ...
- 京东秋招提前批初试--java开发工程师
1,自我介绍,学过的课程有哪些 2,介绍一下java的内存结构和内存模型(jvm和jmm) 3,对于NIO有没有了解?作用是什么?(基于通道和缓冲区的I/O方式,用的是DirectByteBuffer ...
- 模板方法模式(c++实现)
外观模式 目录 外观模式 模式定义 模式动机 UML类图 源码实现 优点 缺点 模式定义 模板方法模式(Facade),定义一个操作中的算法的骨架,而将一些步骤延迟到子类中.模板方法使得子类可以不改变 ...
- Babel:下一代Javascript语法编译器
定义 Babel是一个Javascript的编译器,通过它你可以将一些新版本的ECMAScript语法转换成低版本的语法.以便能够在低版本的浏览器或者其它环境平稳运行. 截至目前笔者写这篇文章的时候, ...
- OSCP Learning Notes - Buffer Overflows(1)
Introduction to Buffer Overflows Anatomy of Memory Anatomy of the Stack Fuzzing Tools: Vulnserver - ...
- 一位Google高管审查了20,000+简历,他发现了这5个致命的错误
工作与生活的平衡 下班划水摸鱼时间,我比较喜欢浏览一下各类新闻网页,比如说ins,这不,我就在ins上看到了这样的一篇文章,内容很简单,就是简历,但是就是这样一份简历,却让这位Google高管震惊不已 ...
- element-ui设置级联选择器表单验证
data(){<el-form :model="ruleForm" :rules="rules" ref="ruleForm" lab ...
- 毫不留情地揭开 ArrayList 和 LinkedList 之间的神秘面纱
先看再点赞,给自己一点思考的时间,思考过后请毫不犹豫微信搜索[沉默王二],关注这个靠才华苟且的程序员.本文 GitHub github.com/itwanger 已收录,里面还有技术大佬整理的面试题, ...