mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
os: fix bug where read_bytes would return only the first byte
This commit is contained in:
parent
e68200538a
commit
f00f9fbf5a
@ -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.
|
||||
|
Loading…
Reference in New Issue
Block a user