From: Michael D. Lowis Date: Thu, 20 Jul 2017 01:13:34 +0000 (-0400) Subject: updated tide-fetch to use find command instead of Dir.glob for performance. Also... X-Git-Url: https://git.mdlowis.com/?a=commitdiff_plain;h=f4ed00f77f453b0b6db93872c4e7d35d663f8c0c;p=projs%2Ftide.git updated tide-fetch to use find command instead of Dir.glob for performance. Also expands tilde now --- diff --git a/tide-fetch.rb b/tide-fetch.rb index 5fcfc6d..d2f864f 100755 --- a/tide-fetch.rb +++ b/tide-fetch.rb @@ -42,18 +42,13 @@ def open_with(app) spawn("#{app} #{$item}") end -def find_files(file) - if file.match(/^\.?\//) - files = [file] - else - files = Dir.glob("**/#{file}").sort_by(&:length) - end - raise RuleError.new() if files.length == 0 - files -end - def find_file(file) - find_files(file).first + file = file.gsub(/^~/, ENV["HOME"]) + if not file.match(/^\.?\//) + file = `find . -path '*#{file}' -print -quit`.chomp + end + raise RuleError.new() if (file.length == 0 || (not File.exist?(file))) + file end def mimetype(regex)