CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
rapid7

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.

GitHub Repository: rapid7/metasploit-framework
Path: blob/master/lib/rex/ui/text/output/file.rb
Views: 11704
1
# -*- coding: binary -*-
2
3
module Rex
4
module Ui
5
module Text
6
7
###
8
#
9
# This class implements output against a file
10
#
11
###
12
class Output::File < Rex::Ui::Text::Output
13
14
attr_accessor :fd
15
16
def initialize(path, mode='wb')
17
self.fd = ::File.open(path, mode)
18
end
19
20
def supports_color?
21
false
22
end
23
24
#
25
# Prints the supplied message to file output.
26
#
27
def print_raw(msg = '')
28
return if not self.fd
29
self.fd.write(msg)
30
self.fd.flush
31
msg
32
end
33
alias_method :write, :print_raw
34
35
def close
36
self.fd.close if self.fd
37
self.fd = nil
38
end
39
end
40
41
end
42
end
43
end
44
45
46