lib/ratch/fileutils.rb in ratch-0.2.2 vs lib/ratch/fileutils.rb in ratch-0.2.3
- old
+ new
@@ -1,6 +1,30 @@
+# TITLE:
+#
+# FileUtils
+#
+# COPYING:
+#
+# Copyright (c) 2007 Psi T Corp.
+#
+# This file is part of the ProUtils' Ratch program.
+#
+# Ratch is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# Ratch is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with Ratch. If not, see <http://www.gnu.org/licenses/>.
+
require 'fileutils'
+require 'ratch/facets/multiglob'
module Ratch
module FileUtils
@@ -9,10 +33,18 @@
def glob(*args, &blk)
Dir.glob(*args, &blk)
end
+ def multiglob(*args, &blk)
+ Dir.multiglob(*args, &blk)
+ end
+
+ def multiglob_r(*args, &blk)
+ Dir.multiglob_r(*args, &blk)
+ end
+
# Read file.
def file_read(path)
File.read(path)
end
@@ -128,18 +160,18 @@
abort "path not found #{path}" unless paths.any?{|path| exists?(path)}
end
alias_method :exist!, :exists! ; module_function :exist!
alias_method :path!, :exists! ; module_function :path!
- # Is a file a task?
+# # Is a file a task?
+#
+# def task?(path)
+# task = File.dirname($0) + "/#{path}"
+# task.chomp!('!')
+# task if FileTest.file?(task) && FileTest.executable?(task)
+# end
- def task?(path)
- task = File.dirname($0) + "/#{path}"
- task.chomp!('!')
- task if FileTest.file?(task) && FileTest.executable?(task)
- end
-
# Is a file a command executable?
#
# TODO Probably needs to be fixed for Windows.
def bin?(path)
@@ -150,10 +182,10 @@
end
# This is a support method of #bin?
def command_paths
- @command_paths ||= ENV['PATH'].split(':')
+ @command_paths ||= ENV['PATH'].split(/[:;]/)
end
# TODO Make more robust.
UNSAFE = [ '/', '/*', '/**/*' ]