file_info.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. /**************************************************************************/
  2. /* file_info.h */
  3. /**************************************************************************/
  4. /* This file is part of: */
  5. /* GODOT ENGINE */
  6. /* https://godotengine.org */
  7. /**************************************************************************/
  8. /* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
  9. /* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
  10. /* */
  11. /* Permission is hereby granted, free of charge, to any person obtaining */
  12. /* a copy of this software and associated documentation files (the */
  13. /* "Software"), to deal in the Software without restriction, including */
  14. /* without limitation the rights to use, copy, modify, merge, publish, */
  15. /* distribute, sublicense, and/or sell copies of the Software, and to */
  16. /* permit persons to whom the Software is furnished to do so, subject to */
  17. /* the following conditions: */
  18. /* */
  19. /* The above copyright notice and this permission notice shall be */
  20. /* included in all copies or substantial portions of the Software. */
  21. /* */
  22. /* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
  23. /* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
  24. /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
  25. /* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
  26. /* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
  27. /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
  28. /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
  29. /**************************************************************************/
  30. #ifndef FILE_INFO_H
  31. #define FILE_INFO_H
  32. #include "core/variant/variant.h"
  33. enum class FileSortOption {
  34. FILE_SORT_NAME = 0,
  35. FILE_SORT_NAME_REVERSE = 1,
  36. FILE_SORT_TYPE = 2,
  37. FILE_SORT_TYPE_REVERSE = 3,
  38. FILE_SORT_MODIFIED_TIME = 4,
  39. FILE_SORT_MODIFIED_TIME_REVERSE = 5,
  40. FILE_SORT_MAX = 6,
  41. };
  42. struct FileInfo {
  43. String name;
  44. String path;
  45. String icon_path;
  46. StringName type;
  47. Vector<String> sources;
  48. bool import_broken = false;
  49. uint64_t modified_time = 0;
  50. bool operator<(const FileInfo &p_fi) const {
  51. return FileNoCaseComparator()(name, p_fi.name);
  52. }
  53. };
  54. struct FileInfoTypeComparator {
  55. bool operator()(const FileInfo &p_a, const FileInfo &p_b) const {
  56. return FileNoCaseComparator()(p_a.name.get_extension() + p_a.type + p_a.name.get_basename(), p_b.name.get_extension() + p_b.type + p_b.name.get_basename());
  57. }
  58. };
  59. struct FileInfoModifiedTimeComparator {
  60. bool operator()(const FileInfo &p_a, const FileInfo &p_b) const {
  61. return p_a.modified_time > p_b.modified_time;
  62. }
  63. };
  64. void sort_file_info_list(List<FileInfo> &r_file_list, FileSortOption p_file_sort_option);
  65. #endif // FILE_INFO_H