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.

59 lines
2.0KB

  1. #pragma once
  2. #include <common.hpp>
  3. #include <list>
  4. namespace rack {
  5. /** Cross-platform functions for operating systems routines
  6. */
  7. namespace system {
  8. /** Returns a list of all entries (directories, files, symbols) in a directory. */
  9. std::list<std::string> getEntries(const std::string& path);
  10. /** Returns whether the given path is a file. */
  11. bool isFile(const std::string& path);
  12. /** Returns whether the given path is a directory. */
  13. bool isDirectory(const std::string& path);
  14. /** Moves a file. */
  15. void moveFile(const std::string& srcPath, const std::string& destPath);
  16. /** Copies a file. */
  17. void copyFile(const std::string& srcPath, const std::string& destPath);
  18. /** Creates a directory.
  19. The parent directory must exist.
  20. */
  21. void createDirectory(const std::string& path);
  22. /** Returns the number of logical simultaneous multithreading (SMT) (e.g. Intel Hyperthreaded) threads on the CPU. */
  23. int getLogicalCoreCount();
  24. /** Sets a name of the current thread for debuggers and OS-specific process viewers. */
  25. void setThreadName(const std::string& name);
  26. /** Sets the current thread to be high-priority. */
  27. void setThreadRealTime(bool realTime);
  28. /** Returns the number of seconds the current thread has been active. */
  29. double getThreadTime();
  30. /** Returns the caller's human-readable stack trace with "\n"-separated lines. */
  31. std::string getStackTrace();
  32. /** Opens a URL, also happens to work with PDFs and folders.
  33. Shell injection is possible, so make sure the URL is trusted or hard coded.
  34. May block, so open in a new thread.
  35. */
  36. void openBrowser(const std::string& url);
  37. /** Opens Windows Explorer, Finder, etc at the folder location. */
  38. void openFolder(const std::string& path);
  39. /** Runs an executable without blocking.
  40. The launched process will continue running if the current process is closed.
  41. */
  42. void runProcessDetached(const std::string& path);
  43. std::string getOperatingSystemInfo();
  44. /** Unzips a ZIP file to a folder.
  45. The folder must exist.
  46. Returns 0 if successful.
  47. */
  48. int unzipToFolder(const std::string& zipPath, const std::string& dir);
  49. } // namespace system
  50. } // namespace rack