ReactOS 0.4.16-dev-106-g10b08aa
CDirectoryList Class Reference

#include <CDirectoryList.h>

Collaboration diagram for CDirectoryList:

Public Member Functions

 CDirectoryList ()
 
 CDirectoryList (LPCWSTR pszDirectoryPath, BOOL fRecursive)
 
BOOL ContainsPath (LPCWSTR pszPath) const
 
BOOL AddPath (LPCWSTR pszPath)
 
BOOL AddPathsFromDirectory (LPCWSTR pszDirectoryPath)
 
BOOL RenamePath (LPCWSTR pszPath1, LPCWSTR pszPath2)
 
BOOL DeletePath (LPCWSTR pszPath)
 
void RemoveAll ()
 

Protected Attributes

BOOL m_fRecursive
 
CSimpleArray< CDirectoryItemm_items
 

Detailed Description

Definition at line 66 of file CDirectoryList.h.

Constructor & Destructor Documentation

◆ CDirectoryList() [1/2]

CDirectoryList::CDirectoryList ( )
inline

Definition at line 69 of file CDirectoryList.h.

70 {
71 }
#define FALSE
Definition: types.h:117

◆ CDirectoryList() [2/2]

CDirectoryList::CDirectoryList ( LPCWSTR  pszDirectoryPath,
BOOL  fRecursive 
)
inline

Definition at line 73 of file CDirectoryList.h.

74 : m_fRecursive(fRecursive)
75 {
76 AddPathsFromDirectory(pszDirectoryPath);
77 }
BOOL AddPathsFromDirectory(LPCWSTR pszDirectoryPath)

Member Function Documentation

◆ AddPath()

BOOL CDirectoryList::AddPath ( LPCWSTR  pszPath)

Definition at line 28 of file CDirectoryList.cpp.

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}
BOOL ContainsPath(LPCWSTR pszPath) const
CSimpleArray< CDirectoryItem > m_items
#define TRUE
Definition: types.h:120
@ IsEmpty
Definition: atl_ax.c:995
BOOL WINAPI PathIsRelativeW(LPCWSTR lpszPath)
Definition: path.c:1579
#define assert(x)
Definition: debug.h:53
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
int32_t INT
Definition: typedefs.h:58

Referenced by AddPathsFromDirectory(), and CDirectoryWatcher::ProcessNotification().

◆ AddPathsFromDirectory()

BOOL CDirectoryList::AddPathsFromDirectory ( LPCWSTR  pszDirectoryPath)

Definition at line 77 of file CDirectoryList.cpp.

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 ERR(fmt,...)
Definition: precomp.h:57
BOOL AddPath(LPCWSTR pszPath)
static TAGID TAGID find
Definition: db.cpp:155
#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
#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:70
__wchar_t WCHAR
Definition: xmlstorage.h:180
WCHAR * LPWSTR
Definition: xmlstorage.h:184

Referenced by AddPathsFromDirectory(), and CDirectoryList().

◆ ContainsPath()

BOOL CDirectoryList::ContainsPath ( LPCWSTR  pszPath) const

Definition at line 13 of file CDirectoryList.cpp.

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}

Referenced by AddPath(), and CDirectoryWatcher::ProcessNotification().

◆ DeletePath()

BOOL CDirectoryList::DeletePath ( LPCWSTR  pszPath)

Definition at line 61 of file CDirectoryList.cpp.

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}
#define NULL
Definition: types.h:112

Referenced by CDirectoryWatcher::ProcessNotification().

◆ RemoveAll()

void CDirectoryList::RemoveAll ( )
inline

Definition at line 85 of file CDirectoryList.h.

86 {
87 m_items.RemoveAll();
88 }

◆ RenamePath()

BOOL CDirectoryList::RenamePath ( LPCWSTR  pszPath1,
LPCWSTR  pszPath2 
)

Definition at line 44 of file CDirectoryList.cpp.

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}

Referenced by CDirectoryWatcher::ProcessNotification().

Member Data Documentation

◆ m_fRecursive

BOOL CDirectoryList::m_fRecursive
protected

Definition at line 91 of file CDirectoryList.h.

Referenced by AddPathsFromDirectory().

◆ m_items

CSimpleArray<CDirectoryItem> CDirectoryList::m_items
protected

Definition at line 92 of file CDirectoryList.h.

Referenced by AddPath(), ContainsPath(), DeletePath(), RemoveAll(), and RenamePath().


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