Mercurial > mplayer.hg
changeset 25528:e3f6092fb640
Default use the dir where the current playing file located if path not set.
author | ulion |
---|---|
date | Mon, 31 Dec 2007 01:20:50 +0000 |
parents | 8911d4b81d78 |
children | 867ee1c2114b |
files | libmenu/menu_filesel.c |
diffstat | 1 files changed, 16 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/libmenu/menu_filesel.c Sun Dec 30 22:40:24 2007 +0000 +++ b/libmenu/menu_filesel.c Mon Dec 31 01:20:50 2007 +0000 @@ -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 @@ } 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);