Skip to content

Commit 55cb689

Browse files
authored
include colon in the characters prohibited for a filename (#5366)
1 parent 76fcccf commit 55cb689

2 files changed

Lines changed: 8 additions & 4 deletions

File tree

source/MRMesh/MRStringConvert.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ std::string bytesString( size_t size )
111111
bool hasProhibitedChars( const std::string& line )
112112
{
113113
for ( const auto& c : line )
114-
if ( c == '?' || c == '*' || c == '/' || c == '\\' || c == '"' || c == '<' || c == '>' )
114+
if ( isProhibitedChar( c ) )
115115
return true;
116116
return false;
117117
}
@@ -120,7 +120,7 @@ std::string replaceProhibitedChars( const std::string& line, char replacement /*
120120
{
121121
auto res = line;
122122
for ( auto& c : res )
123-
if ( c == '?' || c == '*' || c == '/' || c == '\\' || c == '"' || c == '<' || c == '>' )
123+
if ( isProhibitedChar( c ) )
124124
c = replacement;
125125
return res;
126126
}

source/MRMesh/MRStringConvert.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,10 +81,14 @@ std::string utf8string( const std::string & ) = delete;
8181
/// ...
8282
[[nodiscard]] MRMESH_API std::string bytesString( size_t size );
8383

84-
/// returns true if line contains any of OS prohibited chars ('?', '*', '/', '\', '"', '<', '>')
84+
/// returns true if the character is any of OS prohibited chars ('?', '*', '/', '\', '"', '<', '>', ':')
85+
[[nodiscard]] inline bool isProhibitedChar( char c )
86+
{ return c == '?' || c == '*' || c == '/' || c == '\\' || c == '"' || c == '<' || c == '>' || c == ':'; }
87+
88+
/// returns true if line contains at least one character (c) for which isProhibitedChar(c)==true
8589
[[nodiscard]] MRMESH_API bool hasProhibitedChars( const std::string& line );
8690

87-
/// replace OS prohibited chars ('?', '*', '/', '\', '"', '<', '>') with `replacement` char
91+
/// replace all characters (c), where isProhibitedChar(c)==true, with `replacement` char
8892
[[nodiscard]] MRMESH_API std::string replaceProhibitedChars( const std::string& line, char replacement = '_' );
8993

9094
/// if (v) contains an error, then appends given file name to that error

0 commit comments

Comments
 (0)