diff src/luan/modules/Io.luan @ 1570:81288d8b20a2

add Io.relative_file_name
author Franklin Schmidt <fschmidt@gmail.com>
date Wed, 18 Nov 2020 20:41:49 -0700
parents d9a5405a3102
children a23b02693d3b
line wrap: on
line diff
--- a/src/luan/modules/Io.luan	Wed Nov 18 19:41:20 2020 -0700
+++ b/src/luan/modules/Io.luan	Wed Nov 18 20:41:49 2020 -0700
@@ -2,6 +2,7 @@
 local IoLuan = require "java:luan.modules.IoLuan"
 local System = require "java:java.lang.System"
 local Boot = require "luan:Boot.luan"
+local LuanException = require "java:luan.LuanException"
 
 
 local Io = {}
@@ -80,6 +81,13 @@
 	return string_uri.read_text()
 end
 
+function Io.relative_file_name(path)
+	local f = LuanException.getLuanStackTrace()[2].getFileName()
+	f = uri(f)
+	f.parent or error "source isn't file"
+	return f.parent().to_uri_string().."/"..path
+end
+
 
 -- debug