关于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时使用 ...
随机推荐
- 解决android studio 文本乱码问题
下面图片,部分字体,有一些中文字符无法显示,可选择提交保存,立即可看到效果,不喜欢就再换一个合适的字体.
- Set 和 Map
1. 数组去重 <script type="text/javascript"> [...new Set(array)] </script> 2. 条件语句的 ...
- java 面向对象(十八):包装类的使用
1.为什么要有包装类(或封装类)为了使基本数据类型的变量具有类的特征,引入包装类. 2.基本数据类型与对应的包装类: 3.需要掌握的类型间的转换:(基本数据类型.包装类.String) 简易版:基本数 ...
- Active Directory - Creating users via PowerShell
Method1: Create a user by executing the following PowerShell Script. New-ADUser -name 'Michael Jorda ...
- idea 自动生成try/catch代码块的快捷键
好像每个人的快捷键可能不同:我的是 Alt+Shift+Z 网上查的是 Ctrl+Alt+T 如果都不是可以点选工具栏生成try/catch(并可查看到自己的快捷键是什么):Code->Su ...
- 高效C++:模板和泛型编程
模板和泛型编程的关注重点在编译期,所有的行为都在编译期确定,因此其规则和玩法也有自己特殊的一套,和其他模块不通用. 了解隐式接口和编译期多态 元编程------编译器多态,决定哪个重载函数被调用 cl ...
- 设计模式:Iterator模式
目的:将数据的存储和数据的查询分开,降低数据的耦合性 继承关系图: 例子: //定义迭代器接口 template<typename T> class Iterator { public: ...
- 支持向量机SMO算法实现(注释详细)
一:SVM算法 (一)见西瓜书及笔记 (二)统计学习方法及笔记 (三)推文https://zhuanlan.zhihu.com/p/34924821 (四)推文 支持向量机原理(一) 线性支持向量机 ...
- R常用统计 - 相关关系分析
数据格式 每行分别为表型和基因表达情况对应标量,每列分别为样品名的矩阵.假定前9列为phenotype,从第10行起为gene_id,编写简单for循环如下: script require(" ...
- apache 基本配置
1.1 ServerRoot 配置 [ServerRoot "" 主要用于指定Apache的安装路径,此选项参数值在安装Apache时系统会自动把Apache的路径写入.Windo ...