ReactOS 0.4.16-dev-1025-gd3456f5
CFindFolder.cpp File Reference
#include "CFindFolder.h"
#include <exdispid.h>
Include dependency graph for CFindFolder.cpp:

Go to the source code of this file.

Classes

struct  FolderViewColumns
 
struct  _SearchData
 
class  CFindFolderContextMenu
 

Macros

#define IS_TEXT_UNKNOWN_FLAGS_MASK   ((7 << 13) | (1 << 11))
 
#define IS_DOTS(psz)   ((psz)[0] == L'.' && ((psz)[1] == 0 || ((psz)[1] == L'.' && (psz)[2] == 0)))
 

Enumerations

enum  ENCODING {
  ENCODING_ANSI = 0 , ENCODING_UTF16LE = 1 , ENCODING_UTF16BE = 2 , ENCODING_UTF8 = 3 ,
  ENCODING_AUTO = -1 , ENCODING_ANSI = 0 , ENCODING_UTF16LE = 1 , ENCODING_UTF16BE = 2 ,
  ENCODING_UTF8 = 3 , ENCODING_UTF8BOM = 4 , ENCODING_ANSI = 0 , ENCODING_UTF16LE = 1 ,
  ENCODING_UTF16BE = 2 , ENCODING_UTF8 = 3 , ENCODING_ANSI = 1 , ENCODING_UTF8 ,
  ENCODING_UTF16LE , ENCODING_UTF16BE
}
 

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (shellfind)
 
static HRESULT SHELL32_CoCreateInitSF (LPCITEMIDLIST pidlRoot, PERSIST_FOLDER_TARGET_INFO *ppfti, LPCITEMIDLIST pidlChild, const GUID *clsid, REFIID riid, LPVOID *ppvOut)
 
static void WINAPI _InsertMenuItemW (HMENU hMenu, UINT indexMenu, BOOL fByPosition, UINT wID, UINT fType, LPCWSTR dwTypeData, UINT fState)
 
static LPITEMIDLIST _ILCreate (LPCWSTR lpszPath)
 
static LPCWSTR _ILGetPath (LPCITEMIDLIST pidl)
 
static LPCITEMIDLIST _ILGetFSPidl (LPCITEMIDLIST pidl)
 
static PIDLIST_ABSOLUTE _ILCreateAbsolute (LPCITEMIDLIST pidlChild)
 
static int CALLBACK ILFreeHelper (void *pItem, void *pCaller)
 
template<typename TChar , typename TString , int(&)(const TChar *, const TChar *, size_t) StrNCmp>
static const TChar * StrStrN (const TChar *lpFirst, const TString &lpSrch, UINT cchMax)
 
static BOOL StrFindNIA (const CHAR *lpFirst, const CStringA &lpSrch, UINT cchMax)
 
static BOOL StrFindNIW (const WCHAR *lpFirst, const CStringW &lpSrch, UINT cchMax)
 
static BOOL IsDataUnicode (IN PVOID Buffer, IN DWORD BufferSize, OUT ENCODING *Encoding OPTIONAL, OUT PDWORD SkipBytes OPTIONAL)
 
static BOOL SearchFile (LPCWSTR lpFilePath, _SearchData *pSearchData)
 
static BOOL FileNameMatch (LPCWSTR FindDataFileName, _SearchData *pSearchData)
 
static BOOL ContentsMatch (LPCWSTR szPath, _SearchData *pSearchData)
 
static BOOL AttribHiddenMatch (DWORD FileAttributes, _SearchData *pSearchData)
 
static UINT RecursiveFind (LPCWSTR lpPath, _SearchData *pSearchData)
 

Variables

static const FolderViewColumns g_ColumnDefs []
 

Macro Definition Documentation

◆ IS_DOTS

#define IS_DOTS (   psz)    ((psz)[0] == L'.' && ((psz)[1] == 0 || ((psz)[1] == L'.' && (psz)[2] == 0)))

◆ IS_TEXT_UNKNOWN_FLAGS_MASK

#define IS_TEXT_UNKNOWN_FLAGS_MASK   ((7 << 13) | (1 << 11))

Enumeration Type Documentation

◆ ENCODING

