static int file_check(URLContext *h, int mask) { int ret = 0; const char *filename = h->filename; av_strstart(filename, "file:", &filename); { #if HAVE_ACCESS && defined(R_OK) if (access(filename, F_OK) < 0) return AVERROR(errno); if (mask&AVIO_FLAG_READ) if (access(filename, R_OK) >= 0) ret |= AVIO_FLAG_READ; if (mask&AVIO_FLAG_WRITE) if (access(filename, W_OK) >= 0) ret |= AVIO_FLAG_WRITE; #else struct stat st; # ifndef _WIN32 ret = stat(filename, &st); # else ret = win32_stat(filename, &st); # endif if (ret < 0) return AVERROR(errno); ret |= st.st_mode&S_IRUSR ? mask&AVIO_FLAG_READ : 0; ret |= st.st_mode&S_IWUSR ? mask&AVIO_FLAG_WRITE : 0; #endif } return ret; }
/* ** Fill stat buf with information received from stat() or lstat(). ** lstat() is called on Unix if isWd is TRUE and allow-symlinks setting is on. ** */ static int fossil_stat(const char *zFilename, struct fossilStat *buf, int isWd){ int rc; void *zMbcs = fossil_utf8_to_filename(zFilename); #if !defined(_WIN32) if( isWd && g.allowSymlinks ){ rc = lstat(zMbcs, buf); }else{ rc = stat(zMbcs, buf); } #else rc = win32_stat(zMbcs, buf, isWd); #endif fossil_filename_free(zMbcs); return rc; }