Issue #6811 has been reported by prijutme4ty (Ilya Vorontsov). ---------------------------------------- Feature #6811: File, Dir and FileUtils should have bang-versions of singleton methods that fails silently https://bugs.ruby-lang.org/issues/6811 Author: prijutme4ty (Ilya Vorontsov) Status: Open Priority: Normal Assignee: Category: Target version: I found that often write Dir.mkdir(folder) unless Dir.exist? folder and similar code for rm, rm_rf and so on We can simply make bang-versions like def Dir.mkdir!(folder, permissions=0744) Dir.mkdir(folder, permissions) unless Dir.exist? folder # or another alternative Dir.mkdir(folder, permissions) rescue false end
[ruby-trunk - Feature #6811][Open] File, Dir and FileUtils should have bang-versions of singleton me
on 2012-07-29 13:38
on 2012-07-29 15:33
Issue #6811 has been updated by trans (Thomas Sawyer). At least for mkdir you can use mkdir_p, although it annoyingly warns about missing path if $VERBOSE=true (can we consider that a bug please?). ---------------------------------------- Feature #6811: File, Dir and FileUtils should have bang-versions of singleton methods that fails silently https://bugs.ruby-lang.org/issues/6811#change-28533 Author: prijutme4ty (Ilya Vorontsov) Status: Open Priority: Normal Assignee: Category: Target version: I found that often write Dir.mkdir(folder) unless Dir.exist? folder and similar code for rm, rm_rf and so on We can simply make bang-versions like def Dir.mkdir!(folder, permissions=0744) Dir.mkdir(folder, permissions) unless Dir.exist? folder # or another alternative Dir.mkdir(folder, permissions) rescue false end
on 2012-07-29 17:27
Issue #6811 has been updated by Eregon (Benoit Daloze). prijutme4ty (Ilya Vorontsov) wrote: > I found that often write > Dir.mkdir(folder) unless Dir.exist? folder > and similar code for rm, rm_rf and so on Bang methods are not usually used for that in Ruby core and stdlib. I agree for the practical point of view of this though. I'm unsure what a good name would be. Using mkdir_p for this seems a bit dangerous, as it might create intermediary directories you did not intend to. trans wrote: > although it annoyingly warns about missing path if $VERBOSE=true (can we consider that a bug please?). How so? ---------------------------------------- Feature #6811: File, Dir and FileUtils should have bang-versions of singleton methods that fails silently https://bugs.ruby-lang.org/issues/6811#change-28537 Author: prijutme4ty (Ilya Vorontsov) Status: Open Priority: Normal Assignee: Category: Target version: I found that often write Dir.mkdir(folder) unless Dir.exist? folder and similar code for rm, rm_rf and so on We can simply make bang-versions like def Dir.mkdir!(folder, permissions=0744) Dir.mkdir(folder, permissions) unless Dir.exist? folder # or another alternative Dir.mkdir(folder, permissions) rescue false end
on 2012-07-29 20:08
Issue #6811 has been updated by trans (Thomas Sawyer). Sorry, it is if $DEBUG = true, not $VERBOSE. Here's the issue: > FileUtils.mkdir_p('a/b/c/d') Exception `Errno::ENOENT' at /home/trans/.local/lib/ry/rubies/1.9.3-p125/lib/ruby/1.9.1/fileutils.rb:247 - No such file or directory - a/b/c/d Exception `Errno::EEXIST' at /home/trans/.local/lib/ry/rubies/1.9.3-p125/lib/ruby/1.9.1/fileutils.rb:247 - File exists - . => ["a/b/c/d"] It the most annoying warning, and I always end-up writing my own method instead. ---------------------------------------- Feature #6811: File, Dir and FileUtils should have bang-versions of singleton methods that fails silently https://bugs.ruby-lang.org/issues/6811#change-28540 Author: prijutme4ty (Ilya Vorontsov) Status: Open Priority: Normal Assignee: Category: Target version: I found that often write Dir.mkdir(folder) unless Dir.exist? folder and similar code for rm, rm_rf and so on We can simply make bang-versions like def Dir.mkdir!(folder, permissions=0744) Dir.mkdir(folder, permissions) unless Dir.exist? folder # or another alternative Dir.mkdir(folder, permissions) rescue false end
Re: [ruby-trunk - Feature #6811] File, Dir and FileUtils should have bang-versions of singleton meth
on 2012-07-29 20:27
On 29 July 2012 20:07, trans (Thomas Sawyer) <transfire@gmail.com> wrote: > Sorry, it is if $DEBUG = true, not $VERBOSE. > > Here's the issue: > >> FileUtils.mkdir_p('a/b/c/d') > Exception `Errno::ENOENT' at /home/trans/.local/lib/ry/rubies/1.9.3-p125/lib/ruby/1.9.1/fileutils.rb:247 - No such file or directory - a/b/c/d > Exception `Errno::EEXIST' at /home/trans/.local/lib/ry/rubies/1.9.3-p125/lib/ruby/1.9.1/fileutils.rb:247 - File exists - . > => ["a/b/c/d"] > > It the most annoying warning, and I always end-up writing my own method instead. Ah, I see, this is due to the exception-driven implementation of FileUtils. I think it would be worth discussing it in a separate issue.
on 2012-11-19 22:42
Issue #6811 has been updated by boris_stitnicky (Boris Stitnicky). First, let me apologize to everyone for expressing opinion, while having relatively little experience. I like your proposal, but I am concerned about feature creep. Maybe those convenience features should go to stdlib, just like eg. require 'mathn' changes math behavior, we could have require 'fileboost' or something making FileUtils fatter. I think that in the future, there will be many amazing proposals for FileUtils functionality, like yours here, so the best of them could go to this 'fileboost' or whatever other name would it have. ---------------------------------------- Feature #6811: File, Dir and FileUtils should have bang-versions of singleton methods that fails silently https://bugs.ruby-lang.org/issues/6811#change-33128 Author: prijutme4ty (Ilya Vorontsov) Status: Open Priority: Normal Assignee: Category: Target version: I found that often write Dir.mkdir(folder) unless Dir.exist? folder and similar code for rm, rm_rf and so on We can simply make bang-versions like def Dir.mkdir!(folder, permissions=0744) Dir.mkdir(folder, permissions) unless Dir.exist? folder # or another alternative Dir.mkdir(folder, permissions) rescue false end
[ruby-trunk - Feature #6811][Assigned] File, Dir and FileUtils should have bang-versions of singleto
on 2012-11-24 03:19
Issue #6811 has been updated by mame (Yusuke Endoh). Status changed from Open to Assigned Assignee set to matz (Yukihiro Matsumoto) Target version set to next minor ---------------------------------------- Feature #6811: File, Dir and FileUtils should have bang-versions of singleton methods that fails silently https://bugs.ruby-lang.org/issues/6811#change-33737 Author: prijutme4ty (Ilya Vorontsov) Status: Assigned Priority: Normal Assignee: matz (Yukihiro Matsumoto) Category: Target version: next minor I found that often write Dir.mkdir(folder) unless Dir.exist? folder and similar code for rm, rm_rf and so on We can simply make bang-versions like def Dir.mkdir!(folder, permissions=0744) Dir.mkdir(folder, permissions) unless Dir.exist? folder # or another alternative Dir.mkdir(folder, permissions) rescue false end
Please log in before posting. Registration is free and takes only a minute.
Existing account
(Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
Log in with Google account | Log in with Yahoo account
No account? Register here.