Enumerator
ENCODING_ANSI 
ENCODING_UTF16LE 
ENCODING_UTF16BE 
ENCODING_UTF8 
ENCODING_AUTO 
ENCODING_ANSI 
ENCODING_UTF16LE 
ENCODING_UTF16BE 
ENCODING_UTF8 
ENCODING_UTF8BOM 
ENCODING_ANSI 
ENCODING_UTF16LE 
ENCODING_UTF16BE 
ENCODING_UTF8 
ENCODING_ANSI 
ENCODING_UTF8 
ENCODING_UTF16LE 
ENCODING_UTF16BE 

Definition at line 271 of file CFindFolder.cpp.

272{
273 ENCODING_ANSI = 0,
276 ENCODING_UTF8 = 3
277} ENCODING;
ENCODING
@ ENCODING_UTF16BE
@ ENCODING_UTF8
@ ENCODING_UTF16LE
@ ENCODING_ANSI

Function Documentation

◆ _ILCreate()

static LPITEMIDLIST _ILCreate ( LPCWSTR  lpszPath)
static

Definition at line 100 of file CFindFolder.cpp.

101{
102 CComHeapPtr<ITEMIDLIST> lpFSPidl(ILCreateFromPathW(lpszPath));
103 if (!lpFSPidl)
104 {
105 ERR("Failed to create pidl from path\n");
106 return NULL;
107 }
108 LPITEMIDLIST lpLastFSPidl = ILFindLastID(lpFSPidl);
109
110 SIZE_T cbPath = (PathFindFileNameW(lpszPath) - lpszPath + 1) * sizeof(WCHAR);
111 SIZE_T cbData = sizeof(WORD) + cbPath + lpLastFSPidl->mkid.cb;
112 if (cbData > 0xffff)
113 return NULL;
114 LPITEMIDLIST pidl = (LPITEMIDLIST) SHAlloc(cbData + sizeof(WORD));
115 if (!pidl)
116 return NULL;
117
118 LPBYTE p = (LPBYTE) pidl;
119 p += sizeof(WORD); // mkid.cb
120
121 PWSTR path = (PWSTR)p;
122 memcpy(p, lpszPath, cbPath);
123 p += cbPath;
124 ((PWSTR)p)[-1] = UNICODE_NULL; // "C:\" not "C:" (required by ILCreateFromPathW and matches Windows)
125 if (!PathIsRootW(path))
126 {
127 p -= sizeof(WCHAR);
128 ((PWSTR)p)[-1] = UNICODE_NULL; // "C:\folder"
129 }
130
131 memcpy(p, lpLastFSPidl, lpLastFSPidl->mkid.cb);
132 p += lpLastFSPidl->mkid.cb;
133
134 pidl->mkid.cb = p - (LPBYTE)pidl;
135 ((LPITEMIDLIST)p)->mkid.cb = 0; // Terminator
136 return pidl;
137}
#define ERR(fmt,...)
Definition: precomp.h:57
#define NULL
Definition: types.h:112
LPVOID WINAPI SHAlloc(SIZE_T len)
Definition: shellole.c:304
LPWSTR WINAPI PathFindFileNameW(LPCWSTR lpszPath)
Definition: path.c:394
BOOL WINAPI PathIsRootW(LPCWSTR lpszPath)
Definition: path.c:1648
unsigned short WORD
Definition: ntddk_ex.h:93
GLfloat GLfloat p
Definition: glext.h:8902
if(dx< 0)
Definition: linetemp.h:194
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
#define UNICODE_NULL
LPITEMIDLIST WINAPI ILFindLastID(LPCITEMIDLIST pidl)
Definition: pidl.c:198
LPITEMIDLIST WINAPI ILCreateFromPathW(LPCWSTR path)
Definition: pidl.c:1101
ITEMIDLIST UNALIGNED * LPITEMIDLIST
Definition: shtypes.idl:41
uint16_t * PWSTR
Definition: typedefs.h:56
unsigned char * LPBYTE
Definition: typedefs.h:53
ULONG_PTR SIZE_T
Definition: typedefs.h:80
__wchar_t WCHAR
Definition: xmlstorage.h:180

◆ _ILCreateAbsolute()

static PIDLIST_ABSOLUTE _ILCreateAbsolute ( LPCITEMIDLIST  pidlChild)
static

Definition at line 154 of file CFindFolder.cpp.

