ReactOS  0.4.12-dev-75-g00dd17e
ShellDirectory Struct Reference

shell folder entry More...

#include <shellfs.h>

Inheritance diagram for ShellDirectory:
Collaboration diagram for ShellDirectory:

Public Member Functions

 ShellDirectory (ShellFolder &root_folder, const ShellPath &shell_path, HWND hwnd)
 
 ShellDirectory (ShellDirectory *parent, LPITEMIDLIST shell_path, HWND hwnd)
 
 ShellDirectory (const ShellDirectory &other)
 
 ~ShellDirectory ()
 
virtual void read_directory (int scan_flags=0)
 
virtual const voidget_next_path_component (const void *) const
 
virtual Entryfind_entry (const void *)
 
virtual bool get_path (PTSTR path, size_t path_count) const
 
virtual ShellFolder get_shell_folder () const
 
int extract_icons (ICONCACHE_FLAGS flags)
 
- Public Member Functions inherited from ShellEntry
 ShellEntry (Entry *parent, LPITEMIDLIST shell_path)
 
 ShellEntry (Entry *parent, const ShellPath &shell_path)
 
virtual ShellPath create_absolute_pidl () const
 
virtual HRESULT GetUIObjectOf (HWND hWnd, REFIID riid, LPVOID *ppvOut)
 
virtual BOOL launch_entry (HWND hwnd, UINT nCmdShow=SW_SHOWNORMAL)
 
virtual HRESULT do_context_menu (HWND hwnd, const POINT &pptScreen, CtxMenuInterfaces &cm_ifs)
 
IShellFolderget_parent_folder () const
 
- Public Member Functions inherited from Entry
virtual ~Entry ()
 
void free_subentries ()
 
void read_directory_base (SORT_ORDER sortOrder=SORT_NAME, int scan_flags=0)
 
Entryread_tree (const void *path, SORT_ORDER sortOrder=SORT_NAME, int scan_flags=0)
 
void sort_directory (SORT_ORDER sortOrder)
 
void smart_scan (SORT_ORDER sortOrder=SORT_NAME, int scan_flags=0)
 
int extract_icon (ICONCACHE_FLAGS flags=ICF_NORMAL)
 
int safe_extract_icon (ICONCACHE_FLAGS flags=ICF_NORMAL)
 

Public Attributes

ShellFolder _folder
 
HWND _hwnd
 
- Public Attributes inherited from ShellEntry
ShellPath _pidl
 
- Public Attributes inherited from Entry
Entry_next
 
Entry_down
 
Entry_up
 
bool _expanded
 
bool _scanned
 
int _level
 
WIN32_FIND_DATA _data
 
SFGAOF _shell_attribs
 
LPTSTR _display_name
 
LPTSTR _type_name
 
LPTSTR _content
 
ENTRY_TYPE _etype
 
int _icon_id
 
BY_HANDLE_FILE_INFORMATION _bhfi
 
bool _bhfi_valid
 

Protected Member Functions

bool fill_w32fdata_shell (LPCITEMIDLIST pidl, SFGAOF attribs, WIN32_FIND_DATA *, BY_HANDLE_FILE_INFORMATION *, bool do_access=true)
 
- Protected Member Functions inherited from ShellEntry
 ShellEntry (LPITEMIDLIST shell_path)
 
 ShellEntry (const ShellPath &shell_path)
 
- Protected Member Functions inherited from Entry
 Entry (ENTRY_TYPE etype)
 
 Entry (Entry *parent, ENTRY_TYPE etype)
 
 Entry (const Entry &)
 
bool get_path_base (PTSTR path, size_t path_count, ENTRY_TYPE etype) const
 
- Protected Member Functions inherited from Directory
 Directory ()
 
virtual ~Directory ()
 

Additional Inherited Members

- Protected Attributes inherited from Directory
void_path
 

Detailed Description

shell folder entry

Definition at line 53 of file shellfs.h.

Constructor & Destructor Documentation

◆ ShellDirectory() [1/3]

ShellDirectory::ShellDirectory ( ShellFolder root_folder,
const ShellPath shell_path,
HWND  hwnd 
)
inline

Definition at line 55 of file shellfs.h.

Referenced by read_directory().

