우리 님이 쓰신 글 :
: C 에도 C++처럼 FileExist()같이 파일 존재만 간단하게 알아낼수 있는 함수가 있나요?
io.h 헤더 파일에 보면 access 함수가 있습니다.
아래는 도움말 내용입니다.
Header File
io.h
Category
Input/output Routines
Prototype
int access(const char *filename, int amode);
int _waccess(const wchar_t *filename, int amode);
Description
Determines accessibility of a file.
access checks the file named by filename to determine if it exists, and whether it can be read, written to, or executed.
The list of amode values is as follows:
06 Check for read and write permission
04 Check for read permission
02 Check for write permission
01 Execute (ignored)
00 Check for existence of file
All existing files have read access (amode equals 04), so 00 and 04 give the same result. Similarly, amode values of 06 and 02 are equivalent because under Win32 write access implies read access.
If filename refers to a directory, access simply determines whether the directory exists.
Return Value
If the requested access is allowed, access returns 0; otherwise, it returns a value of -1, and the global variable errno is set to one of the following values:
ENOENT Path or file name not found
EACCES Permission denied
|