urbit/ape/write.hoon

37 lines
970 B
Plaintext
Raw Normal View History

2015-10-09 01:22:34 +03:00
:: File writer
::
2015-12-20 14:48:17 +03:00
:::: /hoon#write#app
2015-10-09 01:22:34 +03:00
::
2015-12-20 00:00:01 +03:00
|_ {bowl $~}
2015-10-09 01:22:34 +03:00
++ beak-now byk(r [%da now])
++ poke-json
2015-12-20 00:00:01 +03:00
|= jon+json
2015-10-09 01:22:34 +03:00
=- (poke--data (need (- jon.+)))
=> jo
%- ot :~
2015-12-20 14:48:17 +03:00
pax#(cu deft (su fel:stab))
dat#(of json#some mime#(pe / (cu taco so)) ~) :: XX mite
2015-10-09 01:22:34 +03:00
==
::
++ poke-write-paste
2015-12-20 00:00:01 +03:00
|= {typ+?($hoon $md $txt) txt+@t}
2015-12-20 14:48:17 +03:00
(poke--data [`typ /pub#paste#(scot %da now)] %mime / (taco txt))
2015-10-09 01:22:34 +03:00
::
++ poke--data
2015-12-20 00:00:01 +03:00
|= {{ext+(unit @t) pax+path} dat+$$({$json json} {$mime mime})}
2015-10-09 01:22:34 +03:00
?~ ext $(ext [~ -.dat])
=+ cay=?-(-.dat %json [-.dat !>(+.dat)], %mime [-.dat !>(+.dat)])
?: =(u.ext -.dat) (made pax ~ `cay)
[[ost %exec pax our ~ beak-now %cast u.ext `cay]~ +>.$] :: XX defer %nice
::
++ made
2015-12-20 00:00:01 +03:00
|= {pax+wire @ res+gage}
?. =(our src)
2015-12-20 14:48:17 +03:00
~|(foreign-write#[our=our src=src] !!)
?+ -.res ~|(gage#-.res !!)
2015-12-20 00:00:01 +03:00
$| (mean p.res)
$& =- [[ost %info / our -]~ +>.$]
2015-10-09 01:22:34 +03:00
(foal :(welp (tope beak-now ~) pax /[-.p.res]) p.res)
==
--