Asp Forum
Home
|
Login
|
Register
|
Search
Forums
>
comp.lang.ruby
File.open().read.length result incorrect on Windows Server
Aaron Chandler
3/17/2009 2:59:00 AM
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-...
.
3 Answers
Michael Linfield
3/17/2009 3:16:00 AM
0
> 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-...
.
Heesob Park
3/17/2009 3:28:00 AM
0
Hi,
2009/3/17 Aaron Chandler <vitalaaron@gmail.com>:
> 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.lang.ruby/browse_thread/thread/47209184b760c8e4/e8aca7...
Regards,
Park Heesob
Aaron Chandler
3/17/2009 3:50:00 AM
0
> Try
> File.open('bigfile.flv','rb').read.length
>
> Refer to
>
http://groups.google.com/group/comp.lang.ruby/browse_thread/thread/47209184b760c8e4/e8aca7...
>
This did the trick. Thanks tons.
-Aaron
--
Posted via
http://www.ruby-...
.
Servizio di avviso nuovi messaggi
Ricevi direttamente nella tua mail i nuovi messaggi per
File.open().read.length result incorrect on Windows Server
Inserendo la tua e-mail nella casella sotto, riceverai un avviso tramite posta elettronica ogni volta che il motore di ricerca troverà un nuovo messaggio per te
Il servizio è completamente GRATUITO!
x
Login to ForumsZone
Login with Google
Login with E-Mail & Password