summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2014-10-26 14:34:46 +0100
committerwm4 <wm4@nowhere>2014-10-26 14:34:46 +0100
commit078f5f300dc776dd78608fb5c0048cb77e92e6cf (patch)
treeaa63ed8d4a01b4ca7962704ceba8e61579231ec0
parentdd91c09a710ca9caa103732878825c6ecbd97a65 (diff)
downloadmpv-078f5f300dc776dd78608fb5c0048cb77e92e6cf.tar.bz2
mpv-078f5f300dc776dd78608fb5c0048cb77e92e6cf.tar.xz
TOOLS/lua/autoload: fix operation outside of working dir
Fixes #1222. (This commit is based on a patch posted there.)
-rw-r--r--TOOLS/lua/autoload.lua10
1 files 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