_WBLOCK - block-oriented write operation.

(GCOS8 only)


status = _wblock(fp,buf,nbytes,seek);


FILE *fp;
indicates the stream to which you want to write.
void *buf;
points to the data that you want to write. This must be word-aligned.
int nbytes;
is the number of bytes of data that you want to write. This must be greater than zero and a multiple of 4.
int seek;
is a byte offset within the file, indicating the place where you want to start writing.
int status;
is the number of bytes written, if the operation was successful. If an I/O error occurs, "status" is the negative of the major error status.


"_wblock" performs a binary write operation on a random or sequential disk file.

If "_wblock" gets an end-of-file status on the output stream, it attempts to grow the file enough to hold the data, provided that the write operation was exactly at the end of the file. If the grow is successful, the remainder of the write is reissued. If the grow fails, "_wblock" does not make a second attempt at growing the file.

For a random disk file, "seek" must be a non-zero multiple of 4*64 (since there are four bytes in each word and 64 words in a sector). There is no limit on the amount of data you can write.

Also for a random disk file, "nbytes" should be a multiple of 4*64. If "nbytes" is not a multiple of 320*4, the hardware fills out the last sector with zeroes, and the remaining sectors of the last llink are left untouched. For random files, "nbytes" must be less than 256*1024*4.

For a sequential disk file, "seek" must be a multiple of 4*320 and "nbytes" must be less than or equal to 63*4*320 (63 llinks). The file pointer will be advanced by (words+319)/320 llinks (where "words" is the number of words written, normally "nbytes/4").

See Also:

expl b lib .grow
for details of the file growth algorithm.

Copyright © 1996, Thinkage Ltd.