update for HEAD-2003091401
[reactos.git] / subsys / system / explorer / shell / shellfs.h
1 /*
2  * Copyright 2003 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  // shellfs.h
24  //
25  // Martin Fuchs, 23.07.2003
26  //
27
28
29 struct ShellEntry : public Entry
30 {
31         ShellEntry(Entry* parent, LPITEMIDLIST shell_path) : Entry(parent), _pidl(shell_path) {}
32         ShellEntry(Entry* parent, const ShellPath& shell_path) : Entry(parent), _pidl(shell_path) {}
33
34         virtual void get_path(PTSTR path) const;
35         virtual BOOL launch_entry(HWND hwnd, UINT nCmdShow=SW_SHOWNORMAL);
36
37         IShellFolder* get_parent_folder() const;
38         LPITEMIDLIST create_absolute_pidl(HWND hwnd);
39
40         ShellPath       _pidl;
41
42 protected:
43         ShellEntry(LPITEMIDLIST shell_path) : Entry(ET_SHELL), _pidl(shell_path) {}
44         ShellEntry(const ShellPath& shell_path) : Entry(ET_SHELL), _pidl(shell_path) {}
45 };
46
47
48 struct ShellDirectory : public ShellEntry, public Directory
49 {
50         ShellDirectory(ShellFolder& root_folder, const ShellPath& shell_path, HWND hwnd)
51          :      ShellEntry(shell_path),
52                 _folder(root_folder, shell_path),
53                 _hwnd(hwnd)
54         {
55                 lstrcpy(_data.cFileName, root_folder.get_name(shell_path));
56                 _data.dwFileAttributes = FILE_ATTRIBUTE_DIRECTORY;
57                 _shell_attribs = SFGAO_FOLDER;
58
59                 ShellFolder subfolder(root_folder, shell_path);
60                 IShellFolder* pFolder = subfolder;
61                 pFolder->AddRef();
62                 _path = pFolder;
63         }
64
65         explicit ShellDirectory(ShellDirectory* parent, LPITEMIDLIST shell_path, HWND hwnd)
66          :      ShellEntry(parent, shell_path),
67                 _folder(parent->_folder, shell_path),
68                 _hwnd(hwnd)
69         {
70                 /* not neccessary - the caller will fill the info
71                 lstrcpy(_data.cFileName, _folder.get_name(shell_path));
72                 _data.dwFileAttributes = FILE_ATTRIBUTE_DIRECTORY;
73                 _shell_attribs = SFGAO_FOLDER; */
74
75                 _folder->AddRef();
76                 _path = _folder;
77         }
78
79         ShellDirectory(const ShellDirectory& other)
80          :      ShellEntry(other),
81                 Directory(other),
82                 _folder(other._folder),
83                 _hwnd(other._hwnd)
84         {
85                 IShellFolder* pFolder = (IShellFolder*)_path;
86                 pFolder->AddRef();
87         }
88
89         ~ShellDirectory()
90         {
91                 IShellFolder* pFolder = (IShellFolder*)_path;
92                 _path = NULL;
93                 pFolder->Release();
94         }
95
96         virtual void read_directory();
97         virtual const void* get_next_path_component(const void*);
98         virtual Entry* find_entry(const void* p);
99
100         virtual void get_path(PTSTR path) const;
101
102         ShellFolder _folder;
103         HWND    _hwnd;
104
105 protected:
106         bool    fill_w32fdata_shell(LPCITEMIDLIST pidl, SFGAOF attribs, WIN32_FIND_DATA*, BY_HANDLE_FILE_INFORMATION*);
107 };
108
109
110 inline IShellFolder* ShellEntry::get_parent_folder() const
111 {
112         if (_up)
113                 return static_cast<ShellDirectory*>(_up)->_folder;
114         else
115                 return Desktop();
116 }