awtk/docs/fscript_istream.md
2021-01-12 14:29:47 +08:00

1.2 KiB

istream 扩展函数

1.istream_seek

2.istream_tell

3.istream_read_uint8

4.istream_read_uint16

5.istream_read_uint32

6.istream_read_uint64

7.istream_read_int8

8.istream_read_int16

9.istream_read_int32

10.istream_read_int64

11.istream_read_float

12.istream_read_double

13.istream_read_string

14.istream_read_binary

15.istream_read_line

16.istream_is_eos

更多示例

a = istream_file_create("test.bin", "rb")
assert(istream_read_uint8(a)==1)
assert(istream_read_int8(a)==-1)
assert(istream_tell(a), 2)

assert(istream_read_uint16(a)==2)
assert(istream_read_int16(a)==-2)
assert(istream_tell(a), 6)

assert(istream_read_uint32(a)==3)
assert(istream_read_int32(a)==-3)
assert(istream_tell(a), 14)

assert(istream_read_uint64(a)==4)
assert(istream_read_int64(a)==-4)
assert(istream_tell(a), 30)

assert(istream_read_float(a)==5)
assert(istream_read_double(a)==-5)
assert(istream_tell(a), 42)

assert(istream_read_string(a, 5)=="hello")
assert(istream_tell(a), 47)

istream_read_binary(a, 5)
assert(istream_tell(a), 52)
assert(istream_seek(a, 0))
assert(istream_read_uint8(a)==1)
assert(istream_read_int8(a)==-1)
assert(istream_tell(a) == 2)

unset(a)