分类: LINUX
2009-02-19 18:37:51
(1) #include
int stat(const char *restrict pathname, struct stat *restrict buf);
int fstat(int fd, struct stat *buf);
int lstat(const char *restrict pathname, stuct stat *restrict buf);
若成功则返回0,若出错则返回-1
struct stat{
mode_t st_mode;
ino_t st_ino;
dev_t st_dev;
dev_t st_rdev;
nlink_t st_nlink;
uid_t st_uid;
gid_t st_gid;
off_t st_size;
time_t st_atime;
time_t st_mtime;
time_t st_ctime;
blksize_t st_blksize;
blkcnt_t st_blocks;
}
St_mode: S_ISREG、S_ISDIR、S_ISCHR、S_ISBLK、S_ISFIFO、S_ISLNK、S_ISSOCK
S_IRUSR、S_IWUSR、S_IXUSR、
S_IRGRP、S_IWGRP、S_IXGRP、
S_IROTH、S_IWOTH、S_IXOTH、
S_ISUID、S_ISGID、S_ISVTX
(2)#include
int access(const char *pathname, int mode)
若成功则返回0,若出错则返回-1
Mode: R_OK、W_OK、X_OK、F_OK
(3) #include
mode_t umask(mode_t cmask);
返回以前的文件模式创建屏蔽字
(4) #include
int chmod(const char *pathname, mode_t mode);
int fchmod(int fds, mode_t mode);
若成功则返回0,若出错则返回-1
(5)#include
int chown(const char *pathname, uid_t owner, gid_t group);
int fchown(int fds, uid_t owner, gid_t group);
int lchown(const char *pathname, uid_t owner, gid_t group);
若成功则返回0,若出错则返回-1
(6)#include
int truncate(const char *pathname, off_t length);
int ftruncate(int fds, off_t length);
若成功则返回0,若出错则返回-1
(7)#include
int link(const char *existingpath, const char *newpath);
int unlink(const char *pathname);
int remove(const char *pathname);
int rename(const char *oldname, const char *newname);
若成功则返回0,若出错则返回-1
(8)#include
int syslink(const char *actualpath, const char *syspath);
若成功则返回0,若出错则返回-1
ssize_t readlink(const char* restrict pathname, char *restrict buf, size_t bufsize);
若成功则返回读到的字节数,若出错则返回-1
(9) #include
int mkdir(const char *pathname, mode_t mode);
int rmdir(const char *pathname);
若成功则返回0,若出错则返回-1
(10)#include
DIR *opendir(const char *pathname);
若成功则返回指针,若出错则返回NULL
struct dirent *readdir(DIR *dp);
若成功则返回指针,若在目录结尾或出错则返回NULL
void rewinddir(DIR *dp);
int closedir(DIR *dp);
若成功则返回0,若出错则返回-1
long telldir(DIR *dp);
与dp关联的目录中的当前位置
void seekdir(DIR *dp, long loc);
(11)#include
int chdir(const char *pathname);
int fchdir(int fds);
若成功则返回0,若出错则返回-1
char *getcwd(char *buf, size_t size);
若成功则返回buf,若出错则返回NULL