Exemplo n.º 1
0
int CALLBACK CShellBrowser::SortByType(int InternalIndex1,int InternalIndex2) const
{
	if(m_bVirtualFolder)
	{
		TCHAR FullFileName1[MAX_PATH];
		LPITEMIDLIST pidlComplete1 = ILCombine(m_pidlDirectory,m_pExtraItemInfo[InternalIndex1].pridl);
		GetDisplayName(pidlComplete1,FullFileName1,SHGDN_FORPARSING);
		CoTaskMemFree(pidlComplete1);

		TCHAR FullFileName2[MAX_PATH];
		LPITEMIDLIST pidlComplete2 = ILCombine(m_pidlDirectory,m_pExtraItemInfo[InternalIndex2].pridl);
		GetDisplayName(pidlComplete2,FullFileName2,SHGDN_FORPARSING);
		CoTaskMemFree(pidlComplete2);

		BOOL IsRoot1 = PathIsRoot(FullFileName1);
		BOOL IsRoot2 = PathIsRoot(FullFileName2);

		if(IsRoot1 && !IsRoot2)
		{
			return -1;
		}
		else if(!IsRoot1 && IsRoot2)
		{
			return 1;
		}
	}

	std::wstring Type1 = GetTypeColumnText(InternalIndex1);
	std::wstring Type2 = GetTypeColumnText(InternalIndex2);

	return StrCmpLogicalW(Type1.c_str(),Type2.c_str());
}
Exemplo n.º 2
0
int CALLBACK CShellBrowser::SortByType(const BasicItemInfo_t &itemInfo1, const BasicItemInfo_t &itemInfo2) const
{
	if(m_bVirtualFolder)
	{
		TCHAR FullFileName1[MAX_PATH];
		GetDisplayName(itemInfo1.pidlComplete.get(),FullFileName1,SIZEOF_ARRAY(FullFileName1),SHGDN_FORPARSING);

		TCHAR FullFileName2[MAX_PATH];
		GetDisplayName(itemInfo2.pidlComplete.get(),FullFileName2,SIZEOF_ARRAY(FullFileName2),SHGDN_FORPARSING);

		BOOL IsRoot1 = PathIsRoot(FullFileName1);
		BOOL IsRoot2 = PathIsRoot(FullFileName2);

		if(IsRoot1 && !IsRoot2)
		{
			return -1;
		}
		else if(!IsRoot1 && IsRoot2)
		{
			return 1;
		}
	}

	std::wstring Type1 = GetTypeColumnText(itemInfo1);
	std::wstring Type2 = GetTypeColumnText(itemInfo2);

	return StrCmpLogicalW(Type1.c_str(),Type2.c_str());
}
Exemplo n.º 3
0
int CALLBACK CShellBrowser::SortByName(const BasicItemInfo_t &itemInfo1, const BasicItemInfo_t &itemInfo2, const GlobalFolderSettings &globalFolderSettings) const
{
	if(m_bVirtualFolder)
	{
		BOOL IsRoot1 = PathIsRoot(itemInfo1.getFullPath().c_str());
		BOOL IsRoot2 = PathIsRoot(itemInfo2.getFullPath().c_str());

		if(IsRoot1 && !IsRoot2)
		{
			return -1;
		}
		else if(!IsRoot1 && IsRoot2)
		{
			return 1;
		}
		else if(IsRoot1 && IsRoot2)
		{
			/* If the items been compared are both drives,
			sort by drive letter, rather than display name. */
			return StrCmpLogicalW(itemInfo1.getFullPath().c_str(), itemInfo2.getFullPath().c_str());
		}
	}

	std::wstring Name1 = GetNameColumnText(itemInfo1, globalFolderSettings);
	std::wstring Name2 = GetNameColumnText(itemInfo2, globalFolderSettings);

	return StrCmpLogicalW(Name1.c_str(),Name2.c_str());
}
Exemplo n.º 4
0
//絶対パスの取得
bool UtilGetAbsPathName(CString &_FullPath,LPCTSTR lpszFileName)
{
	ASSERT(lpszFileName&&_tcslen(lpszFileName)>0);
	if(!lpszFileName||_tcslen(lpszFileName)<=0){
		TRACE(_T("ファイル名が指定されていない\n"));
		return false;
	}

	//---絶対パス取得
	TCHAR szAbsPath[_MAX_PATH+1]={0};
	{
		TCHAR Buffer[_MAX_PATH+1]={0};	//ルートかどうかのチェックを行う
		_tcsncpy_s(Buffer,lpszFileName,_MAX_PATH);
		PathAddBackslash(Buffer);
		if(PathIsRoot(Buffer)){
			//ドライブ名だけが指定されている場合、
			//_tfullpathはそのドライブのカレントディレクトリを取得してしまう
			_tcsncpy_s(szAbsPath,lpszFileName,_MAX_PATH);
		}
		else if(!_tfullpath(szAbsPath,lpszFileName,_MAX_PATH)){
			TRACE(_T("絶対パス取得失敗\n"));
			return false;
		}
	}

	_FullPath=szAbsPath;
	return true;
}
Exemplo n.º 5
0
/**
 * @brief Create complete log file name.
 * @param pszCompleteLogFileName - output complete file name.
 * @param pszLogFileName - base log file name.
 * @param pszDefFileExtension - default extension.
 * @return true if log file name was created and false otherwise.
 */
