CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
rapid7

CoCalc provides the best real-time collaborative environment for Jupyter Notebooks, LaTeX documents, and SageMath, scalable from individual users to large groups and classes!

GitHub Repository: rapid7/metasploit-framework
Path: blob/master/lib/metasploit/framework/compiler/headers/base.rb
Views: 1904
1
module Metasploit
2
module Framework
3
module Compiler
4
module Headers
5
class Base
6
7
attr_accessor :loaded_dep
8
9
# Initializes the Base class for headers.
10
def initialize
11
# This is used to avoid loading the same dependency code twice
12
@loaded_dep = []
13
end
14
15
# Returns the header source code.
16
#
17
# @param lib_name [String] The file name of the header.
18
# @return [String]
19
def include(lib_name)
20
lib = lib_dep_map[lib_name]
21
unless lib
22
raise RuntimeError, "#{lib_name} not found"
23
end
24
25
# Load the dependencies first, and only once
26
dep = ''
27
lib.each do |f|
28
unless loaded_dep.include?(f)
29
dep_path = File.join(headers_path, f)
30
dep << File.read(dep_path) << "\n"
31
loaded_dep << f
32
end
33
end
34
35
# Load the headers
36
lib_path = File.join(headers_path, lib_name)
37
"#{dep}#{File.read(lib_path)}"
38
end
39
40
end
41
end
42
end
43
end
44
end
45