SetEndOfFile fix
Rein Klazes
rklazes at xs4all.nl
Sat Jan 26 07:50:54 CST 2002
On Sat, 26 Jan 2002 01:48:06 -0500, you wrote:
>
> This was a great catch. It was the reason Scandisk complained about
> OutlookExpress's files (see my message from 1/11/2001). However your fix
> still fails on my outdated kernel (2.2.12-20). The attached version seems to
> work better on this kernel.
[...]
> +
> + if( (oldoff = lseek( fd, 0, SEEK_CUR)) == -1) return -1;
> + if( lseek( fd, length - 1, SEEK_SET) == -1) return -1;
> + /* write one byte, filepointer is back at the orig. position. */
> + if( write( fd, &buf, 1) == -1) return -1;
> + if( lseek( fd, oldoff, SEEK_SET) == -1) return -1;
You should not have to use the oldoff offset. When this function is
entered the filepointer is already set to the desired length: length.
BTW, what goes wrong exactly? From the snippet above I understand that
either ftruncate() moves the filepointer when it fails or that the
sequence: lseek(fd,-1,SEEK_CUR);write(fd,&buf,1) moves the file
pointer.
Rein.
--
Rein Klazes
rklazes at xs4all.nl
More information about the wine-devel
mailing list