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.

64 lines
2.2KB

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