Feature #7361

Adding Pathname#touch

Added by Alexander E. Fischer over 2 years ago. Updated 3 months ago.

[ruby-core:49374]
Status:Assigned
Priority:Normal
Assignee:Akira Tanaka

Description

Pathname has an #mkdir method to create a directory at the path, but does not have a #touch method to create an empty file at that path.

There were numerous cases where I had to fallback to using

new_file = Pathname.new('location/for/new/file')
FileUtils.touch(new_file)

instead of simply being able to use:

new_file.touch

I would like to add this method. If you like it, let me know. I will provide a patch then.


Related issues

Related to Ruby trunk - Feature #7378: Adding Pathname#write Closed 06/02/2012

History

#1 Updated by Yusuke Endoh over 2 years ago

  • Status changed from Open to Assigned
  • Assignee set to Akira Tanaka
  • Target version set to next minor

#2 Updated by Ben Rexin 3 months ago

Any way i can help?

#3 Updated by Daniel Berger 3 months ago

I'm a little surprise there isn't an option for this in FileUtils. Something like FileUtils.touch('/location/for/new', :force => true). I'd be in favor of adding that, or an option to FileUtils.mkpath.

Also available in: Atom PDF