From 02b0be7cffecafab26ee6844ec7a4c020a4b9f8d Mon Sep 17 00:00:00 2001 From: Juergen Schmied Date: Sun, 20 Feb 2000 18:36:23 +0000 Subject: [PATCH] New aPidl handling functions. --- dlls/shell32/pidl.c | 59 ++++++++++++++++++++++++++++++++++++++++++--- dlls/shell32/pidl.h | 7 ++++++ 2 files changed, 63 insertions(+), 3 deletions(-) diff --git a/dlls/shell32/pidl.c b/dlls/shell32/pidl.c index ec99bbd7836..922a0e1c55e 100644 --- a/dlls/shell32/pidl.c +++ b/dlls/shell32/pidl.c @@ -732,7 +732,7 @@ LPITEMIDLIST WINAPI ILCreateFromPathAW (LPCVOID path) /************************************************************************* * SHSimpleIDListFromPath [SHELL32.162] */ -LPITEMIDLIST WINAPI SHSimpleIDListFromPathA (LPSTR lpszPath) +LPITEMIDLIST WINAPI SHSimpleIDListFromPathA (LPCSTR lpszPath) { LPITEMIDLIST pidl=NULL; HANDLE hFile; @@ -758,7 +758,7 @@ LPITEMIDLIST WINAPI SHSimpleIDListFromPathA (LPSTR lpszPath) } return pidl; } -LPITEMIDLIST WINAPI SHSimpleIDListFromPathW (LPWSTR lpszPath) +LPITEMIDLIST WINAPI SHSimpleIDListFromPathW (LPCWSTR lpszPath) { char lpszTemp[MAX_PATH]; TRACE("path=%s\n",debugstr_w(lpszPath)); @@ -768,7 +768,7 @@ LPITEMIDLIST WINAPI SHSimpleIDListFromPathW (LPWSTR lpszPath) return SHSimpleIDListFromPathA (lpszTemp); } -LPITEMIDLIST WINAPI SHSimpleIDListFromPathAW (LPVOID lpszPath) +LPITEMIDLIST WINAPI SHSimpleIDListFromPathAW (LPCVOID lpszPath) { if ( VERSION_OsIsUnicode()) return SHSimpleIDListFromPathW (lpszPath); @@ -1724,3 +1724,56 @@ DWORD _ILGetFileAttributes(LPCITEMIDLIST pidl, LPSTR pOut, UINT uOutSize) return wAttrib; } +/************************************************************************* +* ILFreeaPidl +* +* free a aPidl struct +*/ +void _ILFreeaPidl(LPITEMIDLIST * apidl, UINT cidl) +{ + int i; + + if(apidl) + { + for(i = 0; i < cidl; i++) SHFree(apidl[i]); + SHFree(apidl); + } +} + +/************************************************************************* +* ILCopyaPidl +* +* copys a aPidl struct +*/ +LPITEMIDLIST * _ILCopyaPidl(LPITEMIDLIST * apidlsrc, UINT cidl) +{ + int i; + LPITEMIDLIST * apidldest = (LPITEMIDLIST*)SHAlloc(cidl * sizeof(LPITEMIDLIST)); + if(!apidlsrc) return NULL; + + for(i = 0; i < cidl; i++) + apidldest[i] = ILClone(apidlsrc[i]); + + return apidldest; +} + +/************************************************************************* +* _ILCopyCidaToaPidl +* +* creates aPidl from CIDA +*/ +LPITEMIDLIST * _ILCopyCidaToaPidl(LPITEMIDLIST* pidl, LPCIDA cida) +{ + int i; + LPITEMIDLIST * dst = (LPITEMIDLIST*)SHAlloc(cida->cidl * sizeof(LPITEMIDLIST)); + + if(!dst) return NULL; + + if (pidl) + *pidl = ILClone((LPITEMIDLIST)(&((LPBYTE)cida)[cida->aoffset[0]])); + + for(i = 0; i < cida->cidl; i++) + dst[i] = ILClone((LPITEMIDLIST)(&((LPBYTE)cida)[cida->aoffset[i + 1]])); + + return dst; +} diff --git a/dlls/shell32/pidl.h b/dlls/shell32/pidl.h index cb32cb0d23c..5d6e8f21ad4 100644 --- a/dlls/shell32/pidl.h +++ b/dlls/shell32/pidl.h @@ -168,4 +168,11 @@ REFIID _ILGetGUIDPointer (LPCITEMIDLIST pidl); void pdump (LPCITEMIDLIST pidl); BOOL pcheck (LPCITEMIDLIST pidl); +/* + * aPidl helper + */ +void _ILFreeaPidl(LPITEMIDLIST * apidl, UINT cidl); +LPITEMIDLIST * _ILCopyaPidl(LPITEMIDLIST * apidlsrc, UINT cidl); +LPITEMIDLIST * _ILCopyCidaToaPidl(LPITEMIDLIST* pidl, LPCIDA cida); + #endif