File.hpp 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. /*
  2. * Author: Patrick-Christopher Mattulat
  3. * Company: Lynar Studios
  4. * E-Mail: webmaster@lynarstudios.com
  5. * Created: 2020-08-15
  6. * Changed: 2020-08-16
  7. *
  8. * */
  9. #ifndef FILE_HPP
  10. #define FILE_HPP
  11. #include "../base/Class.hpp"
  12. #include <string>
  13. #include <vector>
  14. namespace ls_std {
  15. class File : public Class {
  16. public:
  17. explicit File(std::string _absoluteFilePath);
  18. ~File() = default;
  19. // comparison operators
  20. bool operator==(File& _file);
  21. bool operator!=(File& _file);
  22. // additional functionality
  23. bool canExecute();
  24. void createNewFile();
  25. bool exists();
  26. std::string getAbsoluteFilePath();
  27. std::string getName();
  28. long getSize();
  29. bool isDirectory();
  30. bool isFile();
  31. void makeDirectory();
  32. void makeDirectories();
  33. void remove();
  34. private:
  35. std::string absoluteFilePath {};
  36. bool _exists(const std::string& _path);
  37. bool _isDirectory(const std::string& _path);
  38. bool _isFile(const std::string& _path);
  39. static int _mkdir(const std::string& _path);
  40. static std::string _normalizePath(std::string _path);
  41. static std::vector<std::string> _splitIntoSubDirectoryNames(const std::string& _path);
  42. };
  43. }
  44. #endif