blob: 7f35fdecde6376a64bc94f3edfda7856e5494070 (
plain) (
tree)
blob is binary.
rtik.com> 2016-08-16 17:13:26 -0700
committer Kartik K. Agaram <vc@akkartik.com> 2016-08-16 17:13:26 -0700
3203 - testable interface for reading a file' href='/akkartik/mu/commit/filesystem.mu?h=hlt&id=da925d0697d61db6d265fd78cab3d1adf214950c'>da925d06
^
# example program: copy one file into another, character by character
# BEWARE: this will modify your file system
# before running it, put some text into /tmp/mu-x
# after running it, check /tmp/mu-y
def main [
local-scope
source-file:&:source:char <- start-reading null/real-filesystem, [/tmp/mu-x]
sink-file:&:sink:char, write-routine:num <- start-writing null/real-filesystem, [/tmp/mu-y]
{
c:char, done?:bool, source-file <- read source-file
break-if done?
sink-file <- write sink-file, c
loop
}
close sink-file
# make sure to wait for the file to be actually written to disk
# (Mu practices structured concurrency: http://250bpm.com/blog:71)
wait-for-routine write-routine
]
|