Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions source/MRMesh/MRStringConvert.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ std::string bytesString( size_t size )
bool hasProhibitedChars( const std::string& line )
{
for ( const auto& c : line )
if ( c == '?' || c == '*' || c == '/' || c == '\\' || c == '"' || c == '<' || c == '>' )
if ( isProhibitedChar( c ) )
return true;
return false;
}
Expand All @@ -120,7 +120,7 @@ std::string replaceProhibitedChars( const std::string& line, char replacement /*
{
auto res = line;
for ( auto& c : res )
if ( c == '?' || c == '*' || c == '/' || c == '\\' || c == '"' || c == '<' || c == '>' )
if ( isProhibitedChar( c ) )
c = replacement;
return res;
}
Expand Down
8 changes: 6 additions & 2 deletions source/MRMesh/MRStringConvert.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,14 @@ std::string utf8string( const std::string & ) = delete;
/// ...
[[nodiscard]] MRMESH_API std::string bytesString( size_t size );

/// returns true if line contains any of OS prohibited chars ('?', '*', '/', '\', '"', '<', '>')
/// returns true if the character is any of OS prohibited chars ('?', '*', '/', '\', '"', '<', '>', ':')
[[nodiscard]] inline bool isProhibitedChar( char c )
{ return c == '?' || c == '*' || c == '/' || c == '\\' || c == '"' || c == '<' || c == '>' || c == ':'; }

/// returns true if line contains at least one character (c) for which isProhibitedChar(c)==true
[[nodiscard]] MRMESH_API bool hasProhibitedChars( const std::string& line );

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

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