assetScanFolderInfo.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. /*
  2. * Copyright (c) Contributors to the Open 3D Engine Project.
  3. * For complete copyright and license terms please see the LICENSE at the root of this distribution.
  4. *
  5. * SPDX-License-Identifier: Apache-2.0 OR MIT
  6. *
  7. */
  8. #ifndef ASSETSCANFOLDERINFO_H
  9. #define ASSETSCANFOLDERINFO_H
  10. #include <QString>
  11. #include <QDateTime>
  12. #include <AzCore/base.h>
  13. #include <AssetBuilderSDK/AssetBuilderSDK.h>
  14. namespace AssetProcessor
  15. {
  16. /** This Class contains information about the folders to be scanned
  17. * */
  18. class ScanFolderInfo
  19. {
  20. public:
  21. ScanFolderInfo(
  22. QString path,
  23. QString displayName,
  24. QString portableKey,
  25. bool isRoot,
  26. bool recurseSubFolders,
  27. AZStd::vector<AssetBuilderSDK::PlatformInfo> platforms = AZStd::vector<AssetBuilderSDK::PlatformInfo>{},
  28. int order = 0,
  29. AZ::s64 scanFolderID = 0,
  30. bool canSaveNewAssets = false);
  31. ScanFolderInfo() = default;
  32. ScanFolderInfo(const ScanFolderInfo& other) = default;
  33. QString ScanPath() const
  34. {
  35. return m_scanPath;
  36. }
  37. QString GetDisplayName() const
  38. {
  39. return m_displayName;
  40. }
  41. bool IsRoot() const
  42. {
  43. return m_isRoot;
  44. }
  45. bool RecurseSubFolders() const
  46. {
  47. return m_recurseSubFolders;
  48. }
  49. bool CanSaveNewAssets() const
  50. {
  51. return m_canSaveNewAssets;
  52. }
  53. int GetOrder() const
  54. {
  55. return m_order;
  56. }
  57. AZ::s64 ScanFolderID() const
  58. {
  59. return m_scanFolderID;
  60. }
  61. QString GetPortableKey() const
  62. {
  63. return m_portableKey;
  64. }
  65. const AZStd::vector<AssetBuilderSDK::PlatformInfo>& GetPlatforms() const
  66. {
  67. return m_platforms;
  68. }
  69. void SetScanFolderID(AZ::s64 scanFolderID)
  70. {
  71. m_scanFolderID = scanFolderID;
  72. }
  73. private:
  74. QString m_scanPath; // the local path to scan ("C:\\whatever")
  75. QString m_displayName; // the display name to show in GUIs that show it.
  76. QString m_portableKey; // a key that remains the same even if the asset database is moved from computer to computer.
  77. bool m_isRoot = false; // is it 'the' root folder?
  78. bool m_recurseSubFolders = true;
  79. bool m_canSaveNewAssets = false; // Tracks if it is safe to save new assets in this folder.
  80. int m_order = 0;
  81. AZ::s64 m_scanFolderID = 0; // this is filled in by the database - don't modify it.
  82. AZStd::vector<AssetBuilderSDK::PlatformInfo> m_platforms; // This contains the list of platforms that are enabled for the particular scanfolder
  83. };
  84. struct AssetFileInfo
  85. {
  86. AssetFileInfo() = default;
  87. AssetFileInfo(QString filePath, QDateTime modTime, AZ::u64 fileSize, const ScanFolderInfo* scanFolder, bool isDirectory)
  88. : m_filePath(filePath), m_modTime(modTime), m_fileSize(fileSize), m_scanFolder(scanFolder), m_isDirectory(isDirectory) {}
  89. bool operator==(const AssetFileInfo& rhs) const
  90. {
  91. return m_filePath == rhs.m_filePath
  92. && m_modTime == rhs.m_modTime
  93. && m_fileSize == rhs.m_fileSize
  94. && m_isDirectory == rhs.m_isDirectory;
  95. // m_scanFolder ignored since m_filePath will already ensure this is the same file
  96. }
  97. QString m_filePath{}; // Absolute path of the file
  98. QDateTime m_modTime{};
  99. AZ::u64 m_fileSize{};
  100. const ScanFolderInfo* m_scanFolder{};
  101. bool m_isDirectory{};
  102. };
  103. inline uint qHash(const AssetFileInfo& item)
  104. {
  105. return qHash(item.m_filePath);
  106. }
  107. } // end namespace AssetProcessor
  108. #endif //ASSETSCANFOLDERINFO_H