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.

60 lines
2.1KB

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