40ff3c15411fbe589702c4b00243ec99c851fe26
[reactos.git] / reactos / subsys / system / explorer / shell / entries.h
1 /*
2 * Copyright 2003, 2004 Martin Fuchs
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 */
18
19
20 //
21 // Explorer clone
22 //
23 // entries.h
24 //
25 // Martin Fuchs, 23.07.2003
26 //
27
28
29 enum ENTRY_TYPE {
30 ET_UNKNOWN,
31 ET_WINDOWS,
32 #ifdef __WINE__
33 ET_UNIX,
34 #endif
35 ET_SHELL,
36 ET_NTOBJS,
37 ET_REGISTRY,
38 ET_FAT,
39 ET_WEB
40 };
41
42 enum SORT_ORDER {
43 SORT_NONE,
44 SORT_NAME,
45 SORT_EXT,
46 SORT_SIZE,
47 SORT_DATE
48 };
49
50 enum SCAN_FLAGS {
51 // SCAN_EXTRACT_ICONS = 1,
52 SCAN_DO_ACCESS = 2,
53
54 SCAN_ALL = 3,
55
56 SCAN_FILESYSTEM = 4
57 };
58
59 #ifndef ATTRIBUTE_SYMBOLIC_LINK
60 #define ATTRIBUTE_LONGNAME 0x08000000
61 #define ATTRIBUTE_VOLNAME 0x10000000
62 #define ATTRIBUTE_ERASED 0x20000000
63 #define ATTRIBUTE_SYMBOLIC_LINK 0x40000000
64 #define ATTRIBUTE_EXECUTABLE 0x80000000
65 #endif
66
67
68 /// base of all file and directory entries
69 struct Entry
70 {
71 protected:
72 Entry(ENTRY_TYPE etype);
73 Entry(Entry* parent, ENTRY_TYPE etype);
74 Entry(const Entry&);
75
76 public:
77 virtual ~Entry();
78
79 Entry* _next;
80 Entry* _down;
81 Entry* _up;
82
83 bool _expanded;
84 bool _scanned;
85 int _level;
86
87 WIN32_FIND_DATA _data;
88
89 SFGAOF _shell_attribs;
90 LPTSTR _display_name;
91 LPTSTR _type_name;
92 LPTSTR _content;
93
94 ENTRY_TYPE _etype;
95 int /*ICON_ID*/ _icon_id;
96
97 BY_HANDLE_FILE_INFORMATION _bhfi;
98 bool _bhfi_valid;
99
100 void free_subentries();
101
102 void read_directory_base(SORT_ORDER sortOrder=SORT_NAME, int scan_flags=SCAN_ALL);
103 Entry* read_tree(const void* path, SORT_ORDER sortOrder=SORT_NAME, int scan_flags=SCAN_ALL);
104 void sort_directory(SORT_ORDER sortOrder);
105 void smart_scan(SORT_ORDER sortOrder=SORT_NAME, int scan_flags=SCAN_ALL);
106 void extract_icon(bool big_icons);
107
108 virtual void read_directory(int scan_flags=SCAN_ALL) {}
109 virtual const void* get_next_path_component(const void*) const {return NULL;}
110 virtual Entry* find_entry(const void*) {return NULL;}
111 virtual bool get_path(PTSTR path, size_t path_count) const = 0;
112 virtual ShellPath create_absolute_pidl() const {return (LPCITEMIDLIST)NULL;}
113 virtual HRESULT GetUIObjectOf(HWND hWnd, REFIID riid, LPVOID* ppvOut);
114 virtual BOOL launch_entry(HWND hwnd, UINT nCmdShow=SW_SHOWNORMAL);
115 virtual HRESULT do_context_menu(HWND hwnd, const POINT& pos, CtxMenuInterfaces& cm_ifs);
116
117 protected:
118 bool get_path_base(PTSTR path, size_t path_count, ENTRY_TYPE etype) const;
119 };
120
121
122 /// base for all directory entries
123 struct Directory {
124 protected:
125 Directory() : _path(NULL) {}
126 virtual ~Directory() {}
127
128 void* _path;
129 };
130
131
132 /// root entry for file system trees
133 struct Root {
134 Root();
135 ~Root();
136
137 Entry* _entry;
138 TCHAR _path[MAX_PATH];
139 TCHAR _volname[_MAX_FNAME];
140 TCHAR _fs[_MAX_DIR];
141 DWORD _drive_type;
142 DWORD _fs_flags;
143 SORT_ORDER _sort_order;
144
145 Entry* read_tree(LPCTSTR path, int scan_flags=SCAN_ALL);
146 Entry* read_tree(LPCITEMIDLIST pidl, int scan_flags=SCAN_ALL);
147 };