Add Windows OS detection

This commit is contained in:
ethicalhack3r
2016-01-03 20:15:11 +01:00
parent 9df8cc9243
commit 3be5e1fcf5
2 changed files with 13 additions and 4 deletions

View File

@@ -42,6 +42,11 @@ def kali_linux?
end
end
# Determins if installed on Windows OS
def windows?
Gem.win_platform?
end
require 'environment'
def escape_glob(s)
@@ -223,7 +228,11 @@ end
#
# @return [ Integer ] The number of lines in the given file
def count_file_lines(file)
`wc -l #{file.shellescape}`.split[0].to_i
if windows?
`findstr /R /N "^" #{file.shellescape} | find /C ":"`.split[0].to_i
else
`wc -l #{file.shellescape}`.split[0].to_i
end
end
# Truncates a string to a specific length and adds ... at the end