155{
156 PIDLIST_ABSOLUTE pidl = NULL;
157 if (PIDLIST_ABSOLUTE pidlFolder = SHSimpleIDListFromPath(_ILGetPath(pidl))) // FIXME: SHELL32_CreateSimpleIDListFromPath(, DIRECTORY)
158 {
159 pidl = ILCombine(pidlFolder, _ILGetFSPidl(pidl));
160 ILFree(pidlFolder);
161 }
162 return pidl;
163}
static LPCWSTR _ILGetPath(LPCITEMIDLIST pidl)
static LPCITEMIDLIST _ILGetFSPidl(LPCITEMIDLIST pidl)
void WINAPI ILFree(LPITEMIDLIST pidl)
Definition: pidl.c:1044
LPITEMIDLIST WINAPI ILCombine(LPCITEMIDLIST pidl1, LPCITEMIDLIST pidl2)
Definition: pidl.c:816
PIDLIST_ABSOLUTE WINAPI SHSimpleIDListFromPath(PCWSTR)

Referenced by CFindFolder::CreateAbsolutePidlArray().

◆ _ILGetFSPidl()

static LPCITEMIDLIST _ILGetFSPidl ( LPCITEMIDLIST  pidl)
static

Definition at line 146 of file CFindFolder.cpp.

147{
148 if (!pidl || !pidl->mkid.cb)
149 return pidl;
150 return (LPCITEMIDLIST) ((LPBYTE) pidl->mkid.abID
151 + ((wcslen((LPCWSTR) pidl->mkid.abID) + 1) * sizeof(WCHAR)));
152}
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
const ITEMIDLIST UNALIGNED * LPCITEMIDLIST
Definition: shtypes.idl:42
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185

Referenced by _ILCreateAbsolute(), CFindFolder::CompareIDs(), CFindFolder::GetFSFolderAndChild(), CFindFolder::GetUIObjectOf(), and CFindFolderContextMenu::InvokeCommand().

◆ _ILGetPath()

static LPCWSTR _ILGetPath ( LPCITEMIDLIST  pidl)
static

◆ _InsertMenuItemW()

static void WINAPI _InsertMenuItemW ( HMENU  hMenu,
UINT  indexMenu,
BOOL  fByPosition,
UINT  wID,
UINT  fType,
LPCWSTR  dwTypeData,
UINT  fState 
)
static

Definition at line 40 of file CFindFolder.cpp.

48{
49 MENUITEMINFOW mii;
50 WCHAR wszText[100];
51
52 ZeroMemory(&mii, sizeof(mii));
53 mii.cbSize = sizeof(mii);
54 if (fType == MFT_SEPARATOR)
55 mii.fMask = MIIM_ID | MIIM_TYPE;
56 else if (fType == MFT_STRING)
57 {
59 if (IS_INTRESOURCE(dwTypeData))
60 {
61 if (LoadStringW(_AtlBaseModule.GetResourceInstance(), LOWORD((ULONG_PTR)dwTypeData), wszText, _countof(wszText)))
62 mii.dwTypeData = wszText;
63 else
64 {
65 ERR("failed to load string %p\n", dwTypeData);
66 return;
67 }
68 }
69 else
70 mii.dwTypeData = (LPWSTR)dwTypeData;
71 mii.fState = fState;
72 }
73
74 mii.wID = wID;
75 mii.fType = fType;
76 InsertMenuItemW(hMenu, indexMenu, fByPosition, &mii);
77}
#define LOWORD(l)
Definition: pedump.c:82
#define _countof(array)
Definition: sndvol32.h:70
LPWSTR dwTypeData
Definition: winuser.h:3280
uint32_t ULONG_PTR
Definition: typedefs.h:65
#define ZeroMemory
Definition: winbase.h:1743
#define MIIM_ID
Definition: winuser.h:733
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)
#define IS_INTRESOURCE(i)
Definition: winuser.h:580
#define MFT_SEPARATOR
Definition: winuser.h:755
#define MIIM_STATE
Definition: winuser.h:732
#define MFT_STRING
Definition: winuser.h:757
#define MIIM_TYPE
Definition: winuser.h:736
BOOL WINAPI InsertMenuItemW(_In_ HMENU, _In_ UINT, _In_ BOOL, _In_ LPCMENUITEMINFOW)
WCHAR * LPWSTR
Definition: xmlstorage.h:184

Referenced by CFindFolderContextMenu::QueryContextMenu().

◆ AttribHiddenMatch()

static BOOL AttribHiddenMatch ( DWORD  FileAttributes,
_SearchData pSearchData 
)
static