BOOL GetCompleteLogFileName(PTSTR pszCompleteLogFileName, PCTSTR pszLogFileName, PCTSTR pszDefFileExtension)
{
	if (pszLogFileName && *pszLogFileName && PathIsRoot(pszLogFileName))
	{
		_tcscpy_s(pszCompleteLogFileName, MAX_PATH, pszLogFileName);
		return TRUE;
	}
	TCHAR szAppDataPath[MAX_PATH];
	if (! SHGetSpecialFolderPath(NULL, szAppDataPath, CSIDL_APPDATA, TRUE))
		return FALSE;
	TCHAR szAppName[MAX_PATH];
	if (! GetCanonicalAppName(szAppName, countof(szAppName), TRUE))
		return FALSE;
	TCHAR szAppFileName[MAX_PATH];
	if (! GetModuleFileName(NULL, szAppFileName, countof(szAppFileName)))
		return FALSE;
	PTSTR pszFileName = PathFindFileName(szAppFileName);
	PathRemoveExtension(pszFileName);
	PTSTR pszAppName = *szAppName ? szAppName : pszFileName;
	PathCombine(pszCompleteLogFileName, szAppDataPath, pszAppName);
	if (pszLogFileName == NULL || *pszLogFileName == _T('\0'))
	{
		if (pszDefFileExtension == NULL || *pszDefFileExtension != _T('.'))
			return FALSE;
		PathAppend(pszCompleteLogFileName, pszFileName);
		PathAddExtension(pszCompleteLogFileName, pszDefFileExtension);
	}
	else
		PathAppend(pszCompleteLogFileName, pszLogFileName);
	return TRUE;
}
Exemplo n.º 6
0
static BOOL CreateFolder(LPCTSTR pszFolder)
{
	char *pszWork;

	pszWork = (char*)malloc(MAX_PATH);
	lstrcpy(pszWork, pszFolder);

	if (!PathFileExists(pszWork)) {
		if (PathIsRoot(pszWork)) {
			free(pszWork);
			return FALSE;
		}

		char *pszWork2;
		pszWork2 = (char *)malloc(MAX_PATH);
		lstrcpy(pszWork2, pszWork);
		PathAddBackslash(pszWork2);
		lstrcpy(pszWork2, "..");
		PathCanonicalize(pszWork, pszWork2);
		free(pszWork2);

		if (CreateFolder(pszWork)) {
			BOOL ret = CreateDirectory(pszFolder, NULL);
			free(pszWork);
			return ret;
		} else {
			free(pszWork);
			return FALSE;
		}
	}

	free(pszWork);

	return TRUE;
}
Exemplo n.º 7
0
/* TODO: These groups have changed as of Windows Vista. */
void CShellBrowser::DetermineItemTotalSizeGroup(int iItemInternal,TCHAR *szGroupHeader,int cchMax) const
{
	IShellFolder *pShellFolder	= NULL;
	LPITEMIDLIST pidlComplete	= NULL;
	LPITEMIDLIST pidlDirectory	= NULL;
	LPITEMIDLIST pidlRelative	= NULL;
	TCHAR *SizeGroups[] = {_T("Unspecified"),_T("Small"),_T("Medium"),_T("Huge"),_T("Gigantic")};
	TCHAR szItem[MAX_PATH];
	STRRET str;
	ULARGE_INTEGER nTotalBytes;
	ULARGE_INTEGER nFreeBytes;
	BOOL bRoot;
	BOOL bRes = FALSE;
	ULARGE_INTEGER TotalSizeGroupLimits[6];
	int nGroups = 5;
	int iSize = 0;
	int i;

	TotalSizeGroupLimits[0].QuadPart	= 0;
	TotalSizeGroupLimits[1].QuadPart	= 0;
	TotalSizeGroupLimits[2].QuadPart	= GBYTE;
	TotalSizeGroupLimits[3].QuadPart	= 20 * TotalSizeGroupLimits[2].QuadPart;
	TotalSizeGroupLimits[4].QuadPart	= 100 * TotalSizeGroupLimits[2].QuadPart;

	GetIdlFromParsingName(m_CurDir,&pidlDirectory);

	pidlComplete = ILCombine(pidlDirectory,m_pExtraItemInfo[iItemInternal].pridl);

	SHBindToParent(pidlComplete, IID_PPV_ARGS(&pShellFolder), (LPCITEMIDLIST *) &pidlRelative);

	pShellFolder->GetDisplayNameOf(pidlRelative,SHGDN_FORPARSING,&str);
	StrRetToBuf(&str,pidlRelative,szItem,SIZEOF_ARRAY(szItem));

	bRoot = PathIsRoot(szItem);

	if(bRoot)
	{
		bRes = GetDiskFreeSpaceEx(szItem,NULL,&nTotalBytes,&nFreeBytes);

		CoTaskMemFree(pidlDirectory);
		CoTaskMemFree(pidlComplete);
		pShellFolder->Release();

		i = nGroups - 1;

		while(nTotalBytes.QuadPart < TotalSizeGroupLimits[i].QuadPart && i > 0)
			i--;

		iSize = i;
	}

	if(!bRoot || !bRes)
	{
		iSize = 0;
	}

	StringCchCopy(szGroupHeader,cchMax,SizeGroups[iSize]);
}
void CFileBrowserListCtrl::OpenParentFolder()
{
	CPathStr	path(GetFolder());
	if (PathIsRoot(path))
		path.Empty();	// show drive list
	else
		path.Append(_T(".."));
	SetFolder(path);
}
Exemplo n.º 9
0
/* TODO: Need to sort based on percentage free. */
void CShellBrowser::DetermineItemFreeSpaceGroup(int iItemInternal,TCHAR *szGroupHeader,int cchMax) const
{
	std::list<TypeGroup_t>::iterator itr;
	LPITEMIDLIST pidlComplete	= NULL;
	LPITEMIDLIST pidlDirectory	= NULL;
	TCHAR szFreeSpace[MAX_PATH];
	IShellFolder *pShellFolder	= NULL;
	LPITEMIDLIST pidlRelative	= NULL;
	STRRET str;
	TCHAR szItem[MAX_PATH];
	ULARGE_INTEGER nTotalBytes;
	ULARGE_INTEGER nFreeBytes;
	BOOL bRoot;
	BOOL bRes = FALSE;

	GetIdlFromParsingName(m_CurDir,&pidlDirectory);
	pidlComplete = ILCombine(pidlDirectory,m_pExtraItemInfo[iItemInternal].pridl);
	SHBindToParent(pidlComplete, IID_PPV_ARGS(&pShellFolder), (LPCITEMIDLIST *)&pidlRelative);

	pShellFolder->GetDisplayNameOf(pidlRelative,SHGDN_FORPARSING,&str);
	StrRetToBuf(&str,pidlRelative,szItem,SIZEOF_ARRAY(szItem));

	CoTaskMemFree(pidlDirectory);
	CoTaskMemFree(pidlComplete);
	pShellFolder->Release();

	bRoot = PathIsRoot(szItem);

	if(bRoot)
	{
		bRes = GetDiskFreeSpaceEx(szItem,NULL,&nTotalBytes,&nFreeBytes);

		LARGE_INTEGER lDiv1;
		LARGE_INTEGER lDiv2;

		lDiv1.QuadPart = 100;
		lDiv2.QuadPart = 10;

		/* Divide by 10 to remove the one's digit, then multiply
		by 10 so that only the ten's digit rmains. */
		StringCchPrintf(szFreeSpace,SIZEOF_ARRAY(szFreeSpace),
			_T("%I64d%% free"),(((nFreeBytes.QuadPart * lDiv1.QuadPart) / nTotalBytes.QuadPart) / lDiv2.QuadPart) * lDiv2.QuadPart);
	}
	
	if(!bRoot || !bRes)
	{
		StringCchCopy(szFreeSpace,SIZEOF_ARRAY(szFreeSpace),_T("Unspecified"));
	}

	StringCchCopy(szGroupHeader,cchMax,szFreeSpace);
}
Exemplo n.º 10
0
int CALLBACK CShellBrowser::SortByName(int InternalIndex1,int InternalIndex2) const
{
	if(m_bVirtualFolder)
	{
		TCHAR FullFileName1[MAX_PATH];
		LPITEMIDLIST pidlComplete1 = ILCombine(m_pidlDirectory,m_pExtraItemInfo[InternalIndex1].pridl);
		GetDisplayName(pidlComplete1,FullFileName1,SHGDN_FORPARSING);
		CoTaskMemFree(pidlComplete1);

		TCHAR FullFileName2[MAX_PATH];
		LPITEMIDLIST pidlComplete2 = ILCombine(m_pidlDirectory,m_pExtraItemInfo[InternalIndex2].pridl);
		GetDisplayName(pidlComplete2,FullFileName2,SHGDN_FORPARSING);
		CoTaskMemFree(pidlComplete2);

		BOOL IsRoot1 = PathIsRoot(FullFileName1);
		BOOL IsRoot2 = PathIsRoot(FullFileName2);

		if(IsRoot1 && !IsRoot2)
		{
			return -1;
		}
		else if(!IsRoot1 && IsRoot2)
		{
			return 1;
		}
		else if(IsRoot1 && IsRoot2)
		{
			/* If the items been compared are both drives,
			sort by drive letter, rather than display name. */
			return StrCmpLogicalW(FullFileName1,FullFileName2);
		}
	}

	std::wstring Name1 = GetNameColumnText(InternalIndex1);
	std::wstring Name2 = GetNameColumnText(InternalIndex2);

	return StrCmpLogicalW(Name1.c_str(),Name2.c_str());
}
void CFileBrowserListCtrl::OpenItem(int ItemIdx)
{
	// copy item instead of referencing it, because SetFolder changes m_DirList
	CDirItem	Item = m_DirList.GetItem(ItemIdx);
	CString	ItemPath = GetItemPath(ItemIdx);	// grab item path now too
	if (Item.IsDir()) {
		// if user selected parent folder and current folder is a root folder
		if (Item.IsDots() && PathIsRoot(GetFolder()))
			SetFolder(_T(""));	// list drives
		else
			SetFolder(ItemPath);
	}
	NMFBOPENITEM	nmoi;
	nmoi.pszPath = ItemPath;
	nmoi.bIsDir = Item.IsDir();
	Notify(FBLCN_OPENITEM, &nmoi);
}
BOOL CMakerSetupResultPage::_IsFilterFile(LPCTSTR pszFilePath)
{
    BOOL bRet = FALSE;
    if (!bRet)
    {
        bRet = PathIsRoot(pszFilePath);
    }
    if (!bRet)
    {
        bRet = PathIsNetworkPath(pszFilePath);
    }
    if (!bRet)
    {
        bRet = PathIsTempPath(pszFilePath);
    }
    return bRet;
}
Exemplo n.º 13
0
void CShellBrowser::DetermineItemFileSystemGroup(int iItemInternal,TCHAR *szGroupHeader,int cchMax) const
{
	LPITEMIDLIST pidlComplete = NULL;
	IShellFolder *pShellFolder	= NULL;
	LPITEMIDLIST pidlRelative	= NULL;
	TCHAR szFileSystemName[MAX_PATH];
	TCHAR szItem[MAX_PATH];
	STRRET str;
	BOOL bRoot;
	BOOL bRes;

	pidlComplete = ILCombine(m_pidlDirectory,m_pExtraItemInfo[iItemInternal].pridl);

	SHBindToParent(pidlComplete, IID_PPV_ARGS(&pShellFolder), (LPCITEMIDLIST *)&pidlRelative);

	pShellFolder->GetDisplayNameOf(pidlRelative,SHGDN_FORPARSING,&str);
	StrRetToBuf(&str,pidlRelative,szItem,SIZEOF_ARRAY(szItem));

	bRoot = PathIsRoot(szItem);

	if(bRoot)
	{
		bRes = GetVolumeInformation(szItem,NULL,0,NULL,NULL,NULL,szFileSystemName,
			SIZEOF_ARRAY(szFileSystemName));

		if(!bRes || *szFileSystemName == '\0')
		{
			/* TODO: Move into string table. */
			StringCchCopy(szFileSystemName,SIZEOF_ARRAY(szFileSystemName),_T("Unspecified"));
		}
	}
	else
	{
		/* TODO: Move into string table. */
		StringCchCopy(szFileSystemName,SIZEOF_ARRAY(szFileSystemName),_T("Unspecified"));
	}

	StringCchCopy(szGroupHeader,cchMax,szFileSystemName);

	pShellFolder->Release();
	CoTaskMemFree(pidlComplete);
}
void CMyTreeView::AddItem(const TCHAR *szFullFileName)
{
	TCHAR			szDirectory[MAX_PATH];
	HTREEITEM		hParent;
	HTREEITEM		hDeskParent;

	/* If the specified item is a drive, it
	will need to be handled differently,
	as it is a child of my computer (and
	as such is not a regular file). */
	if(PathIsRoot(szFullFileName))
	{
		AddDrive(szFullFileName);
	}
	else
	{
		StringCchCopy(szDirectory, SIZEOF_ARRAY(szDirectory), szFullFileName);
		PathRemoveFileSpec(szDirectory);

		// Check if it is a desktop (sub)child
		hDeskParent = LocateItemOnDesktopTree(szDirectory);

		hParent = LocateExistingItem(szDirectory);

		/* If this items' parent isn't currently shown on the
		treeview and the item is not on the desktop, exit without
		doing anything further. */
		if(hParent == NULL && hDeskParent == NULL)
			return;

		AddItemInternal(hParent,szFullFileName);

		if(hDeskParent != NULL)
		{
			/* If the item is on the desktop, it is a special
			case. We need to update the treeview also starting
			from the root item. */
			AddItemInternal(hDeskParent,szFullFileName);
		}
	}
}
Exemplo n.º 15
0
void clistctrlnewitem::OnDropFiles(HDROP hDropInfo)
{
	// TODO: ÔÚ´ËÌí¼ÓÏûÏ¢´¦Àí³ÌÐò´úÂëºÍ/»òµ÷ÓÃĬÈÏÖµ
	CString t_cs;
	int t_DropCount=DragQueryFile(hDropInfo,-1,NULL,0);
	if(t_DropCount==1)
	{    
		DragQueryFile(hDropInfo,0,t_cs.GetBuffer(_MAX_PATH),_MAX_PATH);
		t_cs.ReleaseBuffer();
		if(PathIsDirectory(t_cs)||PathIsRoot(t_cs)) 
		{
			MessageBox(_T("error!"));
		}
		else
		{
			m_new_location.SetWindowText(t_cs);
			UpdateData(FALSE);
		}
	}
	CDialogEx::OnDropFiles(hDropInfo);
}
Exemplo n.º 16
0
//---------------------------------------------------------------------
// 再帰的にディレクトリを作成するCreateDirectory関数
//---------------------------------------------------------------------
bool kjm::util::create_directory(const _tstring& path) {
	// 指定フォルダがルートを指しているときは、正常終了
	if (PathIsRoot(path.c_str())) {
		return true;
	}

	// すでにフォルダが存在するので、正常終了
	if (PathFileExists(path.c_str())) {
		return true;
	}

	// 親フォルダの作成を試みる
	TCHAR work[MAX_PATH];
	PathAppend(lstrcpy(work, path.c_str()), _T(".."));
	if (kjm::util::create_directory(work)) {
		if (CreateDirectory(path.c_str(), NULL)) {
			return true;
		}
	}

	return false;
}
Exemplo n.º 17
0
string AppSettings::FindImage(const string& fname){
   TCHAR buffer[MAX_PATH];

   // Simply check for fully qualified path
   if (PathIsRoot(fname.c_str())) {
      if (-1 != _taccess(fname.c_str(), 0))
         return fname;
   }

   // Test if its relative and in one of the specified root paths
   for (stringlist::iterator itr = textureRootPaths.begin(), end = textureRootPaths.end(); itr != end; ++itr ){
      PathCombine(buffer, itr->c_str(), fname.c_str());
      if (-1 != _taccess(buffer, 0)){
         return string(buffer);
      }
   }

   // Hit the directories to find out whats out there
   if (!parsedImages){
      FindImages(imgTable, rootPath, searchPaths, extensions);
      parsedImages = true;
   }
   
   // Search my filename for our texture
   _tcscpy(buffer, PathFindFileName(fname.c_str()));
   PathRemoveExtension(buffer);
   NameValueCollection::iterator itr = imgTable.find(buffer);
   if (itr != imgTable.end()){
      if (!rootPath.empty()) {
         _tcscpy(buffer, rootPath.c_str());
         PathCombine(buffer, rootPath.c_str(), ((*itr).second).c_str());
         return string(buffer);
      } else {
         return (*itr).second;
      }
   }
   return fname;
}
Exemplo n.º 18
0
LRESULT CFileTreeView::OnUserDirUp(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{
	if (!m_editDir.m_strDir.IsEmpty())
	{
		if (!PathIsRoot((LPCWSTR)m_editDir.m_strDir))
		{
			PathRemoveBackslash(m_editDir.m_strDir.GetBuffer(MAX_PATH));
			PathRemoveFileSpec(m_editDir.m_strDir.GetBuffer(MAX_PATH));
			PathAddBackslash(m_editDir.m_strDir.GetBuffer(MAX_PATH));
			m_editDir.m_strDir.ReleaseBuffer();
		}
		else
		{
			m_editDir.m_strDir = L"";
		}
		m_editDir.SetWindowText((LPCWSTR)(m_editDir.m_strDir));
		m_editDir.SetSel(m_editDir.m_strDir.GetLength(), m_editDir.m_strDir.GetLength());
		TreeView_SelectItem(m_Org.m_hWnd, NULL);
		m_Org.SetRootFolder((LPCWSTR)m_editDir.m_strDir);
	}
	RecordMemberVariable();
	return 0;
}
Exemplo n.º 19
0
//フルパスかつ絶対パスの取得
PATHERROR UtilGetCompletePathName(CString &_FullPath,LPCTSTR lpszFileName)
{
	ASSERT(lpszFileName&&_tcslen(lpszFileName)>0);
	if(!lpszFileName||_tcslen(lpszFileName)<=0){
		TRACE(_T("ファイル名が指定されていない\n"));
		return PATHERROR_INVALID;
	}

	//---絶対パス取得
	TCHAR szAbsPath[_MAX_PATH+1]={0};
	{
		TCHAR Buffer[_MAX_PATH+1]={0};	//ルートかどうかのチェックを行う
		_tcsncpy_s(Buffer,lpszFileName,_MAX_PATH);
		PathAddBackslash(Buffer);
		if(PathIsRoot(Buffer)){
			//ドライブ名だけが指定されている場合、
			//_tfullpathはそのドライブのカレントディレクトリを取得してしまう
			_tcsncpy_s(szAbsPath,lpszFileName,_MAX_PATH);
		}
		else if(!_tfullpath(szAbsPath,lpszFileName,_MAX_PATH)){
			TRACE(_T("絶対パス取得失敗\n"));
			return PATHERROR_ABSPATH;
		}
	}

	if(!PathFileExists(szAbsPath)&&!PathIsDirectory(szAbsPath)){
		//パスがファイルもしくはディレクトリとして存在しないなら、エラーとする
		TRACE(_T("ファイルが存在しない\n"));
		return PATHERROR_NOTFOUND;
	}
	if(!GetLongPathName(szAbsPath,szAbsPath,_MAX_PATH)){
		TRACE(_T("ロングファイル名取得失敗\n"));
		return PATHERROR_LONGNAME;
	}
	_FullPath=szAbsPath;
	return PATHERROR_NONE;
}
Exemplo n.º 20
0
	bool is_root() const { return PathIsRoot(this->buf)==TRUE; }
Exemplo n.º 21
0
int inline CShellBrowser::SetItemInformation(LPITEMIDLIST pidlDirectory,
LPITEMIDLIST pidlRelative,TCHAR *szFileName)
{
	LPITEMIDLIST	pidlItem = NULL;
	HANDLE			hFirstFile;
	TCHAR			szPath[MAX_PATH];
	int				uItemId;

	m_nAwaitingAdd++;

	if((m_nTotalItems + m_nAwaitingAdd) > (m_iCurrentAllocation - 1))
	{
		int PrevSize = m_iCurrentAllocation;

		if(m_iCurrentAllocation > MEM_ALLOCATION_LEVEL_MEDIUM)
			m_iCurrentAllocation += MEM_ALLOCATION_LEVEL_MEDIUM;
		else if(m_iCurrentAllocation > MEM_ALLOCATION_LEVEL_LOW)
			m_iCurrentAllocation += MEM_ALLOCATION_LEVEL_LOW;
		else
			m_iCurrentAllocation += DEFAULT_MEM_ALLOC;

		m_pwfdFiles = (WIN32_FIND_DATA *)realloc(m_pwfdFiles,
			m_iCurrentAllocation * (sizeof(WIN32_FIND_DATA)));

		m_pExtraItemInfo = (CItemObject *)realloc(m_pExtraItemInfo,
			m_iCurrentAllocation * sizeof(CItemObject));

		m_pItemMap = (int *)realloc(m_pItemMap,m_iCurrentAllocation * sizeof(int));

		InitializeItemMap(PrevSize,m_iCurrentAllocation);

		if(m_pwfdFiles == NULL || m_pExtraItemInfo == NULL)
			return E_OUTOFMEMORY;
	}

	uItemId = GenerateUniqueItemId();

	m_pExtraItemInfo[uItemId].pridl					= ILClone(pidlRelative);
	m_pExtraItemInfo[uItemId].bIconRetrieved		= FALSE;
	m_pExtraItemInfo[uItemId].bThumbnailRetreived	= FALSE;
	m_pExtraItemInfo[uItemId].bFolderSizeRetrieved	= FALSE;
	StringCchCopy(m_pExtraItemInfo[uItemId].szDisplayName,MAX_PATH,szFileName);

	pidlItem = ILCombine(pidlDirectory,pidlRelative);

	SHGetPathFromIDList(pidlItem,szPath);

	CoTaskMemFree(pidlItem);

	/* DO NOT call FindFirstFile() on root drives (especially
	floppy drives). Doing so may cause a delay of up to a
	few seconds. */
	if(!PathIsRoot(szPath))
	{
		m_pExtraItemInfo[uItemId].bDrive = FALSE;
		hFirstFile = FindFirstFile(szPath,&m_pwfdFiles[uItemId]);
	}
	else
	{
		m_pExtraItemInfo[uItemId].bDrive = TRUE;
		StringCchCopy(m_pExtraItemInfo[uItemId].szDrive,
			SIZEOF_ARRAY(m_pExtraItemInfo[uItemId].szDrive),
			szPath);

		hFirstFile = INVALID_HANDLE_VALUE;
	}

	/* Need to use this, since may be in a virtual folder
	(such as the recycle bin), but items still exist. */
	if(hFirstFile != INVALID_HANDLE_VALUE)
	{
		m_pExtraItemInfo[uItemId].bReal = TRUE;
		FindClose(hFirstFile);
	}
	else
	{
		StringCchCopy(m_pwfdFiles[uItemId].cFileName,
			sizeof(m_pwfdFiles[uItemId].cFileName)/sizeof(m_pwfdFiles[uItemId].cFileName[0]),szFileName);
		m_pwfdFiles[uItemId].nFileSizeLow			= 0;
		m_pwfdFiles[uItemId].nFileSizeHigh			= 0;
		m_pwfdFiles[uItemId].dwFileAttributes		= FILE_ATTRIBUTE_DIRECTORY;

		m_pExtraItemInfo[uItemId].bReal = FALSE;
	}

	return uItemId;
}