| 1378 | } |
| 1379 | |
| 1380 | void UIConsole::getFilesFrom( std::string txt, const Uint32& curPos ) { |
| 1381 | static char OSSlash = FileSystem::getOSSlash().at( 0 ); |
| 1382 | size_t pos; |
| 1383 | |
| 1384 | if ( std::string::npos != ( pos = txt.find_last_of( OSSlash ) ) && pos <= curPos ) { |
| 1385 | size_t fpos = txt.find_first_of( OSSlash ); |
| 1386 | |
| 1387 | std::string dir( txt.substr( fpos, pos - fpos + 1 ) ); |
| 1388 | std::string file( txt.substr( pos + 1 ) ); |
| 1389 | |
| 1390 | if ( FileSystem::isDirectory( dir ) ) { |
| 1391 | size_t count = 0, lasti = 0; |
| 1392 | std::vector<std::string> files = FileSystem::filesGetInPath( dir, true, true ); |
| 1393 | String res; |
| 1394 | bool again = false; |
| 1395 | |
| 1396 | do { |
| 1397 | std::vector<std::string> foundFiles; |
| 1398 | res = ""; |
| 1399 | count = 0; |
| 1400 | again = false; |
| 1401 | |
| 1402 | for ( size_t i = 0; i < files.size(); i++ ) { |
| 1403 | if ( !file.size() || String::startsWith( files[i], file ) ) { |
| 1404 | res += "\t" + files[i] + "\n"; |
| 1405 | count++; |
| 1406 | lasti = i; |
| 1407 | foundFiles.push_back( files[i] ); |
| 1408 | } |
| 1409 | } |
| 1410 | |
| 1411 | if ( count > 1 ) { |
| 1412 | bool allBigger = true; |
| 1413 | bool allStartsWith = true; |
| 1414 | |
| 1415 | do { |
| 1416 | allBigger = true; |
| 1417 | |
| 1418 | for ( size_t i = 0; i < foundFiles.size(); i++ ) { |
| 1419 | if ( foundFiles[i].size() < file.size() + 1 ) { |
| 1420 | allBigger = false; |
| 1421 | break; |
| 1422 | } |
| 1423 | } |
| 1424 | |
| 1425 | if ( allBigger ) { |
| 1426 | std::string tfile = foundFiles[0].substr( 0, file.size() + 1 ); |
| 1427 | allStartsWith = true; |
| 1428 | |
| 1429 | for ( size_t i = 0; i < foundFiles.size(); i++ ) { |
| 1430 | if ( !String::startsWith( foundFiles[i], tfile ) ) { |
| 1431 | allStartsWith = false; |
| 1432 | break; |
| 1433 | } |
| 1434 | } |
| 1435 | |
| 1436 | if ( allStartsWith ) { |
| 1437 | file = tfile; |
nothing calls this directly
no test coverage detected