MCPcopy Create free account
hub / github.com/MeshInspector/MeshLib / commonFilesName

Function commonFilesName

source/MRMesh/MRStringConvert.cpp:185–213  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

183}
184
185std::string commonFilesName( const std::vector<std::filesystem::path> & files )
186{
187 if ( files.empty() )
188 return "Empty";
189
190 if ( std::all_of( files.begin(), files.end(), [&] ( auto&& path ) { std::error_code ec; return is_directory( path, ec ); } ) )
191 {
192 return files.size() == 1 ? "Directory" : "Directories";
193 }
194
195 auto getUpperExt = []( const std::filesystem::path & file )
196 {
197 auto ext = utf8string( file.extension() );
198 for ( auto& c : ext )
199 c = ( char )toupper( c );
200 return ext;
201 };
202
203 auto commonExt = getUpperExt( files[0] );
204 if ( files.size() == 1 )
205 return commonExt;
206
207 for ( int i = 1; i < files.size(); ++i )
208 if ( commonExt != getUpperExt( files[i] ) )
209 return "Files";
210
211 commonExt += 's';
212 return commonExt;
213}
214
215char * formatNoTrailingZeros( char * fmt, double v, int digitsAfterPoint, int precision )
216{

Callers 1

loadFilesMethod · 0.85

Calls 5

utf8stringFunction · 0.85
emptyMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected