diff options
author | wm4 <wm4@nowhere> | 2013-09-04 14:04:35 +0200 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2013-09-04 16:15:08 +0200 |
commit | efc5ac17bf0a563cc4200252e8d4718731dc9fde (patch) | |
tree | 86eeedc8abf1170b2c91abda2df632a0458e8eb6 /mpvcore/path.c | |
parent | dbff29c81d3127d69e97abcf7001f4b798898a81 (diff) | |
download | mpv-efc5ac17bf0a563cc4200252e8d4718731dc9fde.tar.bz2 mpv-efc5ac17bf0a563cc4200252e8d4718731dc9fde.tar.xz |
path: add a common mp_is_url() function
Remove the duplicated code.
Diffstat (limited to 'mpvcore/path.c')
-rw-r--r-- | mpvcore/path.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/mpvcore/path.c b/mpvcore/path.c index 5d9b7841a4..5893284b5e 100644 --- a/mpvcore/path.c +++ b/mpvcore/path.c @@ -227,3 +227,11 @@ bool mp_path_isdir(const char *path) struct stat st; return mp_stat(path, &st) == 0 && S_ISDIR(st.st_mode); } + +// Return false if it's considered a normal local filesystem path. +bool mp_is_url(bstr path) +{ + // The URL check is a bit murky, but "/path" and "./path" are never URLs. + return path.len && path.start[0] != '/' && path.start[0] != '.' && + bstr_find0(path, "://") >= 0; +} |