ifstream :: open()은 void를 반환하며 파일이 사용 권한으로 인해 열리지 않았는지 확인할 방법이 없습니다. C++에서 현재 프로세스의 파일에 대해 읽기 권한이나 쓰기 권한을 사용할 수 있는지 테스트하는 좋은 API는 무엇입니까? 내가 인식하지 오전파일에 필요한 사용 권한이 있는지 여부를 테스트하는 좋은 방법은 무엇입니까?
struct stat {
dev_t st_dev; /* ID of device containing file */
ino_t st_ino; /* inode number */
mode_t st_mode; /* protection */
nlink_t st_nlink; /* number of hard links */
uid_t st_uid; /* user ID of owner */
gid_t st_gid; /* group ID of owner */
dev_t st_rdev; /* device ID (if special file) */
off_t st_size; /* total size, in bytes */
blksize_t st_blksize; /* blocksize for file system I/O */
blkcnt_t st_blocks; /* number of 512B blocks allocated */
time_t st_atime; /* time of last access */
time_t st_mtime; /* time of last modification */
time_t st_ctime; /* time of last status change */
};
:
I/O는 OS에 따라 다르며, OS에 대해 알려 주시면보다 구체적인 답변을 드릴 수 있습니다. –
가능한 중복 : http://stackoverflow.com/questions/1138508/in-c-on-unix-how-can-a-process-tell-what-permissions-it-has-to-a-file-without- op –
이것은 Linux 용입니다. – WilliamKF