summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2013-09-07 20:24:02 +0200
committerwm4 <wm4@nowhere>2013-09-07 20:34:49 +0200
commitfde0f40e873c9539e6554da8288b4912b8e0666c (patch)
tree9334ad4d246a4a2bbd27ad63ee736d2a9b91b87b
parent9d0d2443fb379550924c3e94a16d77c37ed363a1 (diff)
downloadmpv-fde0f40e873c9539e6554da8288b4912b8e0666c.tar.bz2
mpv-fde0f40e873c9539e6554da8288b4912b8e0666c.tar.xz
find_subfiles: use stat() instead of opening the file to check existence
Use mp_path_exists() to check for existence of a file (which in turn uses stat()), instead of opening and closing it. The difference is that if we don't have sufficient permissions to read the subtitle files, we will loudly complain. Personally, I prefer this behavior.
-rw-r--r--sub/find_subfiles.c4
1 files changed, 1 insertions, 3 deletions
diff --git a/sub/find_subfiles.c b/sub/find_subfiles.c
index 46ee3df0a9..2af7dafbd7 100644
--- a/sub/find_subfiles.c
+++ b/sub/find_subfiles.c
@@ -87,7 +87,6 @@ static void append_dir_subtitles(struct MPOpts *opts,
{
char *sub_exts[] = {"utf", "utf8", "utf-8", "idx", "sub", "srt", "smi", "rt", "txt", "ssa", "aqt", "jss", "js", "ass", NULL};
void *tmpmem = talloc_new(NULL);
- FILE *f;
assert(strlen(fname) < 1e6);
if (mp_is_url(bstr0(fname)))
@@ -174,11 +173,10 @@ static void append_dir_subtitles(struct MPOpts *opts,
prio++;
#endif
char *subpath = mp_path_join(*slist, path, dename);
- if ((f = fopen(subpath, "rt"))) {
+ if (mp_path_exists(subpath)) {
MP_GROW_ARRAY(*slist, *nsub);
struct subfn *sub = *slist + (*nsub)++;
- fclose(f);
sub->priority = prio;
sub->fname = subpath;
} else