Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > File.open().read.length result incorrect on Windows Server

Reply
Thread Tools

File.open().read.length result incorrect on Windows Server

 
 
Aaron Chandler
Guest
Posts: n/a
 
      03-17-2009
Hi,

I need to open and read a 7.6M file on an EC2 Windows Server 2003
machine, and when I try using:

File.open('bigfile.flv').read.length

the result I get is 22731 (wrong) with the last characters of the file
data being "\334r\227\000\220-".

In comparison, when I run this same command for the same file on my Mac,
I get 7941109 (correct) with the last characters of the file data being
"\000\000\000\250"

It appears as if the file data is being truncated in Windows. Anyone
have an idea as to why I would be seeing results like this?

Thanks,
Aaron
--
Posted via http://www.ruby-forum.com/.

 
Reply With Quote
 
 
 
 
Michael Linfield
Guest
Posts: n/a
 
      03-17-2009
> It appears as if the file data is being truncated in Windows. Anyone
> have an idea as to why I would be seeing results like this?


Not a good explanation of WHY per'se but I've previously encountered
similar problems when opening large files on windows. What wouldn't open
in windows would open in Linux just fine.

Maybe try a different read method such as:

IO.read("filename.flv").length

or

File.stat("filename.flv").size



I don't have a large dataset I can duplicate the problem on at the
moment so I can't test this for you

Regards,

- Mac


--
Posted via http://www.ruby-forum.com/.

 
Reply With Quote
 
 
 
 
Heesob Park
Guest
Posts: n/a
 
      03-17-2009
Hi,

2009/3/17 Aaron Chandler <(E-Mail Removed)>:
> Hi,
>
> I need to open and read a 7.6M file on an EC2 Windows Server 2003
> machine, and when I try using:
>
> File.open('bigfile.flv').read.length
>
> the result I get is 22731 (wrong) with the last characters of the file
> data being "\334r\227\000\220-".
>
> In comparison, when I run this same command for the same file on my Mac,
> I get 7941109 (correct) with the last characters of the file data being
> "\000\000\000\250"
>
> It appears as if the file data is being truncated in Windows. Anyone
> have an idea as to why I would be seeing results like this?
>

Try
File.open('bigfile.flv','rb').read.length

Refer to http://groups.google.com/group/comp....aca721faa8ac67

Regards,

Park Heesob

 
Reply With Quote
 
Aaron Chandler
Guest
Posts: n/a
 
      03-17-2009

> Try
> File.open('bigfile.flv','rb').read.length
>
> Refer to
> http://groups.google.com/group/comp....aca721faa8ac67
>


This did the trick. Thanks tons.

-Aaron


--
Posted via http://www.ruby-forum.com/.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
String::CRC crc function returns incorrect result, why? `Zidane Tribal Perl 1 07-28-2007 08:01 PM
PostBack before ViewState loaded in Browser give incorrect result scolemann@gmail.com ASP .Net 1 05-31-2007 03:25 PM
Python CGI problem: correct result, but incorrect browser response. Sullivan WxPyQtKinter Python 1 04-07-2006 06:43 AM
Again: linking between C++ and Fortran results in incorrect result NM C++ 13 09-17-2005 06:32 PM
1. Ruby result: 101 seconds , 2. Java result:9.8 seconds, 3. Perl result:62 seconds Michael Tan Ruby 32 07-21-2005 03:23 PM



Advertisments