about summary refs log tree commit diff stats
path: root/030container.cc
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2016-05-05 23:03:38 -0700
committerKartik K. Agaram <vc@akkartik.com>2016-05-05 23:03:38 -0700
commitce9616a77fc4e1c22e913308c8ea55ef05203211 (patch)
tree342be7422f012ddee07ab15cb2b13596269bed5d /030container.cc
parente76a27f3edfa0703a204f3ab30ce01b58877f6af (diff)
downloadmu-ce9616a77fc4e1c22e913308c8ea55ef05203211.tar.gz
2930
Diffstat (limited to '030container.cc')
0 files changed, 0 insertions, 0 deletions
testable interface for writing files' href='/akkartik/mu/commit/filesystem.mu?h=main&id=a621ef95f4728d15bdf0b1828ac7dd6ac5af2795'>a621ef95 ^
da925d06 ^

a621ef95 ^



da925d06 ^
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20




                                                                     

             

                                                                                             
   
                                                       
                  
                                   

        



                                                                    
 
# 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
]