56  : ShellEntry(shell_path),
57  _folder(root_folder, shell_path),
58  _hwnd(hwnd)
59  {
60  CONTEXT("ShellDirectory::ShellDirectory()");
61 
62  lstrcpy(_data.cFileName, root_folder.get_name(shell_path, SHGDN_FORADDRESSBAR));
63  _data.dwFileAttributes = FILE_ATTRIBUTE_DIRECTORY;
64  _shell_attribs = SFGAO_FOLDER;
65 
66  ShellFolder subfolder(root_folder, shell_path);
67  IShellFolder* pFolder = subfolder;
68  pFolder->AddRef();
69  _path = pFolder;
70  }
struct _CONTEXT CONTEXT
ShellEntry(Entry *parent, LPITEMIDLIST shell_path)
Definition: shellfs.h:32
WIN32_FIND_DATA _data
Definition: entries.h:100
IShellFolder smart pointer.
Definition: shellclasses.h:593
String get_name(LPCITEMIDLIST pidl, SHGDNF flags=SHGDN_NORMAL) const
#define FILE_ATTRIBUTE_DIRECTORY
Definition: nt_native.h:705
ULONG AddRef()
SFGAOF _shell_attribs
Definition: entries.h:102
ShellFolder _folder
Definition: shellfs.h:112
void * _path
Definition: entries.h:143
#define lstrcpy
Definition: winbase.h:3688

◆ ShellDirectory() [2/3]

ShellDirectory::ShellDirectory ( ShellDirectory parent,
LPITEMIDLIST  shell_path,
HWND  hwnd 
)
inlineexplicit

Definition at line 72 of file shellfs.h.

73  : ShellEntry(parent, shell_path),
74  _folder(parent->_folder, shell_path),
75  _hwnd(hwnd)
76  {
77  /* not neccessary - the caller will fill the info
78  lstrcpy(_data.cFileName, _folder.get_name(shell_path));
79  _data.dwFileAttributes = FILE_ATTRIBUTE_DIRECTORY;
80  _shell_attribs = SFGAO_FOLDER; */
81 
82  _folder->AddRef();
83  _path = _folder;
84  }
ShellEntry(Entry *parent, LPITEMIDLIST shell_path)
Definition: shellfs.h:32
ShellFolder _folder
Definition: shellfs.h:112
void * _path
Definition: entries.h:143

◆ ShellDirectory() [3/3]

ShellDirectory::ShellDirectory ( const ShellDirectory other)
inline

Definition at line 86 of file shellfs.h.

87  : ShellEntry(other),
88  Directory(other),
89  _folder(other._folder),
90  _hwnd(other._hwnd)
91  {
92  IShellFolder* pFolder = (IShellFolder*)_path;
93  pFolder->AddRef();
94  }
ShellEntry(Entry *parent, LPITEMIDLIST shell_path)
Definition: shellfs.h:32
Directory()
Definition: entries.h:140
ULONG AddRef()
ShellFolder _folder
Definition: shellfs.h:112
void * _path
Definition: entries.h:143

◆ ~ShellDirectory()

ShellDirectory::~ShellDirectory ( )
inline

Definition at line 96 of file shellfs.h.

97  {
98  IShellFolder* pFolder = (IShellFolder*)_path;
99  _path = NULL;
100  pFolder->Release();
101  }
ULONG Release()
smooth NULL
Definition: ftsmooth.c:416
void * _path
Definition: entries.h:143

Member Function Documentation

◆ extract_icons()

int ShellDirectory::extract_icons ( ICONCACHE_FLAGS  flags)

Definition at line 524 of file shellfs.cpp.

Referenced by StartMenu::Paint().

525 {
526  int cnt = 0;
527 
528  for(Entry*entry=_down; entry; entry=entry->_next)
529  if (entry->_icon_id == ICID_UNKNOWN) {
530  entry->_icon_id = entry->extract_icon(flags);
531 
532  if (entry->_icon_id != ICID_NONE)
533  ++cnt;
534  }
535 
536  return cnt;
537 }
uint8_t entry
Definition: isohybrid.c:63
Entry * _down
Definition: entries.h:93
GLbitfield flags
Definition: glext.h:7161
base of all file and directory entries
Definition: entries.h:82

◆ fill_w32fdata_shell()

bool ShellDirectory::fill_w32fdata_shell ( LPCITEMIDLIST  pidl,
SFGAOF  attribs,
WIN32_FIND_DATA pw32fdata,
BY_HANDLE_FILE_INFORMATION pbhfi,
bool  do_access = true 
)
protected

Definition at line 31 of file shellfs.cpp.

Referenced by read_directory().

