diff options
author | Eduardo Julian | 2020-05-06 04:19:54 -0400 |
---|---|---|
committer | Eduardo Julian | 2020-05-06 04:19:54 -0400 |
commit | 3e524725cfb47cb56466a08ac290ed5a389748be (patch) | |
tree | 5ba247673e8a3b6d2e25df194b0f6011c2c0b436 /stdlib/source/lux/world/file.lux | |
parent | 724372e2b023bccbb93e1fa40e3c92ed2ee7e36c (diff) |
Loading the artifacts from the cache and re-populating the analyser's state.
Diffstat (limited to '')
-rw-r--r-- | stdlib/source/lux/world/file.lux | 66 |
1 files changed, 58 insertions, 8 deletions
diff --git a/stdlib/source/lux/world/file.lux b/stdlib/source/lux/world/file.lux index 6310a47b9..469cc6e01 100644 --- a/stdlib/source/lux/world/file.lux +++ b/stdlib/source/lux/world/file.lux @@ -5,9 +5,9 @@ [abstract ["." monad (#+ Monad do)]] [control - ["." try (#+ Try) ("#;." functor)] + ["." try (#+ Try) ("#@." functor)] ["." exception (#+ Exception exception:)] - ["." io (#+ IO) ("#;." functor)] + ["." io (#+ IO) ("#@." functor)] [concurrency ["." promise (#+ Promise)]] [security @@ -35,6 +35,9 @@ (capability: #export (Can-Open ! capability) (can-open Path (! (Try (capability !))))) +(capability: #export (Can-See o) + (can-see [] o)) + (capability: #export (Can-Query ! o) (can-query [] (! (Try o)))) @@ -46,6 +49,14 @@ (`` (signature: #export (File !) (~~ (template [<name> <output>] + [(: (Can-See <output>) + <name>)] + + [name Text] + [path Path] + )) + + (~~ (template [<name> <output>] [(: (Can-Query ! <output>) <name>)] @@ -102,6 +113,18 @@ (~~ (template [<forge> <name>+] [(with-expansions [<rows> (template.splice <name>+)] (template [<name>] + [(def: <name> (<forge> (|>> (!.use (:: file <name>)))))] + + <rows>))] + + [..can-see + [[name] [path]]] + + )) + + (~~ (template [<forge> <name>+] + [(with-expansions [<rows> (template.splice <name>+)] + (template [<name>] [(def: <name> (<forge> (|>> (!.use (:: file <name>)) promise.future)))] <rows>))] @@ -115,15 +138,16 @@ [..can-delete [[delete]]])) - (def: move (..can-open - (|>> (!.use (:: file move)) (io;map (try;map async-file)) promise.future)))))) + (def: move + (..can-open + (|>> (!.use (:: file move)) (io@map (try@map async-file)) promise.future)))))) (def: (async-directory directory) (-> (Directory IO) (Directory Promise)) (`` (structure (~~ (template [<name> <async>] [(def: <name> (..can-query (|>> (!.use (:: directory <name>)) - (io;map (try;map (list@map <async>))) + (io@map (try@map (list@map <async>))) promise.future)))] [files ..async-file] @@ -137,7 +161,7 @@ (`` (structure (~~ (template [<name> <async>] [(def: <name> (..can-open - (|>> (!.use (:: system <name>)) (io;map (try;map <async>)) promise.future)))] + (|>> (!.use (:: system <name>)) (io@map (try@map <async>)) promise.future)))] [file ..async-file] [create-file ..async-file] @@ -199,7 +223,8 @@ [exists] [delete] [isFile] [isDirectory] [canRead] [canWrite] [canExecute])) - + + (getName [] java/lang/String) (length [] #io #try long) (listFiles [] #io #try #? [java/io/File]) (getAbsolutePath [] #io #try java/lang/String) @@ -265,6 +290,18 @@ (wrap data) (io.io (exception.throw cannot-read-all-data path))))))) + (def: name + (..can-see + (function (name _) + (|> path + java/io/File::new + java/io/File::getName)))) + + (def: path + (..can-see + (function (_ _) + path))) + (def: size (..can-query (function (size _) @@ -411,7 +448,8 @@ (rmdirSync [host.String] #try Any)) (import: JsPath - (sep host.String)) + (sep host.String) + (basename [host.String] host.String)) (import: (#static require [host.String] Any)) @@ -436,6 +474,18 @@ (function (content _) (io.io (Fs::readFileSync [path] (!fs)))))) + (def: name + (..can-see + (function (name _) + (|> (..require "path") + (:coerce JsPath) + (JsPath::basename path))))) + + (def: path + (..can-see + (function (_ _) + path))) + (def: size (..can-query (function (size _) |