HRESULT TRASH_EnumItems(const WCHAR *path, LPITEMIDLIST **pidls, int *count) { int ti_count; int pos=0, i; HRESULT err = E_OUTOFMEMORY; HDPA tinfs; if(path) FIXME("Ignoring path = %s\n", debugstr_w(path)); if (!TRASH_EnsureInitialized()) return E_FAIL; tinfs = enum_bucket_trashinfos(home_trash, &ti_count); if (tinfs == NULL) return E_FAIL; *pidls = SHAlloc(sizeof(LPITEMIDLIST)*ti_count); if (!*pidls) goto failed; for (i=0; i<ti_count; i++) { WIN32_FIND_DATAW data; LPCSTR filename; filename = DPA_GetPtr(tinfs, i); if (FAILED(err = TRASH_GetDetails(home_trash, filename, &data))) goto failed; if (err == S_FALSE) continue; if (FAILED(err = TRASH_CreateSimplePIDL(filename, &data, &(*pidls)[pos]))) goto failed; pos++; } *count = pos; DPA_DestroyCallback(tinfs, free_item_callback, NULL); return S_OK; failed: if (*pidls != NULL) { int j; for (j=0; j<pos; j++) SHFree((*pidls)[j]); SHFree(*pidls); } DPA_DestroyCallback(tinfs, free_item_callback, NULL); return err; }
void SIC_Destroy(void) { TRACE("\n"); EnterCriticalSection(&SHELL32_SicCS); if (sic_hdpa) DPA_DestroyCallback(sic_hdpa, sic_free, NULL ); ImageList_Destroy(ShellSmallIconList); ImageList_Destroy(ShellBigIconList); LeaveCriticalSection(&SHELL32_SicCS); DeleteCriticalSection(&SHELL32_SicCS); }
static HDPA enum_bucket_trashinfos(const TRASH_BUCKET *bucket, int *count) { HDPA ret = DPA_Create(32); struct dirent *entry; DIR *dir = NULL; errno = ENOMEM; *count = 0; if (ret == NULL) goto failed; dir = opendir(bucket->info_dir); if (dir == NULL) goto failed; while ((entry = readdir(dir)) != NULL) { LPSTR filename; int namelen = lstrlenA(entry->d_name); int suffixlen = lstrlenA(trashinfo_suffix); if (namelen <= suffixlen || lstrcmpA(entry->d_name+namelen-suffixlen, trashinfo_suffix) != 0) continue; filename = StrDupA(entry->d_name); if (filename == NULL) goto failed; if (DPA_InsertPtr(ret, DPA_APPEND, filename) == -1) { LocalFree(filename); goto failed; } (*count)++; } closedir(dir); return ret; failed: if (dir) closedir(dir); if (ret) DPA_DestroyCallback(ret, free_item_callback, NULL); return NULL; }