32 {
33  CONTEXT("ShellDirectory::fill_w32fdata_shell()");
34 
35  bool bhfi_valid = false;
36 
37  if (do_access && !( (attribs&SFGAO_FILESYSTEM) && SUCCEEDED(
38  SHGetDataFromIDList(_folder, pidl, SHGDFIL_FINDDATA, pw32fdata, sizeof(WIN32_FIND_DATA))) )) {
40  IDataObject* pDataObj;
41 
42  STGMEDIUM medium = {0, {0}, 0};
43  FORMATETC fmt = {(USHORT)g_Globals._cfStrFName, 0, DVASPECT_CONTENT, -1, TYMED_HGLOBAL};
44 
45  HRESULT hr = _folder->GetUIObjectOf(0, 1, &pidl, IID_IDataObject, 0, (LPVOID*)&pDataObj);
46 
47  if (SUCCEEDED(hr)) {
48  hr = pDataObj->GetData(&fmt, &medium);
49 
50  pDataObj->Release();
51 
52  if (SUCCEEDED(hr)) {
53  LPCTSTR path = (LPCTSTR)GlobalLock(medium.UNION_MEMBER(hGlobal));
54 
55  if (path) {
56  // fill with drive names "C:", ...
57  assert(_tcslen(path) < GlobalSize(medium.UNION_MEMBER(hGlobal)));
58  _tcscpy(pw32fdata->cFileName, path);
59 
61 
62  if (GetFileAttributesEx(path, GetFileExInfoStandard, &fad)) {
63  pw32fdata->dwFileAttributes = fad.dwFileAttributes;
64  pw32fdata->ftCreationTime = fad.ftCreationTime;
65  pw32fdata->ftLastAccessTime = fad.ftLastAccessTime;
66  pw32fdata->ftLastWriteTime = fad.ftLastWriteTime;
67 
69  // copy file size
70  pw32fdata->nFileSizeLow = fad.nFileSizeLow;
71  pw32fdata->nFileSizeHigh = fad.nFileSizeHigh;
72  } else {
73  // ignore FILE_ATTRIBUTE_HIDDEN attribute of NTFS drives - this would hide those drives in ShellBrowser
74  if (pw32fdata->dwFileAttributes & FILE_ATTRIBUTE_HIDDEN) {
75  if (path[1]==':' && path[2]=='\\' && !path[3]) // Is it a drive path?
76  pw32fdata->dwFileAttributes &= ~FILE_ATTRIBUTE_HIDDEN;
77  }
78  }
79  }
80 
83 
84  if (hFile != INVALID_HANDLE_VALUE) {
85  if (GetFileInformationByHandle(hFile, pbhfi))
86  bhfi_valid = true;
87 
88  CloseHandle(hFile);
89  }
90 
91  SetErrorMode(sem_org);
92 
93  GlobalUnlock(medium.UNION_MEMBER(hGlobal));
94  GlobalFree(medium.UNION_MEMBER(hGlobal));
95  }
96  }
97  }
98  }
99 
100  if (!do_access || !(attribs&SFGAO_FILESYSTEM)) // Archiv files should not be displayed as folders in explorer view.
101  if (attribs & (SFGAO_FOLDER|SFGAO_HASSUBFOLDER))
102  pw32fdata->dwFileAttributes |= FILE_ATTRIBUTE_DIRECTORY;
103 
104  if (attribs & SFGAO_READONLY)
105  pw32fdata->dwFileAttributes |= FILE_ATTRIBUTE_READONLY;
106 
107  if (attribs & SFGAO_COMPRESSED)
108  pw32fdata->dwFileAttributes |= FILE_ATTRIBUTE_COMPRESSED;
109 
110  return bhfi_valid;
111 }
UINT WINAPI SetErrorMode(IN UINT uMode)
Definition: except.c:753
struct _CONTEXT CONTEXT
const CHAR * LPCTSTR
Definition: xmlstorage.h:193
#define CloseHandle
Definition: compat.h:398
#define SEM_FAILCRITICALERRORS
Definition: rtltypes.h:69
const GLint * attribs
Definition: glext.h:10538
#define INVALID_HANDLE_VALUE
Definition: compat.h:391
_TCHAR * _tcscpy(_TCHAR *to, const _TCHAR *from)
Definition: tcscpy.h:8
#define assert(x)
Definition: debug.h:53
const GUID IID_IDataObject
#define FILE_SHARE_WRITE
Definition: nt_native.h:681
#define FILE_SHARE_READ
Definition: compat.h:125
SIZE_T NTAPI GlobalSize(HGLOBAL hMem)
Definition: heapmem.c:1090
#define GetFileAttributesEx
Definition: winbase.h:3630
size_t __cdecl _tcslen(const _TCHAR *str)
Definition: tcslen.h:9
#define OPEN_EXISTING
Definition: compat.h:426
#define FILE_ATTRIBUTE_DIRECTORY
Definition: nt_native.h:705
BOOL WINAPI GetFileInformationByHandle(HANDLE hFile, LPBY_HANDLE_FILE_INFORMATION lpFileInformation)
Definition: fileinfo.c:608
if(!(yy_init))
Definition: macro.lex.yy.c:717
LONG HRESULT
Definition: typedefs.h:77
unsigned int UINT
Definition: ndis.h:50
#define FILE_ATTRIBUTE_READONLY
Definition: nt_native.h:702
nsrefcnt Release()
UINT _cfStrFName
Definition: globals.h:271
HGLOBAL NTAPI GlobalFree(HGLOBAL hMem)
Definition: heapmem.c:611
#define FILE_ATTRIBUTE_COMPRESSED
Definition: nt_native.h:711
#define SHGDFIL_FINDDATA
Definition: shlobj.h:1353
#define FILE_SHARE_DELETE
Definition: nt_native.h:682
#define SHGetDataFromIDList
Definition: shlobj.h:1405
LPVOID NTAPI GlobalLock(HGLOBAL hMem)
Definition: heapmem.c:755
ShellFolder _folder
Definition: shellfs.h:112
ExplorerGlobals g_Globals
Definition: explorer.cpp:52
#define GENERIC_READ
Definition: compat.h:124
_In_ HANDLE hFile
Definition: mswsock.h:90
IN OUT PVCB OUT PDIRENT OUT PBCB IN BOOLEAN CreateFile
Definition: fatprocs.h:904
unsigned short USHORT
Definition: pedump.c:61
Definition: services.c:325
#define FILE_ATTRIBUTE_HIDDEN
Definition: nt_native.h:703
BOOL NTAPI GlobalUnlock(HGLOBAL hMem)
Definition: heapmem.c:1190
#define FILE_FLAG_BACKUP_SEMANTICS
Definition: disk.h:41
Definition: dsound.c:943
#define SUCCEEDED(hr)
Definition: intsafe.h:57

