diff options
author | mitchell <70453897+667e-11@users.noreply.github.com> | 2014-04-10 10:04:49 -0400 |
---|---|---|
committer | mitchell <70453897+667e-11@users.noreply.github.com> | 2014-04-10 10:04:49 -0400 |
commit | 2321c7ad5ab98d0be3b932f00bb91601b313cef9 (patch) | |
tree | 31d54d87b96f6d3fd949ec1634d3ea477b4b4823 /core/lfs_ext.lua | |
parent | e96154f12bbfe50ce23b9fb7430275c276a544ec (diff) |
Fixed bug introduced by r1710 relating to absolute paths.
Diffstat (limited to 'core/lfs_ext.lua')
-rw-r--r-- | core/lfs_ext.lua | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/core/lfs_ext.lua b/core/lfs_ext.lua index 7fe04b89..3b857477 100644 --- a/core/lfs_ext.lua +++ b/core/lfs_ext.lua @@ -96,14 +96,16 @@ end --- -- Returns the absolute path to string *filename*. --- `lfs.currentdir()` is prepended to a relative filename. The returned path is --- not guaranteed to exist. +-- *prefix* or `lfs.currentdir()` is prepended to a relative filename. The +-- returned path is not guaranteed to exist. -- @param filename The relative or absolute path to a file. -- @return string absolute path -function lfs.abspath(filename) - if filename:find(not WIN32 and '^/' or '^%a:[/\\]') then return filename end +function lfs.abspath(filename, prefix) if WIN32 then filename = filename:gsub('/', '\\') end - filename = lfs.currentdir()..(not WIN32 and '/' or '\\')..filename + if not filename:find(not WIN32 and '^/' or '^%a:[/\\]') then + prefix = prefix or lfs.currentdir() + filename = prefix..(not WIN32 and '/' or '\\')..filename + end filename = filename:gsub('%f[^/\\]%.[/\\]', '') -- clean up './' while filename:find('[^/\\]+[/\\]%.%.[/\\]') do filename = filename:gsub('[^/\\]+[/\\]%.%.[/\\]', '') -- clean up '../' |