MCPcopy Create free account
hub / github.com/DFHack/dfhack / is_safe_filename

Function is_safe_filename

plugins/orders.cpp:183–206  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

181}
182
183static bool is_safe_filename(color_ostream & out, const std::string & name)
184{
185 if (name.empty())
186 {
187 out << COLOR_LIGHTRED << "Missing filename!" << std::endl;
188 return false;
189 }
190
191 for (auto it : name)
192 {
193 if (isalnum(it))
194 {
195 continue;
196 }
197
198 if (it != ' ' && it != '.' && it != '-' && it != '_')
199 {
200 out << COLOR_LIGHTRED << "Invalid symbol in name: " << it << std::endl;
201 return false;
202 }
203 }
204
205 return true;
206}
207
208template<typename B>
209static void bitfield_to_json_array(Json::Value & out, B bits)

Callers 2

orders_export_commandFunction · 0.85
orders_import_commandFunction · 0.85

Calls 1

emptyMethod · 0.45

Tested by

no test coverage detected