◆ find_entry()

Entry * ShellDirectory::find_entry ( const void p)
virtual

Reimplemented from Entry.

Definition at line 495 of file shellfs.cpp.

Referenced by ShellBrowser::jump_to(), and ShellBrowser::OnDefaultCommand().

496 {
497  LPITEMIDLIST pidl = (LPITEMIDLIST) p;
498 
499  // handle special case of empty trailing id list entry
500  if (!pidl->mkid.cb)
501  return this;
502 
503  for(Entry*entry=_down; entry; entry=entry->_next)
504  if (entry->_etype == ET_SHELL) {
505  ShellEntry* se = static_cast<ShellEntry*>(entry);
506 
507  if (se->_pidl && se->_pidl->mkid.cb==pidl->mkid.cb && !memcmp(se->_pidl, pidl, se->_pidl->mkid.cb))
508  return entry;
509  } else {
510  const ShellPath& sp = entry->create_absolute_pidl();
511  static DynamicFct<LPITEMIDLIST(WINAPI*)(LPCITEMIDLIST)> ILFindLastID(TEXT("SHELL32"), "ILFindLastID");
512 
513  if (ILFindLastID) {
514  LPCITEMIDLIST entry_pidl = (*ILFindLastID)(sp);
515 
516  if (entry_pidl && entry_pidl->mkid.cb==pidl->mkid.cb && !memcmp(entry_pidl, pidl, entry_pidl->mkid.cb))
517  return entry;
518  }
519  }
520 
521  return NULL;
522 }
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
Definition: utclib.c:112
uint8_t entry
Definition: isohybrid.c:63
const ITEMIDLIST UNALIGNED * LPCITEMIDLIST
Definition: shtypes.idl:42
smooth NULL
Definition: ftsmooth.c:416
LPITEMIDLIST WINAPI ILFindLastID(LPCITEMIDLIST pidl)
Definition: pidl.c:189
Entry * _down
Definition: entries.h:93
ShellPath _pidl
Definition: shellfs.h:44
shell file/directory entry
Definition: shellfs.h:30
#define TEXT(s)
Definition: k32.h:26
static const WCHAR sp[]
Definition: suminfo.c:288
ITEMIDLIST UNALIGNED * LPITEMIDLIST
Definition: shtypes.idl:41
wrapper class for item ID lists
Definition: shellclasses.h:651
base of all file and directory entries
Definition: entries.h:82

◆ get_next_path_component()

const void * ShellDirectory::get_next_path_component ( const void p) const
virtual

Reimplemented from Entry.

Definition at line 482 of file shellfs.cpp.

