Top Level Namespace
Defined Under Namespace
Modules: Qdumpfs, QdumpfsFind, QdumpfsUtils Classes: File
Instance Method Summary collapse
-
#which(cmd) ⇒ Object
stackoverflow.com/questions/2108727/which-in-ruby-checking-if-program-exists-in-path-from-ruby Cross-platform way of finding an executable in the $PATH.
- #windows? ⇒ Boolean
- #wprintf(format, *args) ⇒ Object
Instance Method Details
#which(cmd) ⇒ Object
stackoverflow.com/questions/2108727/which-in-ruby-checking-if-program-exists-in-path-from-ruby Cross-platform way of finding an executable in the $PATH.
which('ruby') #=> /usr/bin/ruby
13 14 15 16 17 18 19 20 21 22 |
# File 'lib/qdumpfs/util.rb', line 13 def which(cmd) exts = ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : [''] ENV['PATH'].split(File::PATH_SEPARATOR).each do |path| exts.each do |ext| exe = File.join(path, "#{cmd}#{ext}") return exe if File.executable?(exe) && !File.directory?(exe) end end nil end |
#windows? ⇒ Boolean
3 4 5 |
# File 'lib/qdumpfs/win32.rb', line 3 def windows? /mswin32|cygwin|mingw|bccwin/.match(RUBY_PLATFORM) end |
#wprintf(format, *args) ⇒ Object
5 6 7 |
# File 'lib/qdumpfs/util.rb', line 5 def wprintf(format, *args) STDERR.printf("pdumpfs: " + format + "\n", *args) end |