Build tool
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.

sys.h 911B

1234567891011121314151617181920212223242526272829303132333435363738
  1. #pragma once
  2. #include <string>
  3. #include <vector>
  4. #include <fstream>
  5. namespace sys {
  6. struct FileInfo {
  7. long mTimeSec;
  8. long mTimeNsec;
  9. bool isDir;
  10. bool isOlderThan(FileInfo &f) {
  11. return mTimeSec < f.mTimeSec ||
  12. (mTimeSec == f.mTimeSec && mTimeNsec < f.mTimeNsec);
  13. }
  14. };
  15. struct ProcConf {
  16. bool print = false;
  17. bool forwardSignals = false;
  18. std::string *output = nullptr;
  19. };
  20. std::string sanitizePath(const std::string &path);
  21. FileInfo fileInfo(const std::string &path);
  22. bool fileExists(const std::string &path);
  23. void mkdirp(const std::string &path);
  24. void rmrf(const std::string &path);
  25. void execute(const std::vector<std::string> &args, const ProcConf &conf);
  26. void readDir(const std::string &path, std::vector<std::string> &files);
  27. void chdir(const std::string &path);
  28. std::string cwd();
  29. void symlink(const std::string &from, const std::string &to);
  30. std::string dirname(const std::string &path);
  31. }