Module: Metasploit::Model::File
- Defined in:
- lib/metasploit/model/file.rb
Overview
Re-implement methods on ruby's File that are buggy in JRuby so that the platform specific logic can be in this module instead of everywhere these methods are used.
Class Method Summary collapse
-
.method_missing(method_name, *args, &block) ⇒ Object
Delegates to
::File
if::File
supports the method when File does not implement an override to fix different platform incompatibilities. -
.realpath(path) ⇒ String
On JRuby, File.realpath does not resolve symlinks, so need to drop to Java to get the real path.
-
.respond_to?(method_name, include_private = false) ⇒ Boolean
Whether this module or
::File
responds tomethod_name
.
Class Method Details
.method_missing(method_name, *args, &block) ⇒ Object
Delegates to ::File
if ::File
supports the method when Metasploit::Model::File does not implement an
override to fix different platform incompatibilities.
30 31 32 33 34 35 36 |
# File 'lib/metasploit/model/file.rb', line 30 def method_missing(method_name, *args, &block) if ::File.respond_to?(method_name) ::File.public_send(method_name, *args, &block) else super end end |
.realpath(path) ⇒ String
On JRuby, File.realpath does not resolve symlinks, so need to drop to Java to get the real path.
16 17 18 19 20 |
# File 'lib/metasploit/model/file.rb', line 16 def self.realpath(path) file = java.io.File.new(path) file.canonical_path end |
.respond_to?(method_name, include_private = false) ⇒ Boolean
Whether this module or ::File
responds to method_name
.
43 44 45 |
# File 'lib/metasploit/model/file.rb', line 43 def respond_to?(method_name, include_private=false) ::File.respond_to?(method_name, include_private) || super end |