1 // TortoiseGit - a Windows shell extension for easy version control
3 // Copyright (C) 2003-2006 - Stefan Kueng
5 // This program is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU General Public License
7 // as published by the Free Software Foundation; either version 2
8 // of the License, or (at your option) any later version.
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
15 // You should have received a copy of the GNU General Public License
16 // along with this program; if not, write to the Free Software Foundation,
17 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21 #include "ItemIDList.h"
24 ItemIDList::ItemIDList(LPCITEMIDLIST item
, LPCITEMIDLIST parent
) :
31 ItemIDList::~ItemIDList()
35 int ItemIDList::size() const
42 LPCSHITEMID ptr
= &item_
->mkid
;
43 while (ptr
!= 0 && ptr
->cb
!= 0)
46 LPBYTE byte
= (LPBYTE
) ptr
;
48 ptr
= (LPCSHITEMID
) byte
;
55 LPCSHITEMID
ItemIDList::get(int index
) const
61 LPCSHITEMID ptr
= &item_
->mkid
;
70 LPBYTE byte
= (LPBYTE
) ptr
;
72 ptr
= (LPCSHITEMID
) byte
;
77 stdstring
ItemIDList::toString()
79 IShellFolder
*shellFolder
= NULL
;
80 IShellFolder
*parentFolder
= NULL
;
82 TCHAR
* szDisplayName
= NULL
;
86 hr
= ::SHGetDesktopFolder(&shellFolder
);
91 hr
= shellFolder
->BindToObject(parent_
, 0, IID_IShellFolder
, (void**) &parentFolder
);
93 parentFolder
= shellFolder
;
97 parentFolder
= shellFolder
;
100 if ((parentFolder
!= 0)&&(item_
!= 0))
102 hr
= parentFolder
->GetDisplayNameOf(item_
, SHGDN_NORMAL
| SHGDN_FORPARSING
, &name
);
105 parentFolder
->Release();
108 hr
= StrRetToStr (&name
, item_
, &szDisplayName
);
112 parentFolder
->Release();
113 if (szDisplayName
== NULL
)
115 CoTaskMemFree(szDisplayName
);
116 return ret
; //to avoid a crash!
119 CoTaskMemFree(szDisplayName
);
123 LPCITEMIDLIST
ItemIDList::operator& ()