Add new helper function to create a relative file or folder ItemIDList
for a path and change usage of SHSimpleIDListFromPath to call new function instead.
This commit is contained in:
parent
b59bf98b93
commit
1c481f3da8
|
@ -1116,7 +1116,7 @@ LPITEMIDLIST _ILCreateFolder( WIN32_FIND_DATAA * stffile )
|
|||
pData = _ILGetDataPointer(pidl);
|
||||
FileTimeToDosDateTime(&(stffile->ftLastWriteTime),&pData->u.folder.uFileDate,&pData->u.folder.uFileTime);
|
||||
pData->u.folder.dwFileSize = stffile->nFileSizeLow;
|
||||
pData->u.folder.uFileAttribs=stffile->dwFileAttributes;
|
||||
pData->u.folder.uFileAttribs = stffile->dwFileAttributes;
|
||||
}
|
||||
|
||||
return pidl;
|
||||
|
@ -1162,6 +1162,24 @@ LPITEMIDLIST _ILCreateValue(WIN32_FIND_DATAA * stffile)
|
|||
return pidl;
|
||||
}
|
||||
|
||||
LPITEMIDLIST _ILCreateFromPathA(LPCSTR szPath)
|
||||
{
|
||||
HANDLE hFile;
|
||||
WIN32_FIND_DATAA stffile;
|
||||
LPITEMIDLIST pidl = NULL;
|
||||
|
||||
hFile = FindFirstFileA(szPath, &stffile);
|
||||
if (hFile != INVALID_HANDLE_VALUE)
|
||||
{
|
||||
if (stffile.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
|
||||
pidl = _ILCreateFolder(&stffile);
|
||||
else
|
||||
pidl = _ILCreateValue(&stffile);
|
||||
FindClose(hFile);
|
||||
}
|
||||
return pidl;
|
||||
}
|
||||
|
||||
LPITEMIDLIST _ILCreateSpecial(LPCSTR szGUID)
|
||||
{
|
||||
IID iid;
|
||||
|
|
|
@ -58,7 +58,8 @@
|
|||
* drive 0x2F drive (lnk/persistant)
|
||||
* folder/file 0x30 folder/file (1) (lnk/persistant)
|
||||
* folder 0x31 folder (usual)
|
||||
* value 0x32 file (usual)
|
||||
* valueA 0x32 file (ANSI file name)
|
||||
* valueW 0x34 file (Unicode file name)
|
||||
* workgroup 0x41 network (3)
|
||||
* computer 0x42 network (4)
|
||||
* whole network 0x47 network (5)
|
||||
|
@ -174,6 +175,7 @@ LPITEMIDLIST _ILCreateDrive (LPCSTR);
|
|||
LPITEMIDLIST _ILCreateFolder (WIN32_FIND_DATAA * stffile);
|
||||
LPITEMIDLIST _ILCreateValue (WIN32_FIND_DATAA * stffile);
|
||||
LPITEMIDLIST _ILCreateSpecial (LPCSTR szGUID);
|
||||
LPITEMIDLIST _ILCreateFromPathA (LPCSTR szPath);
|
||||
|
||||
/*
|
||||
* helper functions (getting struct-pointer)
|
||||
|
|
|
@ -324,9 +324,9 @@ IShellFolder_fnParseDisplayName (IShellFolder2 * iface,
|
|||
HRESULT hr = E_OUTOFMEMORY;
|
||||
LPCWSTR szNext = NULL;
|
||||
WCHAR szElement[MAX_PATH];
|
||||
CHAR szTempA[MAX_PATH],
|
||||
szPath[MAX_PATH];
|
||||
CHAR szPath[MAX_PATH];
|
||||
LPITEMIDLIST pidlTemp = NULL;
|
||||
DWORD len;
|
||||
|
||||
TRACE ("(%p)->(HWND=%p,%p,%p=%s,%p,pidl=%p,%p)\n",
|
||||
This, hwndOwner, pbcReserved, lpszDisplayName, debugstr_w (lpszDisplayName), pchEaten, ppidl, pdwAttributes);
|
||||
|
@ -342,14 +342,13 @@ IShellFolder_fnParseDisplayName (IShellFolder2 * iface,
|
|||
szNext = GetNextElementW (lpszDisplayName, szElement, MAX_PATH);
|
||||
|
||||
/* build the full pathname to the element */
|
||||
WideCharToMultiByte (CP_ACP, 0, szElement, -1, szTempA, MAX_PATH, NULL, NULL);
|
||||
lstrcpyA (szPath, This->sPathTarget);
|
||||
PathAddBackslashA (szPath);
|
||||
lstrcatA (szPath, szTempA);
|
||||
lstrcpyA(szPath, This->sPathTarget);
|
||||
PathAddBackslashA(szPath);
|
||||
len = lstrlenA(szPath);
|
||||
WideCharToMultiByte(CP_ACP, 0, szElement, -1, szPath + len, MAX_PATH - len, NULL, NULL);
|
||||
|
||||
/* get the pidl */
|
||||
pidlTemp = SHSimpleIDListFromPathA (szPath);
|
||||
|
||||
pidlTemp = _ILCreateFromPathA(szPath);
|
||||
if (pidlTemp) {
|
||||
if (szNext && *szNext) {
|
||||
/* try to analyse the next element */
|
||||
|
@ -696,6 +695,7 @@ static HRESULT WINAPI IShellFolder_fnSetNameOf (IShellFolder2 * iface, HWND hwnd
|
|||
len = strlen (szSrc);
|
||||
_ILSimpleGetText (pidl, szSrc + len, MAX_PATH - len);
|
||||
} else {
|
||||
/* FIXME: Can this work with a simple PIDL? */
|
||||
SHGetPathFromIDListA (pidl, szSrc);
|
||||
}
|
||||
|
||||
|
@ -708,7 +708,7 @@ static HRESULT WINAPI IShellFolder_fnSetNameOf (IShellFolder2 * iface, HWND hwnd
|
|||
TRACE ("src=%s dest=%s\n", szSrc, szDest);
|
||||
if (MoveFileA (szSrc, szDest)) {
|
||||
if (pPidlOut)
|
||||
*pPidlOut = SHSimpleIDListFromPathA (szDest);
|
||||
*pPidlOut = _ILCreateFromPathA(szDest);
|
||||
SHChangeNotify (bIsFolder ? SHCNE_RENAMEFOLDER : SHCNE_RENAMEITEM, SHCNF_PATHA, szSrc, szDest);
|
||||
return S_OK;
|
||||
}
|
||||
|
@ -931,23 +931,13 @@ static HRESULT WINAPI ISFHelper_fnAddFolder (ISFHelper * iface, HWND hwnd, LPCST
|
|||
TRACE ("(%p)(%s %p)\n", This, lpName, ppidlOut);
|
||||
|
||||
strcpy (lpstrNewDir, This->sPathTarget);
|
||||
PathAddBackslashA (lpstrNewDir);
|
||||
strcat (lpstrNewDir, lpName);
|
||||
PathAppendA(lpstrNewDir, lpName);
|
||||
|
||||
bRes = CreateDirectoryA (lpstrNewDir, NULL);
|
||||
|
||||
if (bRes) {
|
||||
LPITEMIDLIST pidl,
|
||||
pidlitem;
|
||||
|
||||
pidlitem = SHSimpleIDListFromPathA (lpstrNewDir);
|
||||
|
||||
pidl = ILCombine (This->pidlRoot, pidlitem);
|
||||
SHChangeNotify (SHCNE_MKDIR, SHCNF_IDLIST, pidl, NULL);
|
||||
SHFree (pidl);
|
||||
|
||||
SHChangeNotify (SHCNE_MKDIR, SHCNF_PATHA, lpstrNewDir, NULL);
|
||||
if (ppidlOut)
|
||||
*ppidlOut = pidlitem;
|
||||
*ppidlOut = _ILCreateFromPathA(lpstrNewDir);
|
||||
hres = S_OK;
|
||||
} else {
|
||||
char lpstrText[128 + MAX_PATH];
|
||||
|
|
Loading…
Reference in New Issue