Merge branch 'master' of github.com:rapid7/metasploit-framework

unstable
sinn3r 2012-02-02 16:53:38 -06:00
commit f677f51319
2 changed files with 10 additions and 3 deletions

View File

@ -307,6 +307,7 @@ class Console::CommandDispatcher::Stdapi::Fs
path = args[0] || client.fs.dir.getwd
tbl = Rex::Ui::Text::Table.new(
'Header' => "Listing: #{path}",
'SortIndex' => 4,
'Columns' =>
[
'Mode',
@ -319,7 +320,8 @@ class Console::CommandDispatcher::Stdapi::Fs
items = 0
# Enumerate each item...
client.fs.dir.entries_with_info(path).sort { |a,b| a['FileName'] <=> b['FileName'] }.each { |p|
# No need to sort as Table will do it for us
client.fs.dir.entries_with_info(path).each { |p|
tbl <<
[

View File

@ -68,6 +68,8 @@ class Table
self.postfix = opts['Postfix'] || ''
self.colprops = []
self.sort_index = opts['SortIndex'] || 0
# Default column properties
self.columns.length.times { |idx|
self.colprops[idx] = {}
@ -100,7 +102,7 @@ class Table
str << columns_to_s || ''
str << hr_to_s || ''
sort_rows(0)
sort_rows
rows.each { |row|
if (is_hr(row))
str << hr_to_s
@ -180,7 +182,7 @@ class Table
# If the supplied index is an IPv4 address, handle it differently, but
# avoid actually resolving domain names.
#
def sort_rows(index=0)
def sort_rows(index=sort_index)
return unless rows
rows.sort! do |a,b|
if a[index].nil?
@ -189,6 +191,8 @@ class Table
1
elsif Rex::Socket.dotted_ip?(a[index]) and Rex::Socket.dotted_ip?(b[index])
Rex::Socket::addr_atoi(a[index]) <=> Rex::Socket::addr_atoi(b[index])
elsif a[index] =~ /^[0-9]+$/ and b[index] =~ /^[0-9]+$/
a[index].to_i <=> b[index].to_i
else
a[index] <=> b[index] # assumes otherwise comparable.
end
@ -208,6 +212,7 @@ class Table
attr_accessor :columns, :rows, :colprops # :nodoc:
attr_accessor :width, :indent, :cellpad # :nodoc:
attr_accessor :prefix, :postfix # :nodoc:
attr_accessor :sort_index # :nodoc:
protected