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目录访问函数总结的更多相关文章

  1. linux查看访问windows共享目录NT_STATUS_DUPLICATE_NAME问题解决

    linux查看访问windows共享目录NT_STATUS_DUPLICATE_NAME问题解决 [jason@superfreak ~]$ smbclient //powerhouse-smb.my ...

  2. 在Linux下访问Windows共享目录的配置方法

    在Linux下访问Windows共享目录的配置方法 1.在Windows上设置一个共享目录 如:将d:\RedHat_disk设置为共享目录 2.在Windows上创建一个用户,如tommy,密码11 ...

  3. 【Linux C中文函数手册】之 目录操作函数

    目录操作函数 1)closedir 关闭目录 相关函数: opendir表头文件: #include<sys/types.h> #include<dirent.h>定义函数: ...

  4. linux系统编程之文件与IO(四):目录访问相关系统调用

    1. 目录操作相关的系统调用     1.1 mkdir和rmdir系统调用     1.1.1 实例     1.2 chdir, getcwd系统调用     1.2.1 实例     1.3 o ...

  5. CentOS Linux SVN服务器 配置用户目录访问 权限 Authorization failed

    SVN 修改 aurhz 文件设置用户目录访问权限格式: [/code] user=rw user 用户对code目录拥有读和写的权限. 但是访问 svn://192.168.1.59 的时候却提示A ...

  6. 详解Linux目录(目录树详细解释)

    给大家一篇关于Linux目录 方面的详细说明,好好读一下! Linux目录详解(RHEL5.4) linux有四种基本文件系统类型:--普通文件:如文本文件.c语言源代码.shell脚本等,可以用ca ...

  7. Linux 目录配置

    一.Linux 目录配置标准:FHS FHS(Filessystem Hierarchy Standard) 的重点在于规范每个特定的目录下应该要放置什么样子的数据. FHS依据文件系统使用的频繁与否 ...

  8. day 2 Linux目录结构

    Linux系统的目录结构的基本介绍: 1)在逻辑上的所有目录(包括目录下的子目录)都在最高级别的目录“/”下. 根(/)目录是Linux系统中所有目录的起始点(顶点),根下面的目录及子目录是一个有层次 ...

  9. 【Linux】Linux 目录结构

    博客已转移,请借一步说话 .http://www.weixuehao.com/archives/492 初学Linux,首先需要弄清Linux 标准目录结构 / root --- 启动Linux时使用 ...

随机推荐

  1. if-else和三目运算符 ? : 的对比

    今天的地铁思考让我想起一个之前学C语言的时候一直没有验证的事情:既生瑜何生亮? 平时写代码的时候,似乎并没有太多的关注我应该选用什么条件判断语句,感觉判断条件或者两条支路语句复杂就本能地if-else ...

  2. 02 flask源码剖析之flask快速使用

    02 flask快速使用 目录 02 flask快速使用 1.flask与django的区别 2. 安装 3. 依赖wsgi Werkzeug 4. 快速使用flask 5. 用户登录&用户管 ...

  3. bzoj3374[Usaco2004 Mar]Special Serial Numbers 特殊编号*

    bzoj3374[Usaco2004 Mar]Special Serial Numbers 特殊编号 题意: 求比一个数大的最小的一半以上的数位相同的数.数位数≤100. 题解: 模拟题.从低位枚举到 ...

  4. 如何在项目中封装api

    一般在项目中,会有很多的api请求,无论在vue,angular,还是react中都应该把接口封装起来,方便后期的维护. 1.新建一个api文件 我们可以在项目的分目录下创建一个api文件夹,在这里面 ...

  5. OSCP Learning Notes - Exploit(6)

    Antivirus Bypassing Tools: Kali Linux Detection Platform: https://www.virustotal.com/gui/home/upload ...

  6. Ethical Hacking - NETWORK PENETRATION TESTING(15)

    ARP Poisoning - arpspoof Arpspoof is a tool part of a suit called dsniff, which contains a number of ...

  7. .Net微服务实战之负载均衡(上)

    系列文章 .Net微服务实战之技术选型篇 .Net微服务实战之技术架构分层篇 .Net微服务实战之DevOps篇 相关源码:https://github.com/SkyChenSky/Sikiro P ...

  8. SQL语句 查询最新记录

    要求:SQL语句按ID以最新时间查询最新的一条记录 方法1: select * from (select *, ROW_NUMBER() over(partition by id order by u ...

  9. Python基础-异常

    异常捕获 常见异常类型 Exception:顶级异常类,大部分异常类都是它的子类.SyntaxError:语法错误TypeError:类型错误ValueError:值错误NameError:找不到名称 ...

  10. C++语法小记---前置操作符和后置操作符

    前置操作符和后置操作符 单独的"++i"和"i++"是否有区别 对于基本类型: 二者没有区别,因为编译器会对代码进行优化,二者的汇编代码完全相同 对于类类型: ...