ReactOS 0.4.15-dev-7924-g5949c20
CDirectoryList.cpp
Go to the documentation of this file.
1/*
2 * PROJECT: shell32
3 * LICENSE: LGPL-2.1-or-later (https://spdx.org/licenses/LGPL-2.1-or-later)
4 * PURPOSE: Shell change notification
5 * COPYRIGHT: Copyright 2020 Katayama Hirofumi MZ (katayama.hirofumi.mz@gmail.com)
6 */
7#include "shelldesktop.h"
8#include "CDirectoryList.h"
9#include <assert.h> // for assert
10
12
14{
15 assert(!PathIsRelativeW(pszPath));
16
17 for (INT i = 0; i < m_items.GetSize(); ++i)
18 {
19 if (m_items[i].IsEmpty())
20 continue;
21
22 if (m_items[i].EqualPath(pszPath))
23 return TRUE; // matched
24 }
25 return FALSE;
26}
27
29{
30 assert(!PathIsRelativeW(pszPath));
31 if (ContainsPath(pszPath))
32 return FALSE;
33 for (INT i = 0; i < m_items.GetSize(); ++i)
34 {
35 if (m_items[i].IsEmpty())
36 {
37 m_items[i].SetPath(pszPath);
38 return TRUE;
39 }
40 }
41 return m_items.Add(pszPath);
42}
43
45{
46 assert(!PathIsRelativeW(pszPath1));
47 assert(!PathIsRelativeW(pszPath2));
48
49 for (INT i = 0; i < m_items.GetSize(); ++i)
50 {
51 if (m_items[i].EqualPath(pszPath1))
52 {
53 // matched
54 m_items[i].SetPath(pszPath2);
55 return TRUE;
56 }
57 }
58 return FALSE;
59}
60
62{
63 assert(!PathIsRelativeW(pszPath));
64
65 for (INT i = 0; i < m_items.GetSize(); ++i)
66 {
67 if (m_items[i].EqualPath(pszPath))
68 {
69 // matched
70 m_items[i].SetPath(NULL);
71 return TRUE;
72 }
73 }
74 return FALSE;
75}
76
78{
79 // get the full path
81 lstrcpynW(szPath, pszDirectoryPath, _countof(szPath));
83
84 // is it a directory?
86 return FALSE;
87
88 // add the path
89 if (!AddPath(szPath))
90 return FALSE;
91
92 // enumerate the file items to remember
93 PathAppendW(szPath, L"*");
96 if (hFind == INVALID_HANDLE_VALUE)
97 {
98 ERR("FindFirstFileW failed\n");
99 return FALSE;
100 }
101
102 LPWSTR pch;
103 do
104 {
105 // ignore "." and ".."
106 pch = find.cFileName;
107 if (pch[0] == L'.' && (pch[1] == 0 || (pch[1] == L'.' && pch[2] == 0)))
108 continue;
109
110 // build a path
112 if (lstrlenW(szPath) + lstrlenW(find.cFileName) + 1 > MAX_PATH)
113 {
114 ERR("szPath is too long\n");
115 continue;
116 }
117 PathAppendW(szPath, find.cFileName);
118
119 // add the path and do recurse
120 if (find.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
121 {
122 if (m_fRecursive)
124 else
126 }
127 } while (FindNextFileW(hFind, &find));
128
129 FindClose(hFind);
130
131 return TRUE;
132}
#define WINE_DEFAULT_DEBUG_CHANNEL(t)
Definition: precomp.h:23
#define ERR(fmt,...)
Definition: debug.h:110
BOOL AddPath(LPCWSTR pszPath)
BOOL ContainsPath(LPCWSTR pszPath) const
CSimpleArray< CDirectoryItem > m_items
BOOL DeletePath(LPCWSTR pszPath)
BOOL AddPathsFromDirectory(LPCWSTR pszDirectoryPath)
BOOL RenamePath(LPCWSTR pszPath1, LPCWSTR pszPath2)
static TAGID TAGID find
Definition: db.cpp:155
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
@ IsEmpty
Definition: atl_ax.c:995
#define INVALID_HANDLE_VALUE
Definition: compat.h:731
#define MAX_PATH
Definition: compat.h:34
#define lstrcpynW
Definition: compat.h:738
#define lstrlenW
Definition: compat.h:750
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
BOOL WINAPI PathRemoveFileSpecW(LPWSTR lpszPath)
Definition: path.c:629
BOOL WINAPI PathIsDirectoryW(LPCWSTR lpszPath)
Definition: path.c:1723
BOOL WINAPI PathIsRelativeW(LPCWSTR lpszPath)
Definition: path.c:1579
#define assert(x)
Definition: debug.h:53
unsigned int BOOL
Definition: ntddk_ex.h:94
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 pch(ap)
Definition: match.c:418
LPCWSTR szPath
Definition: env.c:37
#define FILE_ATTRIBUTE_DIRECTORY
Definition: nt_native.h:705
#define L(x)
Definition: ntvdm.h:50
#define PathAppendW
Definition: pathcch.h:309
#define _countof(array)
Definition: sndvol32.h:68
int32_t INT
Definition: typedefs.h:58
__wchar_t WCHAR
Definition: xmlstorage.h:180
WCHAR * LPWSTR
Definition: xmlstorage.h:184
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185