2
0

CFileInfo.h 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. #pragma once
  2. /*
  3. * CFileInfo.h, part of VCMI engine
  4. *
  5. * Authors: listed in file AUTHORS in main folder
  6. *
  7. * License: GNU General Public License v2.0 or later
  8. * Full text of license available in license.txt file, in main folder
  9. *
  10. */
  11. #include "ResourceID.h"
  12. /**
  13. * A class which holds information about a file.
  14. */
  15. class DLL_LINKAGE CFileInfo
  16. {
  17. public:
  18. /**
  19. * Default ctor.
  20. */
  21. CFileInfo();
  22. /**
  23. * Ctor.
  24. *
  25. * @param name The path and name of the file.
  26. */
  27. explicit CFileInfo(std::string name);
  28. /**
  29. * Checks if the file exists.
  30. *
  31. * @return true if the file exists, false if not.
  32. */
  33. bool exists() const;
  34. /**
  35. * Checks if the file is a directory.
  36. *
  37. * @return true if the file is a directory, false if not.
  38. */
  39. bool isDirectory() const;
  40. /**
  41. * Sets the name.
  42. *
  43. * @param name The name of the file
  44. */
  45. void setName(const std::string & name);
  46. /**
  47. * Gets the name of the file.
  48. *
  49. * @return the path and name of the file. E.g. ./dir/file.ext
  50. */
  51. std::string getName() const;
  52. /**
  53. * Gets the path to the file only.
  54. *
  55. * @return the path to the file only. E.g. ./dir/
  56. */
  57. std::string getPath() const;
  58. /**
  59. * Gets the file extension.
  60. *
  61. * @return the file extension. E.g. .ext
  62. */
  63. std::string getExtension() const;
  64. /**
  65. * Returns the name of the file.
  66. *
  67. * @return the name of the file. E.g. foo.txt
  68. */
  69. std::string getFilename() const;
  70. /**
  71. * Gets the file name + path exclusive the extension of the file.
  72. *
  73. * @return the file name exclusive the extension of the file. E.g. ./dir/foo
  74. */
  75. std::string getStem() const;
  76. /**
  77. * Gets the file name exclusive the extension of the file.
  78. *
  79. * @return the file name exclusive the extension and a path of the file. E.g. foo
  80. */
  81. std::string getBaseName() const;
  82. /**
  83. * Gets the extension type as a EResType enumeration.
  84. *
  85. * @return the extension type as a EResType enumeration.
  86. */
  87. EResType::Type getType() const;
  88. /**
  89. * Gets the timestamp of the file.
  90. *
  91. * @return the timestamp of the file, 0 if no timestamp was set
  92. */
  93. std::time_t getDate() const;
  94. private:
  95. /** Contains the original URI(not modified) e.g. ./dir/foo.txt */
  96. std::string name;
  97. };