-
Notifications
You must be signed in to change notification settings - Fork 1
Open
Description
Hi, just wondering if it should be possible to read a filestream and put the result into a char array. I'm trying to run something like this:
import binstreams
import os
var fs = newFileStream(paramStr(1), endian = bigEndian, mode = fmRead)
var buf: array[2, char]
fs.read(buf, startIndex = 0, numValues = 2)
But I'm getting this error:
/Users/owner/tiff_parser/endian_test.nim(9, 3) Error: type mismatch: got <FileStream, array[0..1, char], startIndex: int literal(0), numValues: int literal(2)>
but expected one of:
proc read(fs: FileStream; T: typedesc[SomeNumber]): T:type
first type mismatch at position: 2
required type for T: type SomeNumber
but expression 'buf' is of type: array[0..1, char]
proc read[T: SomeNumber](fs: FileStream; buf: var openArray[T];
startIndex, numValues: Natural)
first type mismatch at position: 2
required type for buf: var openArray[T: SomeNumber]
but expression 'buf' is of type: array[0..1, char]
2 other mismatching symbols have been suppressed; compile with --showAllMismatches:on to see them
expression: read(fs, buf, startIndex = 0, numValues = 2)
It says the required type of T should be SomeNumber, but wondering if it could also be made to work with char arrays or if there's a reason why it can't work with other kinds of arrays? Or perhaps there are better alternate methods I could use.
Metadata
Metadata
Assignees
Labels
No labels