| 5182 | static const char *invalid_filename_characters[] = { ":", "/", "\\", "?", "*", "\"", "|", "%", "<", ">" }; |
| 5183 | |
| 5184 | bool String::is_valid_filename() const { |
| 5185 | String stripped = strip_edges(); |
| 5186 | if (*this != stripped) { |
| 5187 | return false; |
| 5188 | } |
| 5189 | |
| 5190 | if (stripped.is_empty()) { |
| 5191 | return false; |
| 5192 | } |
| 5193 | |
| 5194 | for (const char *ch : invalid_filename_characters) { |
| 5195 | if (contains(ch)) { |
| 5196 | return false; |
| 5197 | } |
| 5198 | } |
| 5199 | return true; |
| 5200 | } |
| 5201 | |
| 5202 | String String::validate_filename() const { |
| 5203 | String name = strip_edges(); |
no test coverage detected