FIX Pathname.rename
Rename relative to self.dirname
This commit is contained in:
parent
b32d2044c5
commit
3cf869385e
@ -14,7 +14,7 @@
|
|||||||
#
|
#
|
||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
||||||
# along with Homebrew. If not, see <http://www.gnu.org/licenses/>.
|
# along with Homebrew. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
#
|
||||||
require 'pathname'
|
require 'pathname'
|
||||||
|
|
||||||
# we enhance pathname to make our code more readable
|
# we enhance pathname to make our code more readable
|
||||||
@ -23,9 +23,10 @@ class Pathname
|
|||||||
FileUtils.mv to_s, dst
|
FileUtils.mv to_s, dst
|
||||||
end
|
end
|
||||||
|
|
||||||
def rename dst
|
def rename newname
|
||||||
dst=Pathname.new dst
|
raise unless file?
|
||||||
dst.unlink if dst.exist?
|
dst=dirname+newname
|
||||||
|
dst.unlink rescue nil
|
||||||
mv dst
|
mv dst
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user