Subject: Re: lseek past EOF doesn't append zeros under Windows 95
From: [email-masked] (David Fox)

20 Jun 1998 19:36:23 -0700
Message-ID: <[email-masked]>
References: <[email-masked]>
To: [email-masked]
Cc: [email-masked]

David Fox <[email-masked]> writes:

> Run this with the argument 100 and you will get a two hundred byte
> file filled with garbage.  Under Unix or cygwin32_nt the first hundred
> bytes will be zero.  Any advice?

Here is a wrapper for lseek that works around this problem:

off_t zlseek(int fildes, off_t offset, int whence)
{
  off_t end = lseek(fildes, 0L, SEEK_END);
  if (end < offset) {
    char buf[offset-end];
    memset(buf, 0, offset - end);
    write(fildes, buf, offset - end);
  }
  return lseek(fildes, offset, whence);
}

-- 
David Fox	   http://www.cat.nyu.edu/fox		xoF divaD
NYU Media Research Lab   [email-masked]   baL hcraeseR aideM UYN
-
For help on using this list (especially unsubscribing), send a message to
"[email-masked]" with one line of text: "help".