static int
_is_file_exist(const char *filename)
{
- int ret = 1;
+ int ret = FILEINFO_ERROR_NONE;
if (filename) {
const char *to_access = (strstr(filename, "file://") != NULL) ? filename + 7 : filename;
ret = access(to_access, R_OK);
- if (ret != 0) {
- debug_error(DEBUG, "file [%s] not found.\n", to_access);
+ if (ret < 0) {
+ if (errno == EACCES || errno == EPERM) {
+ debug_error(DEBUG, "Permission denied [%s]", to_access);
+ ret = FILEINFO_ERROR_PERMISSION_DENIED;
+ } else {
+ debug_error(DEBUG, "Not exist file [%s]", to_access);
+ ret = FILEINFO_ERROR_FILE_NOT_FOUND;
+ }
}
}
- return !ret;
+ return ret;
}
static int
MM_FILE_SET_MEDIA_FILE_SRC(src, filename);
ret = _is_file_exist(filename);
- if (!ret) {
- ret = FILEINFO_ERROR_FILE_NOT_FOUND;
+ if (ret != FILEINFO_ERROR_NONE) {
goto END;
}
MM_FILE_SET_MEDIA_FILE_SRC(src, filename);
ret = _is_file_exist(filename);
- if (!ret) {
- ret = FILEINFO_ERROR_FILE_NOT_FOUND;
+ if (ret != FILEINFO_ERROR_NONE) {
goto END;
}
MM_FILE_SET_MEDIA_FILE_SRC(src, filename);
ret = _is_file_exist(filename);
- if (!ret) {
- ret = FILEINFO_ERROR_FILE_NOT_FOUND;
+ if (ret != FILEINFO_ERROR_NONE) {
goto END;
}
MM_FILE_SET_MEDIA_FILE_SRC(src, filename);
ret = _is_file_exist(filename);
- if (!ret) {
- ret = FILEINFO_ERROR_FILE_NOT_FOUND;
+ if (ret != FILEINFO_ERROR_NONE) {
goto END;
}
MM_FILE_SET_MEDIA_FILE_SRC(src, filename);
ret = _is_file_exist(filename);
- if (!ret) {
- ret = FILEINFO_ERROR_FILE_NOT_FOUND;
+ if (ret != FILEINFO_ERROR_NONE) {
goto END;
}
MM_FILE_SET_MEDIA_FILE_SRC(src, filename);
ret = _is_file_exist(filename);
- if (!ret) {
- ret = FILEINFO_ERROR_FILE_NOT_FOUND;
+ if (ret != FILEINFO_ERROR_NONE) {
goto END;
}