MCPcopy Create free account
hub / github.com/davidgiven/fluxengine / changeFilename

Method changeFilename

lib/vfs/cpmfs.cc:142–167  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

140 }
141
142 void changeFilename(const std::string& filename)
143 {
144 static std::regex FORMATTER("(?:(1?[0-9]):)?([^ .]+)\\.?([^ .]*)");
145 std::smatch results;
146 bool matched = std::regex_match(filename, results, FORMATTER);
147 if (!matched)
148 throw BadPathException();
149
150 std::string user = results[1];
151 std::string stem = results[2];
152 std::string ext = results[3];
153
154 if (stem.size() > 8)
155 throw BadPathException();
156 if (ext.size() > 3)
157 throw BadPathException();
158
159 this->user = std::stoi(user);
160 if (this->user > 15)
161 throw BadPathException();
162
163 if (ext.empty())
164 this->filename = stem;
165 else
166 this->filename = fmt::format("{}.{}", stem, ext);
167 }
168
169 std::string combinedFilename() const
170 {

Callers 2

putFileMethod · 0.80
moveFileMethod · 0.80

Calls 3

BadPathExceptionClass · 0.85
sizeMethod · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected