Debian Codegraph @

editor/file_system/file_info.h

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