about summary refs log tree commit diff stats
path: root/source_file.lua
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2022-09-11 08:31:05 -0700
committerKartik K. Agaram <vc@akkartik.com>2022-09-11 08:31:05 -0700
commit9a41c7c176aa571f5270747f690e9b4a37e27529 (patch)
tree95845ced9267487cbe536abe797b6af0e2c45319 /source_file.lua
parent511db8cffd808d244aa84095bcde83def48736e0 (diff)
downloadtext.love-9a41c7c176aa571f5270747f690e9b4a37e27529.tar.gz
more correct absolute path detection
Diffstat (limited to 'source_file.lua')
-rw-r--r--source_file.lua17
1 files changed, 17 insertions, 0 deletions
diff --git a/source_file.lua b/source_file.lua
index 6552667..8dd8832 100644
--- a/source_file.lua
+++ b/source_file.lua
@@ -199,3 +199,20 @@ function load_drawing_from_array(iter, a, i)
   end
   return i, drawing
 end
+
+function is_absolute_path(path)
+  local os_path_separator = package.config:sub(1,1)
+  if os_path_separator == '/' then
+    -- POSIX systems permit backslashes in filenames
+    return path:sub(1,1) == '/'
+  elseif os_path_separator == '\\' then
+    local f = path:sub(1,1)
+    return f == '/' or f == '\\'
+  else
+    error('What OS is this? LÖVE reports that the path separator is "'..os_path_separator..'"')
+  end
+end
+
+function is_relative_path(path)
+  return not is_absolute_path(path)
+end