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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 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 #ifndef _NO_WIN_FS 32 ET_WINDOWS, 33 #endif 34 #ifdef __WINE__ 35 ET_UNIX, 36 #endif 37 ET_SHELL, 38 ET_NTOBJS, 39 ET_REGISTRY, 40 ET_FAT, 41 ET_WEB 42 }; 43 44 enum SORT_ORDER { 45 SORT_NONE, 46 SORT_NAME, 47 SORT_EXT, 48 SORT_SIZE, 49 SORT_DATE 50 }; 51 52 enum SCAN_FLAGS { 53 SCAN_DONT_EXTRACT_ICONS = 1, 54 SCAN_DONT_ACCESS = 2, 55 SCAN_NO_FILESYSTEM = 4 56 }; 57 58 #ifndef ATTRIBUTE_SYMBOLIC_LINK 59 #define ATTRIBUTE_LONGNAME 0x08000000 60 #define ATTRIBUTE_VOLNAME 0x10000000 61 #define ATTRIBUTE_ERASED 0x20000000 62 #define ATTRIBUTE_SYMBOLIC_LINK 0x40000000 63 #define ATTRIBUTE_EXECUTABLE 0x80000000 64 #endif 65 66 enum ICONCACHE_FLAGS { 67 ICF_NORMAL = 0, 68 ICF_MIDDLE = 1, 69 ICF_LARGE = 2, 70 ICF_OPEN = 4, 71 ICF_OVERLAYS = 8, 72 ICF_HICON = 16, 73 ICF_SYSCACHE = 32 74 }; 75 76 #ifndef SHGFI_ADDOVERLAYS // missing in MinGW (as of 28.12.2005) 77 #define SHGFI_ADDOVERLAYS 0x000000020 78 #endif 79 80 81 /// base of all file and directory entries 82 struct Entry 83 { 84 protected: 85 Entry(ENTRY_TYPE etype); 86 Entry(Entry* parent, ENTRY_TYPE etype); 87 Entry(const Entry&); 88 89 public: 90 virtual ~Entry(); 91 92 Entry* _next; 93 Entry* _down; 94 Entry* _up; 95 96 bool _expanded; 97 bool _scanned; 98 int _level; 99 100 WIN32_FIND_DATA _data; 101 102 SFGAOF _shell_attribs; 103 LPTSTR _display_name; 104 LPTSTR _type_name; 105 LPTSTR _content; 106 107 ENTRY_TYPE _etype; 108 int /*ICON_ID*/ _icon_id; 109 110 BY_HANDLE_FILE_INFORMATION _bhfi; 111 bool _bhfi_valid; 112 113 void free_subentries(); 114 115 void read_directory_base(SORT_ORDER sortOrder=SORT_NAME, int scan_flags=0); 116 Entry* read_tree(const void* path, SORT_ORDER sortOrder=SORT_NAME, int scan_flags=0); 117 void sort_directory(SORT_ORDER sortOrder); 118 void smart_scan(SORT_ORDER sortOrder=SORT_NAME, int scan_flags=0); 119 int extract_icon(ICONCACHE_FLAGS flags=ICF_NORMAL); 120 int safe_extract_icon(ICONCACHE_FLAGS flags=ICF_NORMAL); 121 122 virtual void read_directory(int scan_flags=0) {} get_next_path_componentEntry123 virtual const void* get_next_path_component(const void*) const {return NULL;} find_entryEntry124 virtual Entry* find_entry(const void*) {return NULL;} 125 virtual bool get_path(PTSTR path, size_t path_count) const = 0; create_absolute_pidlEntry126 virtual ShellPath create_absolute_pidl() const {return (LPCITEMIDLIST)NULL;} 127 virtual HRESULT GetUIObjectOf(HWND hWnd, REFIID riid, LPVOID* ppvOut); 128 virtual ShellFolder get_shell_folder() const; 129 virtual BOOL launch_entry(HWND hwnd, UINT nCmdShow=SW_SHOWNORMAL); 130 virtual HRESULT do_context_menu(HWND hwnd, const POINT& pos, CtxMenuInterfaces& cm_ifs); 131 132 protected: 133 bool get_path_base(PTSTR path, size_t path_count, ENTRY_TYPE etype) const; 134 }; 135 136 137 /// base for all directory entries 138 struct Directory { 139 protected: DirectoryDirectory140 Directory() : _path(NULL) {} ~DirectoryDirectory141 virtual ~Directory() {} 142 143 void* _path; 144 }; 145 146 147 /// root entry for file system trees 148 struct Root { 149 Root(); 150 ~Root(); 151 152 Entry* _entry; 153 TCHAR _path[MAX_PATH]; 154 TCHAR _volname[_MAX_FNAME]; 155 TCHAR _fs[_MAX_DIR]; 156 DWORD _drive_type; 157 DWORD _fs_flags; 158 SORT_ORDER _sort_order; 159 160 Entry* read_tree(LPCTSTR path, int scan_flags=0); 161 Entry* read_tree(LPCITEMIDLIST pidl, int scan_flags=0); 162 }; 163