CfsFileDescriptor size bug

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

CfsFileDescriptor size bug

Randy Nelson-2
Has anyone else noticed that CfsFileDescriptor>>#size returns incorrect values when the actual file size is > 0xFFFFFFFF? The #size method calls #lseek:whence: which prepares the proper parameters for the Windows SetFilePointer call but it seems to neglect actually using the high order 32 bits when the call returns. If I make the change to #lseek:whence: to check for high order 32 bits, it seems to return proper values. Currently the call returns:
^result negative
ifTrue: [CfsError new errno: EINVAL]
ifFalse: [result]]
without checking to see if Windows set anything in the high order 32 bits. If I change it to:
^result negative
ifTrue: [CfsError new errno: EINVAL]
ifFalse: [ 
((highOffset uint32At: 0) > 0) 
ifTrue: [ OSInt64 new uint64At: 0 put: result; uint32At: 4 put: (highOffset uint32At: 0); uint64At: 0 ]
ifFalse: [ result ] ]]
to check for the high order bits, it seems to return proper values for files bigger than 16rFFFFFFFF (4294967295).

I've tested this on 32 bit and 64 bit systems and with versions up to 8.6. All tests returned incorrect file sizes without the above change.

--
You received this message because you are subscribed to the Google Groups "VA Smalltalk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at http://groups.google.com/group/va-smalltalk.
For more options, visit https://groups.google.com/groups/opt_out.
Reply | Threaded
Open this post in threaded view
|

Re: CfsFileDescriptor size bug

John O'Keefe-3
Randy -

Yes, that looks like it should work. I've opened case 53428 for the change to lseek:whence:and it will be in the next release.

While researching this post, I discovered that there is a better way to get the size of a file -- the Win32 function GetFileSizeEx. I have opened case 53430 for this change.

John

--
You received this message because you are subscribed to the Google Groups "VA Smalltalk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at http://groups.google.com/group/va-smalltalk.
For more options, visit https://groups.google.com/groups/opt_out.
Reply | Threaded
Open this post in threaded view
|

Re: CfsFileDescriptor size bug

John O'Keefe-3
Randy -

Your code does work just fine. However, for the final fix, I have changed lseek:whence: to use the Win32 SetFilePointerEx function instead of SetFilePointer. This removes the need to do the funky code to combine 'result' and 'highOffset' to form the answer from lseek:whence:.

John

On Wednesday, January 15, 2014 2:52:58 PM UTC-5, John O'Keefe wrote:
Randy -

Yes, that looks like it should work. I've opened case 53428 for the change to lseek:whence:and it will be in the next release.

While researching this post, I discovered that there is a better way to get the size of a file -- the Win32 function GetFileSizeEx. I have opened case 53430 for this change.

John

--
You received this message because you are subscribed to the Google Groups "VA Smalltalk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at http://groups.google.com/group/va-smalltalk.
For more options, visit https://groups.google.com/groups/opt_out.