关于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时使用 ...
随机推荐
- Ubuntu systemctl 查看管理系统启动项
Ubuntu systemctl 查看系统启动项 列出所有启动项: sudo systemctl list-unit-files 会列出开启的和未开启的: 使用grep过滤一下开启的grep enab ...
- SQL字符串拼接FOR XML PATH
在工作中难免会遇到数据库中数据要进行拼接的问题,字符串拼接可以是用SQL的拼接也可以使用C#的拼接,本次说的是使用SQL进行拼接. 首先插入测试语句: --测试语句,准备创建表的语句:如下 CREAT ...
- EM算法的收敛性
https://blog.csdn.net/kevinoop/article/details/80522477
- 数据可视化之分析篇(一)使用Power BI进行动态帕累托分析
https://zhuanlan.zhihu.com/p/57763423 通过简单的点击交互,就能进行动态分析发现见解,才是我们需要的,恰好这也是 PowerBI 所擅长的. 就帕累托分析来说,能从 ...
- Windows故障转移群集(WSFC)的备份和恢复
使用wbadmin进行备份和恢复将C盘数据备份到E盘查看备份的版本以及包含的items模拟群集角色被误删除进行恢复操作检查恢复的效果 WSFC群集的备份和恢复功能是使用Windows Server B ...
- js 声明变量规范和特殊变量情况
声明变量特殊情况 情况 说明 结果 var age ; console.log (name); 只声明 不赋值 undefined console.log(name) 不声明 不赋值 直接使用 ...
- bzoj2132圈地计划
bzoj2132圈地计划 题意: 一块土地可以纵横划分为N×M块小区域.于第i行第j列的区域,建造商业区将得到Aij收益,建造工业区将得到Bij收益.而如果区域(i,j)相邻(相邻是指两个格子有公共边 ...
- 集训作业 洛谷P1443 马的遍历
这个题是个搜索,而且有是最少的步数,肯定就是广搜啦,不知道为什么的同学先去学习一下广搜吧. 养成好习惯,看见最少步数就去想想广搜(只是我自己觉得) 竟然这个题可以如此顺畅的想到广搜,感觉不难啊,但还有 ...
- Windows搭建Redis集群-详细教程
一.集群知识 1.集群的概念 所谓的集群,就是通过添加服务器的数量,提供相同的服务,从而让服务器达到一个稳定.高效的状态. 2.使用redis集群的必要性 问题:我们已经部署好了redis,并且能启动 ...
- 2020年20个Flutter最漂亮的UI库和项目
Best-Flutter-UI-Templates 地址:https://github.com/mitesh77/Best-Flutter-UI-Templates The History of Ev ...