[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Uri to absolute/relative path

App Ra

10/18/2006 11:51:00 PM

Hello, I'm new to ruby but so far my experience with Ruby has been
great. I'm unable to open an uri based on the file path.

This works
require 'open-uri'
open("http://www.ruby-lang....) {|f|
f.each_line {|line| p line}
}


but this doesn't

require 'open-uri'
open("file:c://test/test.txt") {|f|
f.each_line {|line| p line}
}

Can Ruby uri class open up a file schema?

Thanks,
apparna


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

1 Answer

Paul Lutus

10/19/2006 7:01:00 AM

0

App Ra wrote:

> Hello, I'm new to ruby but so far my experience with Ruby has been
> great. I'm unable to open an uri based on the file path.
>
> This works
> require 'open-uri'
> open("http://www.ruby-lang....) {|f|
> f.each_line {|line| p line}
> }
>
>
> but this doesn't
>
> require 'open-uri'
> open("file:c://test/test.txt") {|f|
> f.each_line {|line| p line}
> }
>
> Can Ruby uri class open up a file schema?

Make a test without a drive letter. IOW try a simpler case first. Then, if
this succeeds, try this syntax:

"file:///C:/test/test.txt"

URI paths involving drive letters must be handled very carefully. And IMHO,
drive letters should be banished from the world of computing as soon as
possible.

--
Paul Lutus
http://www.ara...