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. Django开篇 - Web应用

    一 Web应用的组成 接下来我们学习的目的是为了开发一个Web应用程序,而Web应用程序是基于B/S架构的,其中B指的是浏览器,负责向S端发送请求信息,而S端会根据接收到的请求信息返回相应的数据给浏览 ...

  2. 机器学习实战基础(二十三):sklearn中的降维算法PCA和SVD(四) PCA与SVD 之 PCA中的SVD

    PCA中的SVD 1 PCA中的SVD哪里来? 细心的小伙伴可能注意到了,svd_solver是奇异值分解器的意思,为什么PCA算法下面会有有关奇异值分解的参数?不是两种算法么?我们之前曾经提到过,P ...

  3. Python面试【315+道题】

    第一部分 Python基础篇(80题) 为什么学习Python? 通过什么途径学习的Python? Python和Java.PHP.C.C#.C++等其他语言的对比? 简述解释型和编译型编程语言? P ...

  4. OSCP Learning Notes - WebApp Exploitation(1)

    Installing XSS&MySQL FILE Download the Pentester Lab: XSS and MySQL FILE from the following webs ...

  5. RabbitMQ 入门之基础概念

    什么是消息队列(MQ) 消息是在不同应用间传递的数据.这里的消息可以非常简单,比如只包含字符串,也可以非常复杂,包含多个嵌套的对象.消息队列(Message Queue)简单来说就是一种应用程序间的通 ...

  6. 波士顿动力狗 SPOT 权威购买指北

    两周前 油管科技视频播主 Lew Later 发布了一支 波士顿动力狗子的开箱视频,短短两周的时间内这支视频的播放量就达到了367万, 在Lew Later 近期发布的视频中,这支视频的播放量绝对算得 ...

  7. GitHub和码云gitee及远程仓库管理

    目录 备注: 知识点 GitHub 码云(gitee.com) gitee的使用 本地版本库关联多个远程库 备注: 本文参考于廖雪峰老师的博客Git教程.依照其博客进行学习和记录,感谢其无私分享,也欢 ...

  8. wpf中实现快捷键

    <Window.InputBindings> <KeyBinding Gesture="Ctrl+Alt+Q" Command="{Binding Yo ...

  9. django 学习记录(一)

    不使用 drf 来实现django 的 api 接口 json序列化 from django.shortcuts import render from django.views.generic.bas ...

  10. js 绑定的键盘事件

    在全局绑定键盘事件 document.onkeydown = function(event){        //在全局中绑定按下事件 var e  = event  ||  window.e; va ...