4 * Copyright 1998 Juergen Schmied <juergen.schmied@metronet.de>
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
23 WINE_DEFAULT_DEBUG_CHANNEL(shell
);
25 CEnumIDListBase::CEnumIDListBase()
32 CEnumIDListBase::~CEnumIDListBase()
36 /**************************************************************************
39 BOOL
CEnumIDListBase::AddToEnumList(LPITEMIDLIST pidl
)
43 TRACE("(%p)->(pidl=%p)\n", this, pidl
);
48 pNew
= static_cast<ENUMLIST
*>(SHAlloc(sizeof(ENUMLIST
)));
51 /*set the next pointer */
55 /*is This the first item in the list? */
64 /*add the new item to the end of the list */
68 /*update the last item pointer */
70 TRACE("-- (%p)->(first=%p, last=%p)\n", this, mpFirst
, mpLast
);
76 /**************************************************************************
79 BOOL
CEnumIDListBase::DeleteList()
83 TRACE("(%p)->()\n", this);
88 mpFirst
= pDelete
->pNext
;
89 SHFree(pDelete
->pidl
);
98 /**************************************************************************
101 BOOL
CEnumIDListBase::HasItemWithCLSID(LPITEMIDLIST pidl
)
104 IID
*ptr
= _ILGetGUIDPointer(pidl
);
113 LPGUID curid
= _ILGetGUIDPointer(pCur
->pidl
);
114 if (curid
&& IsEqualGUID(*curid
, refid
))
126 /**************************************************************************
127 * CreateFolderEnumList()
129 BOOL
CEnumIDListBase::CreateFolderEnumList(
133 WIN32_FIND_DATAW stffile
;
135 WCHAR szPath
[MAX_PATH
];
136 BOOL succeeded
= TRUE
;
137 static const WCHAR stars
[] = { '*','.','*',0 };
138 static const WCHAR dot
[] = { '.',0 };
139 static const WCHAR dotdot
[] = { '.','.',0 };
141 TRACE("(%p)->(path=%s flags=0x%08x)\n", this, debugstr_w(lpszPath
), dwFlags
);
143 if(!lpszPath
|| !lpszPath
[0]) return FALSE
;
145 wcscpy(szPath
, lpszPath
);
146 PathAddBackslashW(szPath
);
147 wcscat(szPath
,stars
);
149 hFile
= FindFirstFileW(szPath
,&stffile
);
150 if ( hFile
!= INVALID_HANDLE_VALUE
)
152 BOOL findFinished
= FALSE
;
156 if ( !(stffile
.dwFileAttributes
& FILE_ATTRIBUTE_HIDDEN
)
157 || (dwFlags
& SHCONTF_INCLUDEHIDDEN
) )
159 LPITEMIDLIST pidl
= NULL
;
161 if ( (stffile
.dwFileAttributes
& FILE_ATTRIBUTE_DIRECTORY
) &&
162 dwFlags
& SHCONTF_FOLDERS
&&
163 strcmpW(stffile
.cFileName
, dot
) && strcmpW(stffile
.cFileName
, dotdot
))
165 pidl
= _ILCreateFromFindDataW(&stffile
);
166 succeeded
= succeeded
&& AddToEnumList(pidl
);
168 else if (!(stffile
.dwFileAttributes
& FILE_ATTRIBUTE_DIRECTORY
)
169 && dwFlags
& SHCONTF_NONFOLDERS
)
171 pidl
= _ILCreateFromFindDataW(&stffile
);
172 succeeded
= succeeded
&& AddToEnumList(pidl
);
177 if (!FindNextFileW(hFile
, &stffile
))
179 if (GetLastError() == ERROR_NO_MORE_FILES
)
185 } while (succeeded
&& !findFinished
);
192 /**************************************************************************
196 HRESULT WINAPI
CEnumIDListBase::Next(
198 LPITEMIDLIST
* rgelt
,
205 TRACE("(%p)->(%d,%p, %p)\n", this, celt
, rgelt
, pceltFetched
);
207 /* It is valid to leave pceltFetched NULL when celt is 1. Some of explorer's
208 * subsystems actually use it (and so may a third party browser)
215 if(celt
> 1 && !pceltFetched
)
216 { return E_INVALIDARG
;
219 if(celt
> 0 && !mpCurrent
)
223 for(i
= 0; i
< celt
; i
++)
227 temp
= ILClone(mpCurrent
->pidl
);
229 mpCurrent
= mpCurrent
->pNext
;
238 /**************************************************************************
241 HRESULT WINAPI
CEnumIDListBase::Skip(
247 TRACE("(%p)->(%u)\n", this, celt
);
249 for(dwIndex
= 0; dwIndex
< celt
; dwIndex
++)
254 mpCurrent
= mpCurrent
->pNext
;
259 /**************************************************************************
260 * IEnumIDList_fnReset
262 HRESULT WINAPI
CEnumIDListBase::Reset()
264 TRACE("(%p)\n", this);
269 /**************************************************************************
270 * IEnumIDList_fnClone
272 HRESULT WINAPI
CEnumIDListBase::Clone(LPENUMIDLIST
*ppenum
)
274 TRACE("(%p)->() to (%p)->() E_NOTIMPL\n", this, ppenum
);
278 /**************************************************************************
279 * IEnumIDList_Folder_Constructor
282 HRESULT
IEnumIDList_Constructor(IEnumIDList
**enumerator
)
284 return ShellObjectCreator
<CEnumIDListBase
>(IID_IEnumIDList
, enumerator
);