| 183 | } |
| 184 | |
| 185 | std::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 | |
| 215 | char * formatNoTrailingZeros( char * fmt, double v, int digitsAfterPoint, int precision ) |
| 216 | { |