You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

46 lines
857B

  1. #include "util/common.hpp"
  2. #include <dirent.h>
  3. #if ARCH_WIN
  4. #include <windows.h>
  5. #include <shellapi.h>
  6. #endif
  7. namespace rack {
  8. std::vector<std::string> systemListDirectory(std::string path) {
  9. std::vector<std::string> filenames;
  10. DIR *dir = opendir(path.c_str());
  11. if (dir) {
  12. struct dirent *d;
  13. while ((d = readdir(dir))) {
  14. std::string filename = d->d_name;
  15. if (filename == "." || filename == "..")
  16. continue;
  17. filenames.push_back(path + "/" + filename);
  18. }
  19. closedir(dir);
  20. }
  21. return filenames;
  22. }
  23. void systemOpenBrowser(std::string url) {
  24. #if ARCH_LIN
  25. std::string command = "xdg-open " + url;
  26. (void) system(command.c_str());
  27. #endif
  28. #if ARCH_MAC
  29. std::string command = "open " + url;
  30. system(command.c_str());
  31. #endif
  32. #if ARCH_WIN
  33. ShellExecute(NULL, "open", url.c_str(), NULL, NULL, SW_SHOWNORMAL);
  34. #endif
  35. }
  36. } // namespace rack