On Tue, Jan 28, 2014 at 3:46 PM, cynic limbu <lists / ruby-forum.com> wrote:
> I'm trying to make my own program that can help me manage my
> files/folders faster than Windows command prompt but I have ran across a
> problem.
>
> The problem is if a user tries to open a folder while the program is in
> "open text file" mode, it will close itself.

What error are you seeing?  Is it this one?

$ ruby -e 'File.open("."){|io|io.each_line {|l| puts l}}'
-e:1:in `each_line': Is a directory - . (Errno::EISDIR)
        from -e:1:in `block in <main>'
        from -e:1:in `open'
        from -e:1:in `<main>'

You usually cannot open folders like files. That's why there is Dir.open():
http://www.ruby-doc.org/core-1.9.3/Dir.html#method-c-open

> Code: http://pastebin.com/uFtpji0H

Btw. using string interpolation for strings is superfluous and inefficient.

> My question to you is, why is this File.readable not working against
> folders? Is my code bad? Help me.

It is:

$ ruby -e 'p File.readable?(".")'
true

File.readable checks permissions but File.open checks the type of
filesystem object. That's not the same.

Cheers

robert

-- 
remember.guy do |as, often| as.you_can - without end
http://blog.rubybestpractices.com/