os: fix bug where read_bytes would return only the first byte

pull/3130/head
prime31 2019-12-17 13:16:56 -08:00 committed by Alexander Medvednikov
parent e68200538a
commit f00f9fbf5a
1 changed files with 3 additions and 3 deletions

View File

@ -96,11 +96,11 @@ pub fn read_bytes(path string) ?[]byte {
C.fseek(fp, 0, C.SEEK_END)
fsize := C.ftell(fp)
C.rewind(fp)
println('fsize=$fsize')
mut res := [`0`].repeat(fsize)
nreadbytes := C.fread(res.data, fsize, 1, fp)
nreadelements := C.fread(res.data, fsize, 1, fp)
C.fclose(fp)
return res[0..nreadbytes]
return res[0..nreadelements * fsize]
}
// read_file reads the file in `path` and returns the contents.