Ask a Question related to Ruby, Design and Development.
-
Alan Davies #1
[BUG] File#rewind, File#syswrite, File#pos on Cygwin build
On the cygwin build of ruby v1.8.0, I have encountered a strange bug
when using rewind, syswrite and pos. If you open a file in read/write
mode, read the contents, rewind, syswrite some data, then File#pos
always seems to return zero. This does not happen if you use the
windows build, or you replace 'syswrite' with 'write'.
e.g:
$ cat syswrite.rb
#!/bin/ruby
testStr = "hello\nthis is some example text\nblah blah blah"
# read it, rewind, then write it back again
File.open("out.txt", 'r+') do |file|
file.readlines
file.rewind
bytes = file.syswrite(testStr)
puts "#{bytes} bytes written"
puts "Now at position #{file.pos}"
end
$ ls > out.txt
$ syswrite.rb
46 bytes written
Now at position 0
Alan Davies Guest
-
problem in binding xml file data to datagrid xml file isgenerated through JSP file
problem it that i am creating xml file using JSP file and i want to bind DataGrid with xml file data that is created using JSP but it will not Bind... -
File Viewer / Bloated file sizes / What is the best file format?
I would like to find a viewer capable of looking at the main Adobe formats as well as the standard formats such as JPG and WMF ... but yet the only... -
File::Glob can't load module [cygwin], perl-5.8.4 9 (newbie)
I am playing with compiling Perl 5.8.4 under cygwin. Can anyone help me fix the error I seem not get past? ../perl harness Can't load module... -
Build pdf file?
Hello all. My brother would like to create a website that high school math teachers could use. They would come to the web site and say "I'd like... -
Confused about locking a file via file.flock(File::LOCK_EX)
I am writing a ruby appl under AIX where I need to update the /etc/hosts table. I would like to make sure that during my update nobody else can... -
ts #2
Re: [BUG] File#rewind, File#syswrite, File#pos on Cygwin build
>>>>> "A" == Alan Davies <NOSPAMcs96and@yahoo.co.ukNOSPAM> writes:
A> On the cygwin build of ruby v1.8.0, I have encountered a strange bug
A> when using rewind, syswrite and pos. If you open a file in read/write
A> mode, read the contents, rewind, syswrite some data, then File#pos
A> always seems to return zero. This does not happen if you use the
A> windows build, or you replace 'syswrite' with 'write'.
try to add a flush
A> File.open("out.txt", 'r+') do |file|
A> file.readlines
A> file.rewind
A> bytes = file.syswrite(testStr)
file.flush
A> puts "#{bytes} bytes written"
A> puts "Now at position #{file.pos}"
A> end
Guy Decoux
ts Guest
-
Robert Klemme #3
Re: [BUG] File#rewind, File#syswrite, File#pos on Cygwin build
"Alan Davies" <NOSPAMcs96and@yahoo.co.ukNOSPAM> schrieb im Newsbeitrag
news:3fba526d@primark.com..."Do not mix with other methods that write to ios or you may get> On the cygwin build of ruby v1.8.0, I have encountered a strange bug
> when using rewind, syswrite and pos. If you open a file in read/write
> mode, read the contents, rewind, syswrite some data, then File#pos
> always seems to return zero. This does not happen if you use the
> windows build, or you replace 'syswrite' with 'write'.
unpredictable results."
[url]http://www.rubycentral.com/book/ref_c_io.html#IO.syswrite[/url]
robert
Robert Klemme Guest
-
ts #4
Re: [BUG] File#rewind, File#syswrite, File#pos on Cygwin build
>>>>> "R" == Robert Klemme <bob.news@gmx.net> writes:
R> "Do not mix with other methods that write to ios or you may get
R> unpredictable results."
R> [url]http://www.rubycentral.com/book/ref_c_io.html#IO.syswrite[/url]
No, no.
moulon% cat b.rb
#!/usr/bin/ruby
testStr = "hello\nthis is some example text\nblah blah blah"
File.open("out.txt", 'r+') do |file|
file.readlines
puts "Now at position #{file.pos}"
file.rewind
puts "Now at position #{file.pos}"
bytes = file.syswrite(testStr)
puts "#{bytes} bytes written"
puts "Now at position #{file.pos}"
end
moulon%
moulon% ruby -v b.rb
ruby 1.8.0 (2003-08-04) [sparc-solaris2.7]
Now at position 3330
Now at position 0
46 bytes written
Now at position 46
moulon%
the problem is in cygwin and linux ...
Guy Decoux
ts Guest
-
Alan Davies #5
Re: [BUG] File#rewind, File#syswrite, File#pos on Cygwin build
ts wrote:
Can we get this fixed in 1.8.1 then?> the problem is in cygwin and linux ...
Alan Davies Guest



Reply With Quote

