static string literals
This commit is contained in:
@@ -1,24 +0,0 @@
|
||||
module file
|
||||
|
||||
export func read_text(path: string): ^u8 {
|
||||
let fd = sys::open(path.ptr 0 0o644)
|
||||
if fd < 0 {
|
||||
return ^u8(0) // failed to open
|
||||
}
|
||||
|
||||
let buf_size: u64 = 4096
|
||||
let buf = c::malloc(buf_size) as ^u8
|
||||
if buf == ^u8(0) {
|
||||
return ^u8(0)
|
||||
}
|
||||
|
||||
let bytes_read = sys::read(fd, buf, buf_size)
|
||||
if bytes_read < 0 {
|
||||
c::free(buf)
|
||||
return ^u8(0)
|
||||
}
|
||||
|
||||
buf[bytes_read] = 0
|
||||
|
||||
return buf
|
||||
}
|
||||
Reference in New Issue
Block a user