core :: FileReader :: open
path
for reading.var f = new FileReader.open("/etc/issue")
assert not f.eof
f.close
In case of error, last_error
is set
f = new FileReader.open("/fail/does not/exist")
assert f.eof
assert f.last_error != null
# Open the file at `path` for reading.
#
# var f = new FileReader.open("/etc/issue")
# assert not f.eof
# f.close
#
# In case of error, `last_error` is set
#
# f = new FileReader.open("/fail/does not/exist")
# assert f.eof
# assert f.last_error != null
init open(path: String)
do
self.path = path
_file = new NativeFile.io_open_read(path.to_cstring)
if _file.as(not null).address_is_null then
last_error = new IOError("Cannot open `{path}`: {sys.errno.strerror}")
end
end
lib/core/file.nit:157,2--175,4