| 371 | } |
| 372 | |
| 373 | std::unique_ptr< std::list<std::string> > DiskFile::FindFiles(std::string path, std::string wildcard, bool recursive) |
| 374 | { |
| 375 | // check path, if not ending with path separator, add one |
| 376 | char pathend = *path.rbegin(); |
| 377 | if (pathend != PATHSEP[0]) |
| 378 | { |
| 379 | path += PATHSEP; |
| 380 | } |
| 381 | std::list<std::string> *matches = new std::list<std::string>; |
| 382 | |
| 383 | std::wstring wwildcard = utf8::Utf8ToWide(path + wildcard); |
| 384 | WIN32_FIND_DATAW fd; |
| 385 | HANDLE h = ::FindFirstFileW(wwildcard.c_str(), &fd); |
| 386 | if (h != INVALID_HANDLE_VALUE) |
| 387 | { |
| 388 | do |
| 389 | { |
| 390 | if (0 == (fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) |
| 391 | { |
| 392 | matches->push_back(path + utf8::WideToUtf8(fd.cFileName)); |
| 393 | } |
| 394 | else if (recursive == true) |
| 395 | { |
| 396 | if (fd.cFileName[0] == '.') { |
| 397 | continue; |
| 398 | } |
| 399 | |
| 400 | std::string nwwildcard="*"; |
| 401 | std::unique_ptr< std::list<std::string> > dirmatches( |
| 402 | DiskFile::FindFiles(path + utf8::WideToUtf8(fd.cFileName), nwwildcard, true) |
| 403 | ); |
| 404 | |
| 405 | // append without requiring ordering |
| 406 | matches->splice(matches->end(), *dirmatches); |
| 407 | } |
| 408 | } while (::FindNextFileW(h, &fd)); |
| 409 | ::FindClose(h); |
| 410 | } |
| 411 | |
| 412 | return std::unique_ptr< std::list<std::string> >(matches); |
| 413 | } |
| 414 | |
| 415 | u64 DiskFile::GetFileSize(std::string filename) |
| 416 | { |
nothing calls this directly
no test coverage detected