1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

all: rune type for `` literals

This commit is contained in:
Alexander Medvednikov
2020-08-27 06:46:18 +02:00
parent 99dd72efea
commit 6921d46185
17 changed files with 173 additions and 108 deletions

View File

@@ -72,7 +72,8 @@ pub fn (f &File) read_bytes(size int) []byte {
// read_bytes_at reads an amount of bytes at the given position in the file
pub fn (f &File) read_bytes_at(size, pos int) []byte {
mut arr := [`0`].repeat(size)
//mut arr := [`0`].repeat(size)
mut arr := []byte{ len:size }
C.fseek(f.cfile, pos, C.SEEK_SET)
nreadbytes := C.fread(arr.data, 1, size, f.cfile)
C.fseek(f.cfile, 0, C.SEEK_SET)

View File

@@ -16,7 +16,7 @@ pub fn read_bytes(path string) ?[]byte {
C.fseek(fp, 0, C.SEEK_END)
fsize := C.ftell(fp)
C.rewind(fp)
mut res := [`0`].repeat(fsize)
mut res := [byte(`0`)].repeat(fsize)
nr_read_elements := C.fread(res.data, fsize, 1, fp)
C.fclose(fp)
return res[0..nr_read_elements * fsize]