SetEndOfFile fix

Guy L. Albertelli galberte at neo.lrun.com
Sat Jan 26 17:33:23 CST 2002


----- Original Message -----
From: "Rein Klazes" <rklazes at xs4all.nl>
To: "Guy L. Albertelli" <galberte at neo.lrun.com>
Cc: <wine-devel at winehq.com>
Sent: Saturday, January 26, 2002 8:50 AM
Subject: Re: SetEndOfFile fix


> On Sat, 26 Jan 2002 01:48:06 -0500, you wrote:
>
> 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.
>

All the following is on the 2.2.12-20 kernel:

"ftruncate" would return a 0. However Scandisk said that the file was bad.
The length reported in the directory was larger than the allocated space.
Errors were also reported on attempts to move or copy the file.

Since ftruncate did not return a error, the rest of your code was never
executed. So the rewrite basically asked if the file was being extended,
then use the lseek and write. Use ftruncate only if shortening the file.
This process resulted in a "valid" file. The size in the directory seemed to
match the allocated space.

The oldoff offset was just to put the current file pointer back to where it
was on entry. I was not sure of the semantics of the SetEndOfFile and where
it would leave the file pointer.

Guy






More information about the wine-devel mailing list