Mercurial Hosting > luan
comparison 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 |
comparison
equal
deleted
inserted
replaced
1569:adf83ae2b9ea | 1570:81288d8b20a2 |
---|---|
1 require "java" | 1 require "java" |
2 local IoLuan = require "java:luan.modules.IoLuan" | 2 local IoLuan = require "java:luan.modules.IoLuan" |
3 local System = require "java:java.lang.System" | 3 local System = require "java:java.lang.System" |
4 local Boot = require "luan:Boot.luan" | 4 local Boot = require "luan:Boot.luan" |
5 local LuanException = require "java:luan.LuanException" | |
5 | 6 |
6 | 7 |
7 local Io = {} | 8 local Io = {} |
8 | 9 |
9 Io.dns_lookup = IoLuan.dns_lookup | 10 Io.dns_lookup = IoLuan.dns_lookup |
78 Io.output_to(out,fn) | 79 Io.output_to(out,fn) |
79 out.close() | 80 out.close() |
80 return string_uri.read_text() | 81 return string_uri.read_text() |
81 end | 82 end |
82 | 83 |
84 function Io.relative_file_name(path) | |
85 local f = LuanException.getLuanStackTrace()[2].getFileName() | |
86 f = uri(f) | |
87 f.parent or error "source isn't file" | |
88 return f.parent().to_uri_string().."/"..path | |
89 end | |
90 | |
83 | 91 |
84 -- debug | 92 -- debug |
85 | 93 |
86 function Io.debug(prompt) | 94 function Io.debug(prompt) |
87 prompt = prompt or "luan_debug> " | 95 prompt = prompt or "luan_debug> " |