【转载】C int access(const char *path, int amode); 判断文件是否存在
来源:互联网 发布:卧铺为什么要换票 知乎 编辑:程序博客网 时间:2024/06/06 18:05
break;
from:
http://www.opengroup.org/onlinepubs/000095399/functions/access.html
NAME
access - determine accessibility of a file
SYNOPSIS
#include <unistd.h>
int access(const char *path, int amode);
DESCRIPTION
The access() function shall check the file named by the pathname pointed to by the path argument for accessibility according to the bit pattern contained in amode, using the real user ID in place of the effective user ID and the real group ID in place of the effective group ID.
The value of amode is either the bitwise-inclusive OR of the access permissions to be checked (R_OK, W_OK, X_OK) or the existence test (F_OK).
If any access permissions are checked, each shall be checked individually, as described in the Base Definitions volume of IEEE Std 1003.1-2001, Chapter 3, Definitions. If the process has appropriate privileges, an implementation may indicate success for X_OK even if none of the execute file permission bits are set.
RETURN VALUE
If the requested access is permitted, access() succeeds and shall return 0; otherwise, -1 shall be returned and errno shall be set to indicate the error.
ERRORS
The access() function shall fail if:
- [EACCES]
- Permission bits of the file mode do not permit the requested access, or search permission is denied on a component of the path prefix.
- [ELOOP]
- A loop exists in symbolic links encountered during resolution of the path argument.
- [ENAMETOOLONG]
- The length of the path argument exceeds {PATH_MAX} or a pathname component is longer than {NAME_MAX}.
- [ENOENT]
- A component of path does not name an existing file or path is an empty string.
- [ENOTDIR]
- A component of the path prefix is not a directory.
- [EROFS]
- Write access is requested for a file on a read-only file system.
The access() function may fail if:
- [EINVAL]
- The value of the amode argument is invalid.
- [ELOOP]
- More than {SYMLOOP_MAX} symbolic links were encountered during resolution of the path argument.
- [ENAMETOOLONG]
- As a result of encountering a symbolic link in resolution of the path argument, the length of the substituted pathname string exceeded {PATH_MAX}.
- [ETXTBSY]
- Write access is requested for a pure procedure (shared text) file that is being executed.
- 【转载】C int access(const char *path, int amode); 判断文件是否存在
- char * strchr (const char *str, int c);
- int const * 、const int *、int *const、const char **与char **
- access:判断文件是否存在
- strrchr(const char * s,int c)
- int atoi(const char*)
- char*const*(*next)(int)
- Linux int lstat(const char *path, struct stat *buf);
- C++(五) access函数判断文件是否存在
- C中判断文件是否存在的access函数
- int _access( const char * _Filename, int _AccessMode)
- C++ access函数判断文件是否存在
- access函数判断文件是否存在
- pathconf(char *path, int name)
- int atoi(const char * str)
- int printf(const char* fmt,...)
- int strlen(const char *str)
- int printf(const char* fmt,...)
- 结构体 自引用
- define # 和##
- windows 下打下通过对话框选择文件的三种方法
- Direct3d纹理
- git新手使用指南
- 【转载】C int access(const char *path, int amode); 判断文件是否存在
- (转)开源3D引擎介绍 .
- 好的学习网址
- 【转】给程序员介绍一些C++开源库
- 【转】几个ARX取CAD窗口句柄的函数
- 在visual studio下防止代码污染
- Ogre手动编译
- tlb、tlh和tli文件的关系
- 自己动手实现图的BFS和DFS(附完整源码)转