483 {
484  LPITEMIDLIST pidl = (LPITEMIDLIST)p;
485 
486  if (!pidl || !pidl->mkid.cb)
487  return NULL;
488 
489  // go to next element
490  pidl = (LPITEMIDLIST)((LPBYTE)pidl+pidl->mkid.cb);
491 
492  return pidl;
493 }
unsigned char * LPBYTE
Definition: typedefs.h:52
smooth NULL
Definition: ftsmooth.c:416
ITEMIDLIST UNALIGNED * LPITEMIDLIST
Definition: shtypes.idl:41

◆ get_path()

bool ShellDirectory::get_path ( PTSTR  path,
size_t  path_count 
) const
virtual

Reimplemented from ShellEntry.

Definition at line 155 of file shellfs.cpp.

Referenced by StartMenu::AddShellEntries(), and read_directory().

156 {
157  CONTEXT("ShellDirectory::get_path()");
158 
159  if (!path || path_count==0)
160  return false;
161 
162  path[0] = TEXT('\0');
163 
164  if (_folder.empty())
165  return false;
166 
167  SFGAOF attribs = SFGAO_FILESYSTEM;
168 
169  // Split pidl into current and parent folder PIDLs
170  ShellPath pidlParent, pidlFolder;
171  _pidl.split(pidlParent, pidlFolder);
172 
173  if (FAILED(const_cast<ShellFolder&>(_folder)->GetAttributesOf(1, (LPCITEMIDLIST*)&pidlFolder, &attribs)))
174  return false;
175 
176  if (!(attribs & SFGAO_FILESYSTEM))
177  return false;
178 
179  if (FAILED(path_from_pidl(get_parent_folder(), &*_pidl, path, path_count)))
180  return false;
181 
182  return true;
183 }
void split(ShellPath &parent, ShellPath &obj) const
struct _CONTEXT CONTEXT
const GLint * attribs
Definition: glext.h:10538
const ITEMIDLIST UNALIGNED * LPCITEMIDLIST
Definition: shtypes.idl:42
bool empty() const
Definition: shellclasses.h:382
IShellFolder * get_parent_folder() const
Definition: shellfs.h:120
ShellFolder _folder
Definition: shellfs.h:112
ShellPath _pidl
Definition: shellfs.h:44
#define TEXT(s)
Definition: k32.h:26
#define path_from_pidl
Definition: shellclasses.h:628
Definition: services.c:325
wrapper class for item ID lists
Definition: shellclasses.h:651
static IShellFolder IShellItem **static IBindCtx LPITEMIDLIST SFGAOF
Definition: ebrowser.c:83

◆ get_shell_folder()

ShellFolder ShellDirectory::get_shell_folder ( ) const
virtual

Reimplemented from ShellEntry.

Definition at line 247 of file shellfs.cpp.

248 {
249  return _folder;
250 }
ShellFolder _folder
Definition: shellfs.h:112

◆ read_directory()

void ShellDirectory::read_directory ( int  scan_flags = 0)
virtual

Reimplemented from Entry.

Definition at line 253 of file shellfs.cpp.

