Skip to content

Instantly share code, notes, and snippets.

@insanitybit
Created March 17, 2017 01:02
Show Gist options
  • Save insanitybit/e92d4d93e4a751426e4e637a3a3d7ee5 to your computer and use it in GitHub Desktop.
Save insanitybit/e92d4d93e4a751426e4e637a3a3d7ee5 to your computer and use it in GitHub Desktop.
actor Searcher
be search(env: Env, path: FilePath) =>
var file_contents: String ref = String.create()
match OpenFile(path)
| let file: File =>
file_contents.reserve(file.size())
while file.errno() is FileOK do
file_contents.append(file.read_string(file.size()))
end
end
env.out.print(file_contents)
@Praetonus
Copy link

The string recovery could look like this:

actor Searcher
  be search(env: Env, path: FilePath) =>
    let recovered_file_contents: String val = recover val
      let file_contents: String ref = String.create()
      match OpenFile(path)
      | let file: File =>
        file_contents.reserve(file.size())
        while file.errno() is FileOK do
        file_contents.append(file.read_string(file.size()))
      end
      file_contents
    end

  env.out.print(recovered_file_contents)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment