Last active
August 29, 2015 14:08
-
-
Save sbotman/1a79c129955fe1b413af to your computer and use it in GitHub Desktop.
Windows Ruby Functions
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def win_friendly_path(path) | |
if path | |
new_path = path.gsub('/', '\\') | |
new_path = "c:#{new_path}" if new_path =~ /^\\/ | |
end | |
new_path | |
end | |
def recursive_file_search(location, target) | |
Dir.entries(location).each do |entry| | |
begin | |
if File.directory?(File.join(location,entry)) | |
next if entry == "\." || entry == "\.\." | |
sub = File.join(location, entry) | |
recursive_file_search(sub, target) | |
end | |
if entry =~ /target/ | |
puts File.join(location, target) | |
end | |
rescue | |
# printf("Cannot open: %s\n", location) | |
end | |
end | |
end | |
recursive_file_search(win_friendly_path('c:\\'), "cmd.exe") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment