"Fossies" - the Fresh Open Source Software Archive

Member "ponyc-0.33.0/examples/files/files.pony" (1 Nov 2019, 464 Bytes) of package /linux/misc/ponyc-0.33.0.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Pony source code syntax highlighting (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file.

    1 use "files"
    2 
    3 actor Main
    4   new create(env: Env) =>
    5     let caps = recover val FileCaps.>set(FileRead).>set(FileStat) end
    6 
    7     try
    8       with file = OpenFile(
    9         FilePath(env.root as AmbientAuth, env.args(1)?, caps)?) as File
   10       do
   11         env.out.print(file.path.path)
   12         for line in file.lines() do
   13           env.out.print(consume line)
   14         end
   15       end
   16     else
   17       try
   18         env.out.print("Couldn't open " + env.args(1)?)
   19       end
   20     end