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():
You can test if the "filename" is a file with File::file?
Look at a modified version of your pastebin.
Abinoam Jr.
···
On Tue, Jan 28, 2014 at 2:50 PM, Robert Klemme <shortcutter@googlemail.com> wrote:
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(): Class: Dir (Ruby 1.9.3)
I'd like to thank all of you for answering my question, it looks like
I'm still far away from being able to create my own programs because I'm
still a newbie in ruby.