ltrunc - negative offset ( QNX4.25)

Is there a way where the file pointer can be wrapped without distrubing
the existing contents in file?

radha krishnan wrote:

Is there a way where the file pointer can be wrapped without distrubing
the existing contents in file?

I don’t understand what you are asking - do you mean lseek()?

we wanted to limit the file size to say 1mb. Also, we would like to do a
wrap the file pointer, without disturbing the conetents in file. we tried
with lseek(filepointer, 0, SEEK_
we tried lseek( filepointer, 0 , SEEK_SET); this was not working.


John Garvey wrote:

radha krishnan wrote:
Is there a way where the file pointer can be wrapped without distrubing
the existing contents in file?

I don’t understand what you are asking - do you mean lseek()?

radha krishnan wrote:

we wanted to limit the file size to say 1mb. Also, we would like to do a
wrap the file pointer, without disturbing the conetents in file. we tried

Ah, you mean a rotary buffer? You would have to code such functionality
yourself. You’d use ltrunc() to pregrow the file initially, have a
scheme to know where head/tail was, and then control the lseek/write
into the correct place to ensure the file never grew.

radha krishnan <radha.nk@geind.ge.com> wrote:

we wanted to limit the file size to say 1mb. Also, we would like to do a
wrap the file pointer, without disturbing the conetents in file. we tried
with lseek(filepointer, 0, SEEK_
we tried lseek( filepointer, 0 , SEEK_SET); this was not working.

If by “filepointer” you mean you are working with a FILE *, then
you need to use fseek(), not lseek(). lseek() takes an fd,
fseek() takes a FILE *.

-David


David Gibbs
QNX Training Services
dagibbs@qnx.com