about summary refs log tree commit diff stats
path: root/file.lua
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2022-09-11 08:37:48 -0700
committerKartik K. Agaram <vc@akkartik.com>2022-09-11 08:37:48 -0700
commitd6acf1aaa0ac7ce46f3f9419d2e91b8655b982bf (patch)
treee02e319ea1453520763441b0470b1a9543945fdd /file.lua
parent7fb71f92199000a470cbac36fa4de31db810d88a (diff)
parentf2c8f06819658084ec2f585d0721af345fb9af7d (diff)
downloadview.love-d6acf1aaa0ac7ce46f3f9419d2e91b8655b982bf.tar.gz
Merge text.love
Diffstat (limited to 'file.lua')
-rw-r--r--file.lua17
1 files changed, 17 insertions, 0 deletions
diff --git a/file.lua b/file.lua
index 98311da..12bd5a1 100644
--- a/file.lua
+++ b/file.lua
@@ -58,3 +58,20 @@ function load_array(a)
   end
   return result
 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