reactos/dll/win32/shell32/shelldesktop/CDirectoryList.h
Katayama Hirofumi MZ d55f49978d
Revert "[SHELL32] SHChangeNotify: Use tree for CDirectoryList (#6784)" (#6800)
Reverts #6784 that was a guilty commit of CORE-19531 that causing performance regression.

JIRA issue: CORE-19531
2024-04-25 09:01:21 +09:00

94 lines
1.8 KiB
C++

#pragma once
#include <atlsimpcoll.h> // for CSimpleArray
//////////////////////////////////////////////////////////////////////////////
// A pathname with info
class CDirectoryItem
{
public:
CDirectoryItem() : m_pszPath(NULL)
{
}
CDirectoryItem(LPCWSTR pszPath)
{
m_pszPath = _wcsdup(pszPath);
}
CDirectoryItem(const CDirectoryItem& item)
: m_pszPath(_wcsdup(item.m_pszPath))
{
}
CDirectoryItem& operator=(const CDirectoryItem& item)
{
if (this != &item)
{
free(m_pszPath);
m_pszPath = _wcsdup(item.m_pszPath);
}
return *this;
}
~CDirectoryItem()
{
free(m_pszPath);
}
BOOL IsEmpty() const
{
return m_pszPath == NULL;
}
LPCWSTR GetPath() const
{
return m_pszPath;
}
void SetPath(LPCWSTR pszPath)
{
free(m_pszPath);
m_pszPath = _wcsdup(pszPath);
}
BOOL EqualPath(LPCWSTR pszPath) const
{
return m_pszPath != NULL && lstrcmpiW(m_pszPath, pszPath) == 0;
}
protected:
LPWSTR m_pszPath; // A full path, malloc'ed
};
// the directory list
class CDirectoryList
{
public:
CDirectoryList() : m_fRecursive(FALSE)
{
}
CDirectoryList(LPCWSTR pszDirectoryPath, BOOL fRecursive)
: m_fRecursive(fRecursive)
{
AddPathsFromDirectory(pszDirectoryPath);
}
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()
{
m_items.RemoveAll();
}
protected:
BOOL m_fRecursive;
CSimpleArray<CDirectoryItem> m_items;
};