windows_find_file.cpp 727 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. #include<__vic/windows/find_file.h>
  2. #include<__vic/windows/wchar.h>
  3. #include<iostream>
  4. #include<exception>
  5. #include<cassert>
  6. namespace tests {
  7. void list(LPCTSTR path)
  8. {
  9. __vic::windows::FindFile ff;
  10. if(!ff.FindFirst(path)) return;
  11. do {
  12. std::cout <<
  13. #ifdef UNICODE
  14. __vic::windows::utf16to8
  15. #endif
  16. (ff.cFileName) << '\n';
  17. } while(ff.FindNext());
  18. }
  19. void run()
  20. {
  21. std::cout << "All files:\n";
  22. list(TEXT(".\\*"));
  23. std::cout << "\n*.cpp files:\n";
  24. list(TEXT(".\\*.cpp"));
  25. }
  26. } // namespace
  27. int main()
  28. {
  29. try
  30. {
  31. tests::run();
  32. return 0;
  33. }
  34. catch(const std::exception &ex)
  35. {
  36. std::cerr << ex.what() << '\n';
  37. }
  38. return 1;
  39. }