Mercurial Hosting > luan
comparison src/luan/modules/Boot.luan @ 1570:81288d8b20a2
add Io.relative_file_name
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Wed, 18 Nov 2020 20:41:49 -0700 |
parents | adf83ae2b9ea |
children | c922446f53aa |
comparison
equal
deleted
inserted
replaced
1569:adf83ae2b9ea | 1570:81288d8b20a2 |
---|---|
12 local matches = StringLuan.matches -- String.matches | 12 local matches = StringLuan.matches -- String.matches |
13 local IoLuan = require "java:luan.modules.IoLuan" | 13 local IoLuan = require "java:luan.modules.IoLuan" |
14 local LuanUrl = require "java:luan.modules.url.LuanUrl" | 14 local LuanUrl = require "java:luan.modules.url.LuanUrl" |
15 local LuanJava = require "java:luan.Luan" | 15 local LuanJava = require "java:luan.Luan" |
16 local LuanTable = require "java:luan.LuanTable" | 16 local LuanTable = require "java:luan.LuanTable" |
17 local LuanException = require "java:luan.LuanException" | |
18 | 17 |
19 | 18 |
20 local Boot = {} | 19 local Boot = {} |
21 | 20 |
22 | 21 |
224 local opener = schemes[scheme] or error( "invalid scheme '"..scheme.."' in '"..name.."'" ) | 223 local opener = schemes[scheme] or error( "invalid scheme '"..scheme.."' in '"..name.."'" ) |
225 return opener(location,options) | 224 return opener(location,options) |
226 end | 225 end |
227 Boot.uri = uri | 226 Boot.uri = uri |
228 | 227 |
229 --[[ | |
230 local function get_caller_file() | |
231 for _, ste in ipairs(LuanException.getLuanStackTrace()) do | |
232 local f = ste.getFileName() | |
233 if f ~= "luan:Boot.luan" then | |
234 return f | |
235 end | |
236 end | |
237 error() | |
238 end | |
239 | |
240 function schemes.rel(path) | |
241 local f = get_caller_file() | |
242 System.out.println(f) | |
243 f = uri(f) | |
244 f.parent or error "source isn't file" | |
245 return f.parent().child(path) | |
246 end | |
247 ]] | |
248 | 228 |
249 function Boot.read(uri_str) -- for PackageLuan.java | 229 function Boot.read(uri_str) -- for PackageLuan.java |
250 local u = uri(uri_str) | 230 local u = uri(uri_str) |
251 if u==nil or not u.exists() then | 231 if u==nil or not u.exists() then |
252 return nil | 232 return nil |