filetools.h 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. #ifndef FILE_TOOLS_H
  2. #define FILE_TOOLS_H
  3. #include <string>
  4. #include <vector>
  5. #include "Strings.h"
  6. // collect files matching fn
  7. // if "recursive" also inspect subdirectories
  8. void fileList(const std::string& fn,
  9. std::vector<std::string>& files,
  10. bool recursive = false);
  11. void dirList(const std::string& fn,
  12. std::vector<std::string>& dirs,
  13. bool recursive = false);
  14. // read list of files from commandline
  15. // if "recursive" expand directories to list of files
  16. void fileList(int argc, char** argv, int optind,
  17. std::vector<std::string>& files,
  18. bool recursive = false);
  19. void strings2File(const std::vector<std::string>& s, const std::string& fn);
  20. void file2Strings(const std::string& fn, std::vector<std::string>& s);
  21. bool dirExists(const std::string& name);
  22. bool fileExists(const std::string& name);
  23. Strings myPopen(const std::string& cmd,
  24. int& rc, bool debug,
  25. const std::string& logfn = "");
  26. void removeLock(const std::string& lockfilename);
  27. void createLock(const std::string& lockfilename);
  28. #endif