comparison src/luan/modules/host/Hosting.luan @ 1716:b82767112d8e

add String.regex
author Franklin Schmidt <fschmidt@gmail.com>
date Sun, 24 Jul 2022 23:43:03 -0600
parents cd2a0c41b23f
children 0a06d59578aa
comparison
equal deleted inserted replaced
1715:ad44e849c60c 1716:b82767112d8e
6 local stringify = Luan.stringify or error() 6 local stringify = Luan.stringify or error()
7 local Io = require "luan:Io.luan" 7 local Io = require "luan:Io.luan"
8 local print = Io.print or error() 8 local print = Io.print or error()
9 local Rpc = require "luan:Rpc.luan" 9 local Rpc = require "luan:Rpc.luan"
10 local String = require "luan:String.luan" 10 local String = require "luan:String.luan"
11 local matches = String.matches or error() 11 local contains = String.contains or error()
12 local starts_with = String.starts_with or error()
12 local substring = String.sub or error() 13 local substring = String.sub or error()
13 local split = String.split or error() 14 local split = String.split or error()
14 local Logging = require "luan:logging/Logging.luan" 15 local Logging = require "luan:logging/Logging.luan"
15 local logger = Logging.logger "Hosting" 16 local logger = Logging.logger "Hosting"
16 17
41 if there == nil then 42 if there == nil then
42 there = host.mkdir(domain,password,there_parent.path,here.name()) 43 there = host.mkdir(domain,password,there_parent.path,here.name())
43 end 44 end
44 for _, here_child in ipairs(here.children()) do 45 for _, here_child in ipairs(here.children()) do
45 local name = here_child.name() 46 local name = here_child.name()
46 if not matches(name,[[^\.]]) then 47 if not starts_with(name,".") then
47 process(there,there.children[name],here_child) 48 process(there,there.children[name],here_child)
48 there.children[name] = nil 49 there.children[name] = nil
49 end 50 end
50 end 51 end
51 for _, there_child in pairs(there.children) do 52 for _, there_child in pairs(there.children) do
71 local my_file = Io.uri("file:"..file) 72 local my_file = Io.uri("file:"..file)
72 my_file.exists() or error("file '"..file.."' not found") 73 my_file.exists() or error("file '"..file.."' not found")
73 my_file.is_file() or error("'"..file.."' is not a file") 74 my_file.is_file() or error("'"..file.."' is not a file")
74 local my_file_string = my_file.to_string() 75 local my_file_string = my_file.to_string()
75 local my_dir_string = my_dir.to_string().."/" 76 local my_dir_string = my_dir.to_string().."/"
76 matches( my_file_string, [[^\Q]]..my_dir_string..[[\E]] ) or error "file must be in dir" 77 contains( my_file_string, my_dir_string ) or error "file must be in dir"
77 my_file_string = substring(my_file_string,#my_dir_string+1) 78 my_file_string = substring(my_file_string,#my_dir_string+1)
78 local path = {split( my_file_string, "/" )} 79 local path = {split( my_file_string, "/" )}
79 path[#path] = nil 80 path[#path] = nil
80 local host = Rpc.remote(domain) 81 local host = Rpc.remote(domain)
81 local there = host.get(domain,password) 82 local there = host.get(domain,password)