summaryrefslogtreecommitdiffstats
path: root/libmenu
diff options
context:
space:
mode:
authorulion <ulion@b3059339-0415-0410-9bf9-f77b7e298cf2>2007-12-31 01:20:50 +0000
committerulion <ulion@b3059339-0415-0410-9bf9-f77b7e298cf2>2007-12-31 01:20:50 +0000
commit61f55e9fd799466bf3fd8e3e28d920b570bed4f0 (patch)
tree9ec581d82e7f5738518a0e489a7251abcb4b6eee /libmenu
parentc98db3f44225a043f6b96079f5143ecf57320f82 (diff)
downloadmpv-61f55e9fd799466bf3fd8e3e28d920b570bed4f0.tar.bz2
mpv-61f55e9fd799466bf3fd8e3e28d920b570bed4f0.tar.xz
Default use the dir where the current playing file located if path not set.
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@25556 b3059339-0415-0410-9bf9-f77b7e298cf2
Diffstat (limited to 'libmenu')
-rw-r--r--libmenu/menu_filesel.c18
1 files changed, 16 insertions, 2 deletions
diff --git a/libmenu/menu_filesel.c b/libmenu/menu_filesel.c
index 2a66b5d12b..ba8ceae550 100644
--- a/libmenu/menu_filesel.c
+++ b/libmenu/menu_filesel.c
@@ -31,6 +31,7 @@
int menu_keepdir = 0;
char *menu_chroot = NULL;
+extern char *filename;
struct list_entry_s {
struct list_entry p;
@@ -425,8 +426,21 @@ static int open_fs(menu_t* menu, char* args) {
}
getcwd(wd,PATH_MAX);
- if (!path || path[0] == '\0')
- path = wd;
+ if (!path || path[0] == '\0') {
+ char *slash = NULL;
+ if (filename && !strstr(filename, "://") && (path=realpath(filename, b))) {
+ slash = strrchr(path, '/');
+#if defined(__MINGW32__) || defined(__CYGWIN__)
+ // FIXME: Do we need and can convert all '\\' in path to '/' on win32?
+ if (!slash)
+ slash = strrchr(path, '\\');
+#endif
+ }
+ if (slash)
+ slash[1] = '\0';
+ else
+ path = wd;
+ }
if (path[0] != '/') {
if(path[strlen(path)-1] != '/')
snprintf(b,sizeof(b),"%s/%s/",wd,path);