Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > Strange read behaviour on windows

Reply
Thread Tools

Strange read behaviour on windows

 
 
Charles Lowe
Guest
Posts: n/a
 
      10-16-2006
This is my first post to the ruby mailing lists, so let me first thank
all the people who's wonderful work I've made use of -- great stuff!.

I've been trying to upload some large files, using
Net::HTTP:ut#body_stream=, but have ran into some problems.

Most of my initial testing was in cygwin, where most things "just work".
upon trying it in the mingw32 build, i got https errors due to openssl
doing some non-block fcntls (IO#fcntl "not implemented on this
platform").

I switched to the i386-mswin32, but now I getting some more fundamental
problems, when doing file reads. I'm typically getting reads back under
the requested size, (not a problem), but this is generating premature
EOF errors. If I just use File#read, I correctly get the entire file.

An irb snippet says it best:

irb(main):139:0> f.pos
=> 1605632
irb(main):140:0> f.read 1024
=> nil
irb(main):141:0> f.pos
=> 1605632
irb(main):142:0> f.read 1024
=> nil
irb(main):143:0> f.sysread 1024
=>
"R\326ER6qJ\302So\233\321\373\25218\205\260u*\245\ 212`k\246\300Vo\233\311\373
\252)8\222}z\367\270g58\026x\022q"
irb(main):144:0> f.pos
=> 1606656
irb(main):145:0> f.sysread 1024
=>
"\340G\370\023\3023\b:R\264C\225\326\213\276\335\2 44\234O)N\035$3N\307\017\36
0d\261\321A\245\334\250y|\025lo\253\306*\205\316\2 46\276$`\366\022\255"
irb(main):146:0> _.length
=> 52
irb(main):147:0> f.sysread 1024
EOFError: end of file reached
from (irb):147:in `sysread'
from (irb):147
from :0
irb(main):148:0> f.pos
=> 1607680
irb(main):149:0> RUBY_PLATFORM
=> "i386-mswin32"

(FWIW, the file f in question, is just the one-click installer -
ruby185-21.exe. f.stat.size correctly yields 27644627).

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

 
Reply With Quote
 
 
 
 
Eero Saynatkari
Guest
Posts: n/a
 
      10-16-2006
--TSQPSNmi3T91JED+
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

On 2006.10.16 15:41, Charles Lowe wrote:
> This is my first post to the ruby mailing lists, so let me first thank=20
> all the people who's wonderful work I've made use of -- great stuff!.
>=20
> I've been trying to upload some large files, using=20
> Net::HTTP:ut#body_stream=3D, but have ran into some problems.
>=20
> Most of my initial testing was in cygwin, where most things "just work".=

=20
> upon trying it in the mingw32 build, i got https errors due to openssl=20
> doing some non-block fcntls (IO#fcntl "not implemented on this=20
> platform").
>=20
> I switched to the i386-mswin32, but now I getting some more fundamental=

=20
> problems, when doing file reads. I'm typically getting reads back under=

=20
> the requested size, (not a problem), but this is generating premature=20
> EOF errors. If I just use File#read, I correctly get the entire file.


Just on an off-chance, is your file open in binary mode?

--TSQPSNmi3T91JED+
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.5 (FreeBSD)

iD8DBQFFMy0t7Nh7RM4TrhIRAmWUAJ9BSIFBuSUv39dXYdLkMl dO/Oq9LwCgrLE2
iRThd+D1DCIiPvjaIj1NpK4=
=ttqH
-----END PGP SIGNATURE-----

--TSQPSNmi3T91JED+--

 
Reply With Quote
 
 
 
 
Charles Lowe
Guest
Posts: n/a
 
      10-16-2006
Eero Saynatkari wrote:
> On 2006.10.16 15:41, Charles Lowe wrote:
>>
>> I switched to the i386-mswin32, but now I getting some more fundamental
>> problems, when doing file reads. I'm typically getting reads back under
>> the requested size, (not a problem), but this is generating premature
>> EOF errors. If I just use File#read, I correctly get the entire file.

>
> Just on an off-chance, is your file open in binary mode?


Oops. Now I feel like an idiot; 'rb' should be the default! stupid
windows...

Thank you though, had been banging my head against that one for a while.

--
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
std.textio.read strange behaviour?! James Unterburger VHDL 3 06-26-2008 08:39 PM
std.textio.read strange behaviour?! pontus.stenstrom@gmail.com VHDL 13 06-26-2008 05:18 PM
Strange applet behaviour on Windows XP Qu0ll Java 28 11-15-2007 08:14 PM
EasyInstall under Windows - strange behaviour Norbert Python 2 12-01-2006 07:30 AM
Strange windows explorer behaviour Peter Huebner NZ Computing 4 10-08-2005 06:43 AM



Advertisments