From 078f5f300dc776dd78608fb5c0048cb77e92e6cf Mon Sep 17 00:00:00 2001 From: wm4 Date: Sun, 26 Oct 2014 14:34:46 +0100 Subject: TOOLS/lua/autoload: fix operation outside of working dir Fixes #1222. (This commit is based on a patch posted there.) --- TOOLS/lua/autoload.lua | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/TOOLS/lua/autoload.lua b/TOOLS/lua/autoload.lua index ebea903a18..049af868c0 100644 --- a/TOOLS/lua/autoload.lua +++ b/TOOLS/lua/autoload.lua @@ -26,6 +26,9 @@ function find_and_add_entries() end local files = mputils.readdir(dir, "files") table.sort(files) + if dir == "." then + dir = "" + end local pl = mp.get_property_native("playlist", {}) local pl_current = mp.get_property_number("playlist-pos", 0) + 1 -- Find the current pl entry (dir+"/"+filename) in the sorted dir list @@ -47,20 +50,21 @@ function find_and_add_entries() if file == nil or file[1] == "." then break end + local filepath = dir .. file if pl_e then -- If there's a playlist entry, and it's the same file, stop. - if pl_e.filename == file then + if pl_e.filename == filepath then break end end if direction == -1 then if pl_current == 1 then -- never add additional entries in the middle mp.msg.info("Prepending " .. file) - table.insert(append[-1], 1, file) + table.insert(append[-1], 1, filepath) end else mp.msg.info("Adding " .. file) - table.insert(append[1], file) + table.insert(append[1], filepath) end end end -- cgit v1.2.3