Definition at line 472 of file CFindFolder.cpp.

473{
474 if (!(FileAttributes & FILE_ATTRIBUTE_HIDDEN) || (pSearchData->SearchHidden))
475 {
476 return TRUE;
477 }
478 return FALSE;
479}
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
_Must_inspect_result_ _In_opt_ PFLT_INSTANCE _Out_ PHANDLE _In_ ACCESS_MASK _In_ POBJECT_ATTRIBUTES _Out_ PIO_STATUS_BLOCK _In_opt_ PLARGE_INTEGER _In_ ULONG FileAttributes
Definition: fltkernel.h:1236
#define FILE_ATTRIBUTE_HIDDEN
Definition: nt_native.h:703

Referenced by RecursiveFind().

◆ ContentsMatch()

static BOOL ContentsMatch ( LPCWSTR  szPath,
_SearchData pSearchData 
)
static

Definition at line 463 of file CFindFolder.cpp.

464{
465 if (pSearchData->szQueryA.IsEmpty() || SearchFile(szPath, pSearchData))
466 {
467 return TRUE;
468 }
469 return FALSE;
470}
static BOOL SearchFile(LPCWSTR lpFilePath, _SearchData *pSearchData)
bool IsEmpty() const noexcept
Definition: atlsimpstr.h:394
LPCWSTR szPath
Definition: env.c:37
CStringA szQueryA

Referenced by RecursiveFind().

◆ FileNameMatch()

static BOOL FileNameMatch ( LPCWSTR  FindDataFileName,
_SearchData pSearchData 
)
static

Definition at line 454 of file CFindFolder.cpp.

455{
456 if (pSearchData->szFileName.IsEmpty() || PathMatchSpecW(FindDataFileName, pSearchData->szFileName))
457 {
458 return TRUE;
459 }
460 return FALSE;
461}
BOOL WINAPI PathMatchSpecW(LPCWSTR lpszPath, LPCWSTR lpszMask)
Definition: path.c:1970
CStringW szFileName

Referenced by RecursiveFind().

◆ ILFreeHelper()

static int CALLBACK ILFreeHelper ( void pItem,
void pCaller 
)
static

Definition at line 190 of file CFindFolder.cpp.

191{
192 ILFree((LPITEMIDLIST)pItem);
193 return TRUE;
194}

Referenced by CFindFolder::FreePidlArray().

◆ IsDataUnicode()

static BOOL IsDataUnicode ( IN PVOID  Buffer,
IN DWORD  BufferSize,
OUT ENCODING *Encoding  OPTIONAL,
OUT PDWORD SkipBytes  OPTIONAL 
)
static

Definition at line 280 of file CFindFolder.cpp.

