Skip to content

Commit 2d1fd1c

Browse files
committed
Pass file size to read for faster reads on Windows
1 parent ef6dad2 commit 2d1fd1c

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

lib/msf/core/modules/loader/directory.rb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,11 @@ def read_module_content(parent_path, type, module_reference_name)
7777

7878
# force to read in binary mode so Pro modules won't be truncated on Windows
7979
File.open(full_path, 'rb') do |f|
80-
module_content = f.read
80+
# Pass the size of the file as it leads to faster reads due to fewer buffer resizes. Greatest effect on Windows.
81+
# @see http://www.ruby-forum.com/topic/209005
82+
# @see https://github.com/ruby/ruby/blob/ruby_1_8_7/io.c#L1205
83+
# @see https://github.com/ruby/ruby/blob/ruby_1_9_3/io.c#L2038
84+
module_content = f.read(f.stat.size)
8185
end
8286

8387
module_content

0 commit comments

Comments
 (0)