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 932B

123456789101112131415161718192021222324252627282930313233343536373839
  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 prefix;
  19. std::string *output = nullptr;
  20. };
  21. std::string sanitizePath(const std::string &path);
  22. FileInfo fileInfo(const std::string &path);
  23. bool fileExists(const std::string &path);
  24. void mkdirp(const std::string &path);
  25. void rmrf(const std::string &path);
  26. void execute(const std::vector<std::string> &args, const ProcConf &conf);
  27. void readDir(const std::string &path, std::vector<std::string> &files);
  28. void chdir(const std::string &path);
  29. std::string cwd();
  30. void symlink(const std::string &from, const std::string &to);
  31. std::string dirname(const std::string &path);
  32. }