MCPcopy Create free account
hub / github.com/apache/trafficserver / open_file

Function open_file

src/traffic_ctl/FileConfigCommand.cc:76–93  ·  view source on GitHub ↗

Function to open a file if it exists, if not and is requested we will create the file.

Source from the content-addressed store, hash-verified

74
75/// Function to open a file if it exists, if not and is requested we will create the file.
76std::string
77open_file(std::string const &filename, std::fstream &fs, std::ios_base::openmode mode = std::ios::in | std::ios::out,
78 bool create = false)
79{
80 fs.open(filename, mode);
81
82 if (!fs.is_open()) {
83 if (create) {
84 fs.clear();
85 if (fs.open(filename, std::ios::out); fs.is_open()) {
86 return {};
87 }
88 }
89 std::string text;
90 return swoc::bwprint(text, "We couldn't open '{}': {}", filename, strerror(errno));
91 }
92 return {};
93}
94
95/// Bunch of mapping flags for the TAGS.
96std::string

Callers 3

config_setMethod · 0.85
reopen_if_movedMethod · 0.85
check_fdMethod · 0.85

Calls 3

openMethod · 0.45
is_openMethod · 0.45
clearMethod · 0.45

Tested by

no test coverage detected