254 {
255  CONTEXT("ShellDirectory::read_directory()");
256 
257  int level = _level + 1;
258 
259  Entry* first_entry = NULL;
260  Entry* last = NULL;
261 
262  /*if (_folder.empty())
263  return;*/
264 
265 #ifndef _NO_WIN_FS
267 
268  if (!(scan_flags&SCAN_NO_FILESYSTEM) && get_path(buffer, COUNTOF(buffer)) && _tcsncmp(buffer,TEXT("::{"),3)) {
269  Entry* entry = NULL; // eliminate useless GCC warning by initializing entry
270 
271  LPTSTR p = buffer + _tcslen(buffer);
272 
273  lstrcpy(p, TEXT("\\*"));
274 
275  WIN32_FIND_DATA w32fd;
276  HANDLE hFind = FindFirstFile(buffer, &w32fd);
277 
278  if (hFind != INVALID_HANDLE_VALUE) {
279  do {
280  // ignore hidden files (usefull in the start menu)
281  if (w32fd.dwFileAttributes & FILE_ATTRIBUTE_HIDDEN)
282  continue;
283 
284  // ignore directory entries "." and ".."
285  if ((w32fd.dwFileAttributes&FILE_ATTRIBUTE_DIRECTORY) &&
286  w32fd.cFileName[0]==TEXT('.') &&
287  (w32fd.cFileName[1]==TEXT('\0') ||
288  (w32fd.cFileName[1]==TEXT('.') && w32fd.cFileName[2]==TEXT('\0'))))
289  continue;
290 
291  lstrcpy(p+1, w32fd.cFileName);
292 
293  if (w32fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
294  entry = new WinDirectory(this, buffer);
295  else
296  entry = new WinEntry(this);
297 
298  if (!first_entry)
299  first_entry = entry;
300 
301  if (last)
302  last->_next = entry;
303 
304  memcpy(&entry->_data, &w32fd, sizeof(WIN32_FIND_DATA));
305 
306  entry->_level = level;
307 
308  if (!(scan_flags & SCAN_DONT_ACCESS)) {
311 
312  if (hFile != INVALID_HANDLE_VALUE) {
313  if (GetFileInformationByHandle(hFile, &entry->_bhfi))
314  entry->_bhfi_valid = true;
315 
316 #ifdef BACKUP_READ_IMPLEMENTED
317  if (ScanNTFSStreams(entry, hFile))
318  entry->_scanned = true; // There exist named NTFS sub-streams in this file.
319 #endif
320 
321  CloseHandle(hFile);
322  }
323  }
324 
325  // set file type name
327 
328  DWORD attribs = SFGAO_FILESYSTEM;
329 
330  if (w32fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
331  attribs |= SFGAO_FOLDER|SFGAO_HASSUBFOLDER;
332 
333  if (w32fd.dwFileAttributes & FILE_ATTRIBUTE_READONLY)
334  attribs |= SFGAO_READONLY;
335 
336  //if (w32fd.dwFileAttributes & FILE_ATTRIBUTE_HIDDEN)
337  // attribs |= SFGAO_HIDDEN;
338 
339  if (w32fd.dwFileAttributes & FILE_ATTRIBUTE_COMPRESSED)
340  attribs |= SFGAO_COMPRESSED;
341 
342  if (ext && !_tcsicmp(ext, _T(".lnk"))) {
343  attribs |= SFGAO_LINK;
344  w32fd.dwFileAttributes |= ATTRIBUTE_SYMBOLIC_LINK;
345  }
346 
347  entry->_shell_attribs = attribs;
348 
349  if (w32fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
350  entry->_icon_id = ICID_FOLDER;
351  else if (!(scan_flags & SCAN_DONT_EXTRACT_ICONS))
352  entry->_icon_id = entry->safe_extract_icon(); // Assume small icon, we can extract the large icon later on demand.
353 
354  last = entry;
355  } while(FindNextFile(hFind, &w32fd));
356 
357  FindClose(hFind);
358  }
359  }
360  else // SCAN_NO_FILESYSTEM
361 #endif
362  {
363  ShellItemEnumerator enumerator(_folder, SHCONTF_FOLDERS|SHCONTF_NONFOLDERS|SHCONTF_INCLUDEHIDDEN|SHCONTF_SHAREABLE|SHCONTF_STORAGE);
364 
367  HRESULT hr_next = S_OK;
368 
369  do {
370 #define FETCH_ITEM_COUNT 32
372  ULONG cnt = 0;
373 
374  memset(pidls, 0, sizeof(pidls));
375 
376  hr_next = enumerator->Next(FETCH_ITEM_COUNT, pidls, &cnt);
377 
378  /* don't break yet now: Registry Explorer Plugin returns E_FAIL!
379  if (!SUCCEEDED(hr_next))
380  break; */
381 
382  if (hr_next == S_FALSE)
383  break;
384 
385  for(ULONG n=0; n<cnt; ++n) {
386  WIN32_FIND_DATA w32fd;
388  bool bhfi_valid = false;
389 
390  memset(&w32fd, 0, sizeof(WIN32_FIND_DATA));
391 
392  SFGAOF attribs_before = ~SFGAO_READONLY & ~SFGAO_VALIDATE;
393  SFGAOF attribs = attribs_before;
394  HRESULT hr = _folder->GetAttributesOf(1, (LPCITEMIDLIST*)&pidls[n], &attribs);
395  bool removeable = false;
396 
397  if (SUCCEEDED(hr) && attribs!=attribs_before) {
398  // avoid accessing floppy drives when browsing "My Computer"
399  if (attribs & SFGAO_REMOVABLE) {
400  attribs |= SFGAO_HASSUBFOLDER;
401  removeable = true;
402  } else if (!(scan_flags & SCAN_DONT_ACCESS)) {
403  SFGAOF attribs2 = SFGAO_READONLY;
404 
405  HRESULT hr = _folder->GetAttributesOf(1, (LPCITEMIDLIST*)&pidls[n], &attribs2);
406 
407  if (SUCCEEDED(hr))
408  attribs |= attribs2;
409  }
410  } else
411  attribs = 0;
412 
413  bhfi_valid = fill_w32fdata_shell(pidls[n], attribs, &w32fd, &bhfi,
414  !(scan_flags&SCAN_DONT_ACCESS) && !removeable);
415 
416  try {
417  Entry* entry = NULL; // eliminate useless GCC warning by initializing entry
418 
419  if (w32fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
420  entry = new ShellDirectory(this, pidls[n], _hwnd);
421  else
422  entry = new ShellEntry(this, pidls[n]);
423 
424  if (!first_entry)
425  first_entry = entry;
426 
427  if (last)
428  last->_next = entry;
429 
430  memcpy(&entry->_data, &w32fd, sizeof(WIN32_FIND_DATA));
431 
432  if (bhfi_valid)
433  memcpy(&entry->_bhfi, &bhfi, sizeof(BY_HANDLE_FILE_INFORMATION));
434 
435  // store path in entry->_data.cFileName in case fill_w32fdata_shell() didn't already fill it
436  if (!entry->_data.cFileName[0])
437  if (SUCCEEDED(path_from_pidl(_folder, pidls[n], path, COUNTOF(path))))
438  _tcscpy(entry->_data.cFileName, path);
439 
440  if (SUCCEEDED(name_from_pidl(_folder, pidls[n], name, COUNTOF(name), SHGDN_INFOLDER|0x2000/*0x2000=SHGDN_INCLUDE_NONFILESYS*/))) {
441  if (!entry->_data.cFileName[0])
442  _tcscpy(entry->_data.cFileName, name);
443  else if (_tcscmp(entry->_display_name, name))
444  entry->_display_name = _tcsdup(name); // store display name separate from file name; sort display by file name
445  }
446 
447  if (attribs & SFGAO_LINK)
448  w32fd.dwFileAttributes |= ATTRIBUTE_SYMBOLIC_LINK;
449 
450  entry->_level = level;
451  entry->_shell_attribs = attribs;
452  entry->_bhfi_valid = bhfi_valid;
453 
454  // set file type name
456 
457  // get icons for files and virtual objects
458  if (!(entry->_data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) ||
459  !(attribs & SFGAO_FILESYSTEM)) {
460  if (!(scan_flags & SCAN_DONT_EXTRACT_ICONS))
461  entry->_icon_id = entry->safe_extract_icon(); // Assume small icon, we can extract the large icon later on demand.
462  } else if (entry->_data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
463  entry->_icon_id = ICID_FOLDER;
464  else
465  entry->_icon_id = ICID_NONE; // don't try again later
466 
467  last = entry;
468  } catch(COMException& e) {
470  }
471  }
472  } while(SUCCEEDED(hr_next));
473  }
474 
475  if (last)
476  last->_next = NULL;
477 
478  _down = first_entry;
479  _scanned = true;
480 }
bool fill_w32fdata_shell(LPCITEMIDLIST pidl, SFGAOF attribs, WIN32_FIND_DATA *, BY_HANDLE_FILE_INFORMATION *, bool do_access=true)
Definition: shellfs.cpp:31
Entry * _next
Definition: entries.h:92
GLint level
Definition: gl.h:1546
struct _CONTEXT CONTEXT
const CHAR * LPCTSTR
Definition: xmlstorage.h:193
#define CloseHandle
Definition: compat.h:398
ShellEntry(Entry *parent, LPITEMIDLIST shell_path)
Definition: shellfs.h:32
FileTypeManager _ftype_mgr
Definition: globals.h:284
WIN32_FIND_DATA _data
Definition: entries.h:100
#define _tcsicmp
Definition: xmlstorage.h:205
POINT last
Definition: font.c:46
int _tcscmp(const _TCHAR *s1, const _TCHAR *s2)
Definition: tcscmp.h:8
const GLint * attribs
Definition: glext.h:10538
BY_HANDLE_FILE_INFORMATION _bhfi
Definition: entries.h:110
uint8_t entry
Definition: isohybrid.c:63
const ITEMIDLIST UNALIGNED * LPCITEMIDLIST
Definition: shtypes.idl:42
#define INVALID_HANDLE_VALUE
Definition: compat.h:391
_TCHAR * _tcscpy(_TCHAR *to, const _TCHAR *from)
Definition: tcscpy.h:8
GLuint buffer
Definition: glext.h:5915
#define _tcsdup
Definition: tchar.h:625
#define FILE_SHARE_WRITE
Definition: nt_native.h:681
#define _MAX_FNAME
Definition: utility.h:74
int _icon_id
Definition: entries.h:108
CHAR * LPTSTR
Definition: xmlstorage.h:192
#define FILE_SHARE_READ
Definition: compat.h:125
Exception with context information.
Definition: shellclasses.h:113
GLuint n
Definition: s_context.h:57
HRESULT name_from_pidl(IShellFolder *folder, LPCITEMIDLIST pidl, LPTSTR buffer, int len, SHGDNF flags)
wrapper class for enumerating shell namespace objects
#define e
Definition: ke_i.h:82
bool _bhfi_valid
Definition: entries.h:111
#define _MAX_PATH
Definition: utility.h:77
#define S_FALSE
Definition: winerror.h:2357
size_t __cdecl _tcslen(const _TCHAR *str)
Definition: tcslen.h:9
smooth NULL
Definition: ftsmooth.c:416
char ext[3]
Definition: mkdosfs.c:358
#define FETCH_ITEM_COUNT
#define FindFirstFile
Definition: winbase.h:3596
#define OPEN_EXISTING
Definition: compat.h:426
#define FILE_ATTRIBUTE_DIRECTORY
Definition: nt_native.h:705
void HandleException(COMException &e, HWND hwnd)
Exception Handler for COM exceptions.
char TCHAR
Definition: xmlstorage.h:189
#define _T(x)
Definition: vfdio.h:22
int safe_extract_icon(ICONCACHE_FLAGS flags=ICF_NORMAL)
Definition: entries.cpp:431
BOOL WINAPI GetFileInformationByHandle(HANDLE hFile, LPBY_HANDLE_FILE_INFORMATION lpFileInformation)
Definition: fileinfo.c:608
LONG HRESULT
Definition: typedefs.h:77
#define FindNextFile
Definition: winbase.h:3602
Entry * _down
Definition: entries.h:93
LPCTSTR set_type(struct Entry *entry, bool dont_hide_ext=false)
Definition: explorer.cpp:213
#define MAX_PATH
Definition: compat.h:26
#define FILE_ATTRIBUTE_READONLY
Definition: nt_native.h:702
unsigned long DWORD
Definition: ntddk_ex.h:95
#define FILE_ATTRIBUTE_COMPRESSED
Definition: nt_native.h:711
#define FILE_SHARE_DELETE
Definition: nt_native.h:682
SFGAOF _shell_attribs
Definition: entries.h:102
ShellFolder _folder
Definition: shellfs.h:112
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
ExplorerGlobals g_Globals
Definition: explorer.cpp:52
ShellDirectory(ShellFolder &root_folder, const ShellPath &shell_path, HWND hwnd)
Definition: shellfs.h:55
Windows file system file-entry.
Definition: winfs.h:32
#define GENERIC_READ
Definition: compat.h:124
_In_ HANDLE hFile
Definition: mswsock.h:90
int _level
Definition: entries.h:98
#define S_OK
Definition: intsafe.h:59
#define TEXT(s)
Definition: k32.h:26
#define path_from_pidl
Definition: shellclasses.h:628
IN OUT PVCB OUT PDIRENT OUT PBCB IN BOOLEAN CreateFile
Definition: fatprocs.h:904
#define lstrcpy
Definition: winbase.h:3688
Definition: services.c:325
#define FILE_ATTRIBUTE_HIDDEN
Definition: nt_native.h:703
bool _scanned
Definition: entries.h:97
Definition: name.c:36
#define FILE_FLAG_BACKUP_SEMANTICS
Definition: disk.h:41
virtual bool get_path(PTSTR path, size_t path_count) const
Definition: shellfs.cpp:155
unsigned int ULONG
Definition: retypes.h:1
#define COUNTOF(x)
Definition: utility.h:93
Windows file system directory-entry.
Definition: winfs.h:45
GLfloat GLfloat p
Definition: glext.h:8902
#define memset(x, y, z)
Definition: compat.h:39
ITEMIDLIST UNALIGNED * LPITEMIDLIST
Definition: shtypes.idl:41
int _tcsncmp(const _TCHAR *s1, const _TCHAR *s2, size_t n)
Definition: tcsncmp.h:9
#define ATTRIBUTE_SYMBOLIC_LINK
Definition: entries.h:62
base of all file and directory entries
Definition: entries.h:82
static IShellFolder IShellItem **static IBindCtx LPITEMIDLIST SFGAOF
Definition: ebrowser.c:83
#define SUCCEEDED(hr)
Definition: intsafe.h:57
LPTSTR _display_name
Definition: entries.h:103
BOOL WINAPI FindClose(HANDLE hFindFile)
Definition: find.c:502

Member Data Documentation

◆ _folder

◆ _hwnd

HWND ShellDirectory::_hwnd

Definition at line 113 of file shellfs.h.

Referenced by read_directory().


The documentation for this struct was generated from the following files: