From: fox@cat.nyu.edu (David Fox)
Subject: Re: lseek past EOF doesn't append zeros under Windows 95
20 Jun 1998 19:36:23 -0700
Message-ID: <y5ahg1goyqn.fsf.cygnus.gnu-win32@dsf.net>
References: <y5a3ed0r4h5.fsf_-_@dsf.net>
To: gnu-win32@cygnus.com
Cc: beshers@cs.columbia.edu

David Fox <fox@cat.nyu.edu> 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   fox@cat.nyu.edu   baL hcraeseR aideM UYN
-
For help on using this list (especially unsubscribing), send a message to
"gnu-win32-request@cygnus.com" with one line of text: "help".
