Skip to content

Instantly share code, notes, and snippets.

@chancyk
Created June 27, 2018 21:40
Show Gist options
  • Save chancyk/0303d7d3a47748e0ef0ab77c786c306a to your computer and use it in GitHub Desktop.
Save chancyk/0303d7d3a47748e0ef0ab77c786c306a to your computer and use it in GitHub Desktop.
use "files"
use "collections"
class RecordType1
let spec_record_type: (U32, U32) = (0, 1)
var record_type: U8 = 0
new create(line: String val) =>
try
record_type = line.substring(0, 1).u8()?
end
class Check
let records: List[RecordType1]
new create(lines: List[String]) =>
records = List[RecordType1]()
for line in lines.values() do
records.push(RecordType1(line))
end
actor Main
var check: Check
new create(env: Env) =>
check = Check(recover List[String]() end)
let caps = recover val FileCaps.>set(FileRead).>set(FileStat) end
try
with file = OpenFile(
FilePath(env.root as AmbientAuth, env.args(1)?, caps)?
) as File
do
env.out.print(file.path.path)
let lines' = List[String]()
for line in file.lines() do
lines'.push(line)
end
Check(lines')
end
else
try
env.out.print("Couldn't open " + env.args(1)?)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment