file_info.h 3.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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/string/string_name.h"
  33. #include "core/templates/list.h"
  34. enum class FileSortOption {
  35. FILE_SORT_NAME = 0,
  36. FILE_SORT_NAME_REVERSE = 1,
  37. FILE_SORT_TYPE = 2,
  38. FILE_SORT_TYPE_REVERSE = 3,
  39. FILE_SORT_MODIFIED_TIME = 4,
  40. FILE_SORT_MODIFIED_TIME_REVERSE = 5,
  41. FILE_SORT_MAX = 6,
  42. };
  43. struct FileInfo {
  44. String name;
  45. String path;
  46. String icon_path;
  47. StringName type;
  48. Vector<String> sources;
  49. bool import_broken = false;
  50. uint64_t modified_time = 0;
  51. bool operator<(const FileInfo &p_fi) const {
  52. return FileNoCaseComparator()(name, p_fi.name);
  53. }
  54. };
  55. struct FileInfoTypeComparator {
  56. bool operator()(const FileInfo &p_a, const FileInfo &p_b) const {
  57. 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());
  58. }
  59. };
  60. struct FileInfoModifiedTimeComparator {
  61. bool operator()(const FileInfo &p_a, const FileInfo &p_b) const {
  62. return p_a.modified_time > p_b.modified_time;
  63. }
  64. };
  65. void sort_file_info_list(List<FileInfo> &r_file_list, FileSortOption p_file_sort_option);
  66. #endif // FILE_INFO_H