Igor Marnat wrote:
Unfortunately there is no possibility at the moment to search through list-archives.
was :-)
Perhaps someone could give me an advise. I'd like to communicate with the char device driver which is realised as a file. In C I can just make "dsp_fd = open(dsp_devname, O_RDWR|O_SYNC)" and then work with it all the time using "write(fd, (const void*)msg, nbytes)" and read respectively without additional activities. How should I use it in GPC? The only way I see is to Assign (dsp_fd, dsp_devname) and then Rewrite it when I have to write to and Reset it when I need to read from.
Since `Rewrite' by definition truncates a (regular) file, it will reopen it on the system level. However, GPC allows reading and writing from a file opened with `Reset' (by default for typed and untyped files, and for text files if FileMode contains FileMode_Text_Reset_ReadWrite -- see unit GPC; it's a bit clumsy for BP compatibility).
For regular files, you'd have to seek back, but for character devices, this is usually not necessary.
However, GPC's opening routines currently don't support O_SYNC, so if that's essential, you may have to call libc's open directly.
The GPC unit contains low-level file routines such as OpenHandle (also without O_SYNC support though), ReadHandle, WriteHandle (which work with handles obtained from libc's open), AssignHandle (to bind such a handle to a Pascal file) etc.
HTH, Frank