# HG changeset patch # User ulion # Date 1199064050 0 # Node ID e3f6092fb6401fc51dc9956c6977a2a50ac96b06 # Parent 8911d4b81d78a3d74ed178beca2568777c91d4bd Default use the dir where the current playing file located if path not set. diff -r 8911d4b81d78 -r e3f6092fb640 libmenu/menu_filesel.c --- 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);