I'm getting a negative number being returned for large files when using
File.size()??? Any ideas? One of my ruby books says an Integer can be any
size??
I'm using:
- File.size(path)
- getting negative number responses for large files (e.g. -1001581 where
file was really around 3.2GB)
- using Windows XP
- using ruby 1.8.5 (2006-08-25) [i386-mswin32]
At Sun, 3 Dec 2006 15:56:49 +0900,
Greg Hauptmann wrote in [ruby-talk:227857]:
I'm getting a negative number being returned for large files when using
File.size()??? Any ideas? One of my ruby books says an Integer can be any
size??
I'm using:
- File.size(path)
- getting negative number responses for large files (e.g. -1001581 where
file was really around 3.2GB)
- using Windows XP
- using ruby 1.8.5 (2006-08-25) [i386-mswin32]
1.8 series on MS-Windows doesn't contain large file support.
I'm getting a negative number being returned for large files when using
File.size()??? Any ideas? One of my ruby books says an Integer can be
any
size??
I'm using:
- File.size(path)
- getting negative number responses for large files (e.g. -1001581 where
file was really around 3.2GB)
- using Windows XP
- using ruby 1.8.5 (2006-08-25) [i386-mswin32]
I'm getting a negative number being returned for large files when using
File.size()??? Any ideas? One of my ruby books says an Integer can be any
size??
I'm using:
- File.size(path)
- getting negative number responses for large files (e.g. -1001581 where
file was really around 3.2GB)
- using Windows XP
- using ruby 1.8.5 (2006-08-25) [i386-mswin32]
thanks
It's a bug in Ruby, not Windows. You can use win32-file, which redefines File.size so that it works properly on Windows.
It uses win32-file-stat behind the scenes, so make sure you've got the latest releases of both win32-file (0.5.2) and win32-file-stat (1.2.3).
Greg Hauptmann wrote:
> Hi,
>
> I'm getting a negative number being returned for large files when using
> File.size()??? Any ideas? One of my ruby books says an Integer can be
> any
> size??
>
> I'm using:
> - File.size(path)
> - getting negative number responses for large files (e.g. -1001581 where
> file was really around 3.2GB)
> - using Windows XP
> - using ruby 1.8.5 (2006-08-25) [i386-mswin32]
>
> thanks
I'm getting a negative number being returned for large files when using File.size()??? Any ideas? One of my ruby books says an Integer can be any size??
I'm using:
- File.size(path)
- getting negative number responses for large files (e.g. -1001581 where file was really around 3.2GB)
excellent!! thanks Eric - who knows how long that would have taken me to
discover for myself
···
On 12/3/06, Eric Hodel <drbrain@segment7.net> wrote:
On Dec 3, 2006, at 24:30 , Greg Hauptmann wrote:
> On 12/3/06, Damjan Rems <d_rems@yahoo.com> wrote:
>> Greg Hauptmann wrote:
>>> I'm getting a negative number being returned for large files when
>>> using File.size()??? Any ideas? One of my ruby books says an
>>> Integer can be any size??
>>>
>>> I'm using:
>>> - File.size(path)
>>> - getting negative number responses for large files (e.g.
>>> -1001581 where file was really around 3.2GB)
>>
>> It is not yours, but Windows fault.
>
> Is there a work around for this guys?
However, notice that for VERY large files, (larger than 4Gb, I guess,
or 4294967296 bytes), that method fails also
[4294967296].pack('l')
is the same as
[4294967296*2].pack('l')
So something different ought to be used. You might as well get
the info from "system (dir)" or similar for your specific case.
Pedro
···
On 12/3/06, Eric Hodel <drbrain@segment7.net> wrote:
On Dec 3, 2006, at 24:30 , Greg Hauptmann wrote:
> On 12/3/06, Damjan Rems <d_rems@yahoo.com> wrote:
>> Greg Hauptmann wrote:
>>> I'm getting a negative number being returned for large files when
>>> using File.size()??? Any ideas? One of my ruby books says an
>>> Integer can be any size??
>>>
>>> I'm using:
>>> - File.size(path)
>>> - getting negative number responses for large files (e.g.
>>> -1001581 where file was really around 3.2GB)
>>
>> It is not yours, but Windows fault.
>
> Is there a work around for this guys?
On Sun, Dec 03, 2006 at 07:58:19PM +0900, Greg Hauptmann wrote:
On 12/3/06, Eric Hodel <drbrain@segment7.net> wrote:
>On Dec 3, 2006, at 24:30 , Greg Hauptmann wrote:
>> On 12/3/06, Damjan Rems <d_rems@yahoo.com> wrote:
>>> It is not yours, but Windows fault.
>>
>> Is there a work around for this guys?
>
>[-1001581].pack('l').unpack('L').first # => 4293965715
>
excellent!! thanks Eric - who knows how long that would have taken me to
discover for myself
On 12/3/06, Eric Hodel <drbrain@segment7.net> wrote:
On Dec 3, 2006, at 24:30 , Greg Hauptmann wrote:
> On 12/3/06, Damjan Rems <d_rems@yahoo.com> wrote:
>> Greg Hauptmann wrote:
>>> I'm getting a negative number being returned for large files when
>>> using File.size()??? Any ideas? One of my ruby books says an
>>> Integer can be any size??
>>>
>>> I'm using:
>>> - File.size(path)
>>> - getting negative number responses for large files (e.g.
>>> -1001581 where file was really around 3.2GB)
>>
>> It is not yours, but Windows fault.
>
> Is there a work around for this guys?
where do you get win32-file? I don't see it in the api or on the wiki? Is
it a gem I have to load?
Tks
···
On 12/4/06, Daniel Berger <djberg96@gmail.com> wrote:
Pedro Fortuny Ayuso wrote:
> On 12/3/06, Eric Hodel <drbrain@segment7.net> wrote:
>>
>> On Dec 3, 2006, at 24:30 , Greg Hauptmann wrote:
>> > On 12/3/06, Damjan Rems <d_rems@yahoo.com> wrote:
>> >> Greg Hauptmann wrote:
>> >>> I'm getting a negative number being returned for large files when
>> >>> using File.size()??? Any ideas? One of my ruby books says an
>> >>> Integer can be any size??
>> >>>
>> >>> I'm using:
>> >>> - File.size(path)
>> >>> - getting negative number responses for large files (e.g.
>> >>> -1001581 where file was really around 3.2GB)
>> >>
>> >> It is not yours, but Windows fault.
>> >
>> > Is there a work around for this guys?
>>
>> [-1001581].pack('l').unpack('L').first # => 4293965715
>
> However, notice that for VERY large files, (larger than 4Gb, I guess,
> or 4294967296 bytes), that method fails also
>
> [4294967296].pack('l')
>
> is the same as
>
> [4294967296*2].pack('l')
>
> So something different ought to be used. You might as well get
> the info from "system (dir)" or similar for your specific case.
>
> Pedro
>