285{
286 PBYTE pBytes = (PBYTE)Buffer;
287 ENCODING encFile = ENCODING_ANSI;
288 DWORD dwPos = 0;
289
290 /*
291 * See http://archives.miloush.net/michkap/archive/2007/04/22/2239345.html
292 * for more details about the algorithm and the pitfalls behind it.
293 * Of course it would be actually great to make a nice function that
294 * would work, once and for all, and put it into a library.
295 */
296
297 /* Look for Byte Order Marks */
298 if ((BufferSize >= 2) && (pBytes[0] == 0xFF) && (pBytes[1] == 0xFE))
299 {
300 encFile = ENCODING_UTF16LE;
301 dwPos = 2;
302 }
303 else if ((BufferSize >= 2) && (pBytes[0] == 0xFE) && (pBytes[1] == 0xFF))
304 {
305 encFile = ENCODING_UTF16BE;
306 dwPos = 2;
307 }
308 else if ((BufferSize >= 3) && (pBytes[0] == 0xEF) && (pBytes[1] == 0xBB) && (pBytes[2] == 0xBF))
309 {
310 encFile = ENCODING_UTF8;
311 dwPos = 3;
312 }
313 else
314 {
315 /*
316 * Try using statistical analysis. Do not rely on the return value of
317 * IsTextUnicode as we can get FALSE even if the text is in UTF-16 BE
318 * (i.e. we have some of the IS_TEXT_UNICODE_REVERSE_MASK bits set).
319 * Instead, set all the tests we want to perform, then just check
320 * the passed tests and try to deduce the string properties.
321 */
322
323/*
324 * This mask contains the 3 highest bits from IS_TEXT_UNICODE_NOT_ASCII_MASK
325 * and the 1st highest bit from IS_TEXT_UNICODE_NOT_UNICODE_MASK.
326 */
327#define IS_TEXT_UNKNOWN_FLAGS_MASK ((7 << 13) | (1 << 11))
328
329 /* Flag out the unknown flags here, the passed tests will not have them either */
334 INT Results;
335
337 Results = Tests;
338
339 /*
340 * As the IS_TEXT_UNICODE_NULL_BYTES or IS_TEXT_UNICODE_ILLEGAL_CHARS
341 * flags are expected to be potentially present in the result without
342 * modifying our expectations, filter them out now.
343 */
345
346 /*
347 * NOTE: The flags IS_TEXT_UNICODE_ASCII16 and
348 * IS_TEXT_UNICODE_REVERSE_ASCII16 are not reliable.
349 *
350 * NOTE2: Check for potential "bush hid the facts" effect by also
351 * checking the original results (in 'Tests') for the absence of
352 * the IS_TEXT_UNICODE_NULL_BYTES flag, as we may presumably expect
353 * that in UTF-16 text there will be at some point some NULL bytes.
354 * If not, fall back to ANSI. This shows the limitations of using the
355 * IsTextUnicode API to perform such tests, and the usage of a more
356 * improved encoding detection algorithm would be really welcome.
357 */
358 if (!(Results & IS_TEXT_UNICODE_NOT_UNICODE_MASK) &&
359 !(Results & IS_TEXT_UNICODE_REVERSE_MASK) &&
360 (Results & IS_TEXT_UNICODE_UNICODE_MASK) &&
362 {
363 encFile = ENCODING_UTF16LE;
364 dwPos = (Results & IS_TEXT_UNICODE_SIGNATURE) ? 2 : 0;
365 }
366 else
367 if (!(Results & IS_TEXT_UNICODE_NOT_UNICODE_MASK) &&
368 !(Results & IS_TEXT_UNICODE_UNICODE_MASK) &&
369 (Results & IS_TEXT_UNICODE_REVERSE_MASK) &&
371 {
372 encFile = ENCODING_UTF16BE;
373 dwPos = (Results & IS_TEXT_UNICODE_REVERSE_SIGNATURE) ? 2 : 0;
374 }
375 else
376 {
377 /*
378 * Either 'Results' has neither of those masks set, as it can be
379 * the case for UTF-8 text (or ANSI), or it has both as can be the
380 * case when analysing pure binary data chunk. This is therefore
381 * invalid and we fall back to ANSI encoding.
382 * FIXME: In case of failure, assume ANSI (as long as we do not have
383 * correct tests for UTF8, otherwise we should do them, and at the
384 * very end, assume ANSI).
385 */
386 encFile = ENCODING_ANSI; // ENCODING_UTF8;
387 dwPos = 0;
388 }
389 }
390
391 if (Encoding)
392 *Encoding = encFile;
393 if (SkipBytes)
394 *SkipBytes = dwPos;
395
396 return (encFile != ENCODING_ANSI);
397}
#define IS_TEXT_UNKNOWN_FLAGS_MASK
struct test_data Tests[]
Definition: bufpool.h:45
BOOL WINAPI IsTextUnicode(IN CONST VOID *lpv, IN INT iSize, IN OUT LPINT lpiResult OPTIONAL)
Definition: unicode.c:27
unsigned long DWORD
Definition: ntddk_ex.h:95
ENCODING
Definition: more.c:493
BYTE * PBYTE
Definition: pedump.c:66
int32_t INT
Definition: typedefs.h:58
_In_ WDFMEMORY _Out_opt_ size_t * BufferSize
Definition: wdfmemory.h:254
#define IS_TEXT_UNICODE_ILLEGAL_CHARS
Definition: winnt_old.h:923
#define IS_TEXT_UNICODE_UNICODE_MASK
Definition: winnt_old.h:927
#define IS_TEXT_UNICODE_NOT_ASCII_MASK
Definition: winnt_old.h:930
#define IS_TEXT_UNICODE_NULL_BYTES
Definition: winnt_old.h:926
#define IS_TEXT_UNICODE_REVERSE_MASK
Definition: winnt_old.h:928
#define IS_TEXT_UNICODE_REVERSE_SIGNATURE
Definition: winnt_old.h:922
#define IS_TEXT_UNICODE_NOT_UNICODE_MASK
Definition: winnt_old.h:929
#define IS_TEXT_UNICODE_SIGNATURE
Definition: winnt_old.h:921
_Must_inspect_result_ _In_ PHYSICAL_ADDRESS _In_ PHYSICAL_ADDRESS SkipBytes
Definition: mmfuncs.h:227

Referenced by SearchFile().

◆ RecursiveFind()

static UINT RecursiveFind ( LPCWSTR  lpPath,
_SearchData pSearchData 
)
static

Definition at line 481 of file CFindFolder.cpp.

482{
483 if (WaitForSingleObject(pSearchData->hStopEvent, 0) != WAIT_TIMEOUT)
484 return 0;
485
487 WIN32_FIND_DATAW FindData;
488 HANDLE hFindFile;
489 BOOL bMoreFiles = TRUE;
490 UINT uTotalFound = 0;
491
492 PathCombineW(szPath, lpPath, L"*");
493
494 for (hFindFile = FindFirstFileW(szPath, &FindData);
495 bMoreFiles && hFindFile != INVALID_HANDLE_VALUE;
496 bMoreFiles = FindNextFileW(hFindFile, &FindData))
497 {
498#define IS_DOTS(psz) ((psz)[0] == L'.' && ((psz)[1] == 0 || ((psz)[1] == L'.' && (psz)[2] == 0)))
499 if (IS_DOTS(FindData.cFileName))
500 continue;
501
502 PathCombineW(szPath, lpPath, FindData.cFileName);
503
504 if (FindData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
505 {
507 if (pSearchData->szQueryW.IsEmpty() &&
508 FileNameMatch(FindData.cFileName, pSearchData) &&
509 AttribHiddenMatch(FindData.dwFileAttributes, pSearchData))
510 {
511 LPWSTR pszPathDup;
512 SHStrDupW(szPath, &pszPathDup);
513 PostMessageW(pSearchData->hwnd, WM_SEARCH_ADD_RESULT, 0, (LPARAM)pszPathDup);
514 uTotalFound++;
515 }
516 status.Format(IDS_SEARCH_FOLDER, FindData.cFileName);
517 LPWSTR pszStatusDup;
518 SHStrDupW(status.GetBuffer(), &pszStatusDup);
519 PostMessageW(pSearchData->hwnd, WM_SEARCH_UPDATE_STATUS, 0, (LPARAM)pszStatusDup);
520
521 uTotalFound += RecursiveFind(szPath, pSearchData);
522 }
523 else if (FileNameMatch(FindData.cFileName, pSearchData)
524 && AttribHiddenMatch(FindData.dwFileAttributes, pSearchData)
525 && ContentsMatch(szPath, pSearchData))
526 {
527 uTotalFound++;
528 LPWSTR pszPathDup;
529 SHStrDupW(szPath, &pszPathDup);
530 PostMessageW(pSearchData->hwnd, WM_SEARCH_ADD_RESULT, 0, (LPARAM)pszPathDup);
531 }
532 }
533
534 if (hFindFile != INVALID_HANDLE_VALUE)
535 FindClose(hFindFile);
536
537 return uTotalFound;
538}
static BOOL AttribHiddenMatch(DWORD FileAttributes, _SearchData *pSearchData)
static BOOL FileNameMatch(LPCWSTR FindDataFileName, _SearchData *pSearchData)
static BOOL ContentsMatch(LPCWSTR szPath, _SearchData *pSearchData)
#define IS_DOTS(psz)
static UINT RecursiveFind(LPCWSTR lpPath, _SearchData *pSearchData)
#define WAIT_TIMEOUT
Definition: dderror.h:14
#define IDS_SEARCH_FOLDER
Definition: resource.h:179
#define INVALID_HANDLE_VALUE
Definition: compat.h:731
#define MAX_PATH
Definition: compat.h:34
HANDLE WINAPI FindFirstFileW(IN LPCWSTR lpFileName, OUT LPWIN32_FIND_DATAW lpFindFileData)
Definition: find.c:320
BOOL WINAPI FindClose(HANDLE hFindFile)
Definition: find.c:502
BOOL WINAPI FindNextFileW(IN HANDLE hFindFile, OUT LPWIN32_FIND_DATAW lpFindFileData)
Definition: find.c:382
HRESULT WINAPI SHStrDupW(LPCWSTR src, LPWSTR *dest)
Definition: string.c:2018
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned int UINT
Definition: ndis.h:50
#define FILE_ATTRIBUTE_DIRECTORY
Definition: nt_native.h:705
#define L(x)
Definition: ntvdm.h:50
#define PathCombineW
Definition: pathcch.h:317
#define WM_SEARCH_ADD_RESULT
Definition: shellfind.h:31
#define WM_SEARCH_UPDATE_STATUS
Definition: shellfind.h:32
CStringW szQueryW
HANDLE hStopEvent
Definition: ps.c:97
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
Definition: synch.c:82
LONG_PTR LPARAM
Definition: windef.h:208
BOOL WINAPI PostMessageW(_In_opt_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)

Referenced by RecursiveFind(), and CFindFolder::SearchThreadProc().

◆ SearchFile()

static BOOL SearchFile ( LPCWSTR  lpFilePath,
_SearchData pSearchData 
)
static

Definition at line 399 of file CFindFolder.cpp.

400{
403 return FALSE;
404
405 // FIXME: support large file
407 if (size == 0 || size == INVALID_FILE_SIZE)
408 {
410 return FALSE;
411 }
412
415 if (hFileMap == INVALID_HANDLE_VALUE)
416 return FALSE;
417
418 LPBYTE pbContents = (LPBYTE)MapViewOfFile(hFileMap, FILE_MAP_READ, 0, 0, size);
419 CloseHandle(hFileMap);
420 if (!pbContents)
421 return FALSE;
422
424 IsDataUnicode(pbContents, size, &encoding, NULL);
425
426 BOOL bFound;
427 switch (encoding)
428 {
429 case ENCODING_UTF16LE:
430 // UTF-16
431 bFound = StrFindNIW((LPCWSTR)pbContents, pSearchData->szQueryW, size / sizeof(WCHAR));
432 break;
433 case ENCODING_UTF16BE:
434 // UTF-16 BE
435 bFound = StrFindNIW((LPCWSTR)pbContents, pSearchData->szQueryU16BE, size / sizeof(WCHAR));
436 break;
437 case ENCODING_UTF8:
438 // UTF-8
439 bFound = StrFindNIA((LPCSTR)pbContents, pSearchData->szQueryU8, size / sizeof(CHAR));
440 break;
441 case ENCODING_ANSI:
442 default:
443 // ANSI or UTF-8 without BOM
444 bFound = StrFindNIA((LPCSTR)pbContents, pSearchData->szQueryA, size / sizeof(CHAR));
445 if (!bFound && pSearchData->szQueryA != pSearchData->szQueryU8)
446 bFound = StrFindNIA((LPCSTR)pbContents, pSearchData->szQueryU8, size / sizeof(CHAR));
447 break;
448 }
449
450 UnmapViewOfFile(pbContents);
451 return bFound;
452}
static BOOL StrFindNIW(const WCHAR *lpFirst, const CStringW &lpSrch, UINT cchMax)
static BOOL IsDataUnicode(IN PVOID Buffer, IN DWORD BufferSize, OUT ENCODING *Encoding OPTIONAL, OUT PDWORD SkipBytes OPTIONAL)
static BOOL StrFindNIA(const CHAR *lpFirst, const CStringA &lpSrch, UINT cchMax)
#define CloseHandle
Definition: compat.h:739
#define PAGE_READONLY
Definition: compat.h:138
#define UnmapViewOfFile
Definition: compat.h:746
#define OPEN_EXISTING
Definition: compat.h:775
#define CreateFileMappingW(a, b, c, d, e, f)
Definition: compat.h:744
#define GENERIC_READ
Definition: compat.h:135
#define CreateFileW
Definition: compat.h:741
#define FILE_MAP_READ
Definition: compat.h:776
#define MapViewOfFile
Definition: compat.h:745
DWORD WINAPI GetFileSize(HANDLE hFile, LPDWORD lpFileSizeHigh)
Definition: fileinfo.c:331
GLsizeiptr size
Definition: glext.h:5919
_In_ HANDLE hFile
Definition: mswsock.h:90
#define FILE_ATTRIBUTE_READONLY
Definition: nt_native.h:702
CStringW szQueryU16BE
CStringA szQueryU8
#define INVALID_FILE_SIZE
Definition: winbase.h:574
static char * encoding
Definition: xmllint.c:155
const char * LPCSTR
Definition: xmlstorage.h:183
char CHAR
Definition: xmlstorage.h:175

Referenced by ContentsMatch().

◆ SHELL32_CoCreateInitSF()

static HRESULT SHELL32_CoCreateInitSF ( LPCITEMIDLIST  pidlRoot,
PERSIST_FOLDER_TARGET_INFO *  ppfti,
LPCITEMIDLIST  pidlChild,
const GUID clsid,
REFIID  riid,
LPVOID ppvOut 
)
static

Definition at line 13 of file CFindFolder.cpp.

15{
16 HRESULT hr;
17 CComPtr<IShellFolder> pShellFolder;
18
20 if (FAILED(hr))
21 return hr;
22
23 LPITEMIDLIST pidlAbsolute = ILCombine (pidlRoot, pidlChild);
26
27 if (ppfti && SUCCEEDED(pShellFolder->QueryInterface(IID_PPV_ARG(IPersistFolder3, &ppf3))))
28 {
29 ppf3->InitializeEx(NULL, pidlAbsolute, ppfti);
30 }
31 else if (SUCCEEDED(pShellFolder->QueryInterface(IID_PPV_ARG(IPersistFolder, &ppf))))
32 {
33 ppf->Initialize(pidlAbsolute);
34 }
35 ILFree (pidlAbsolute);
36
37 return pShellFolder->QueryInterface(riid, ppvOut);
38}
HRESULT WINAPI SHCoCreateInstance(LPCWSTR aclsid, const CLSID *clsid, LPUNKNOWN pUnkOuter, REFIID refiid, LPVOID *ppv)
Definition: shellole.c:105
REFIID riid
Definition: atlbase.h:39
#define SUCCEEDED(hr)
Definition: intsafe.h:50
#define FAILED(hr)
Definition: intsafe.h:51
REFCLSID clsid
Definition: msctf.c:82
HRESULT hr
Definition: shlfolder.c:183
#define IID_PPV_ARG(Itype, ppType)

Referenced by CMyDocsFolder::EnsureFolder(), CDesktopFolder::FinalConstruct(), CRecycleBin::GetFSFolderForItem(), CFindFolder::Initialize(), CAdminToolsFolder::Initialize(), and CFontsFolder::Initialize().

◆ StrFindNIA()

static BOOL StrFindNIA ( const CHAR lpFirst,
const CStringA lpSrch,
UINT  cchMax 
)
inlinestatic

Definition at line 257 of file CFindFolder.cpp.

258{
259 return StrStrN<CHAR, CStringA, _strnicmp>(lpFirst, lpSrch, cchMax) != NULL;
260}
UINT cchMax

Referenced by SearchFile().

◆ StrFindNIW()

static BOOL StrFindNIW ( const WCHAR lpFirst,
const CStringW lpSrch,
UINT  cchMax 
)
inlinestatic

Definition at line 263 of file CFindFolder.cpp.

264{
265 return StrStrN<WCHAR, CStringW, _wcsnicmp>(lpFirst, lpSrch, cchMax) != NULL;
266}

Referenced by SearchFile().

◆ StrStrN()

template<typename TChar , typename TString , int(&)(const TChar *, const TChar *, size_t) StrNCmp>
static const TChar * StrStrN ( const TChar *  lpFirst,
const TString lpSrch,
UINT  cchMax 
)
static

Definition at line 242 of file CFindFolder.cpp.

243{
244 if (!lpFirst || lpSrch.IsEmpty() || !cchMax)
245 return NULL;
246
247 for (UINT i = cchMax; i > 0 && *lpFirst; i--, lpFirst++)
248 {
249 if (!StrNCmp(lpFirst, lpSrch, lpSrch.GetLength()))
250 return (const TChar*)lpFirst;
251 }
252
253 return NULL;
254}
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define StrNCmp
Definition: shlwapi.h:1559

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( shellfind  )

Variable Documentation

◆ g_ColumnDefs

const FolderViewColumns g_ColumnDefs[]
static
Initial value:
=
{
}
#define IDS_COL_NAME
Definition: resource.h:17
#define IDS_COL_RELEVANCE
Definition: resource.h:177
#define IDS_COL_LOCATION
Definition: resource.h:176
#define LVCFMT_LEFT
Definition: commctrl.h:2603
@ SHCOLSTATE_TYPE_STR
Definition: shtypes.idl:121
@ SHCOLSTATE_ONBYDEFAULT
Definition: shtypes.idl:125

Definition at line 87 of file CFindFolder.cpp.