shell32: Get rid of TRASH_ELEMENT and TRASH_DisposeElement().
The latter was unused while the former did not seem very useful.
This commit is contained in:
parent
59c00d5568
commit
fc93ff351e
|
@ -311,7 +311,7 @@ static HRESULT WINAPI RecycleBin_GetDisplayNameOf(IShellFolder2 *This, LPCITEMID
|
||||||
WIN32_FIND_DATAW data;
|
WIN32_FIND_DATAW data;
|
||||||
|
|
||||||
TRACE("(%p, %p, %x, %p)\n", This, pidl, uFlags, pName);
|
TRACE("(%p, %p, %x, %p)\n", This, pidl, uFlags, pName);
|
||||||
TRASH_UnpackItemID(&pidl->mkid, NULL, &data);
|
TRASH_UnpackItemID(&pidl->mkid, &data);
|
||||||
pName->uType = STRRET_WSTR;
|
pName->uType = STRRET_WSTR;
|
||||||
pName->u.pOleStr = StrDupW(PathFindFileNameW(data.cFileName));
|
pName->u.pOleStr = StrDupW(PathFindFileNameW(data.cFileName));
|
||||||
if (pName->u.pOleStr == NULL)
|
if (pName->u.pOleStr == NULL)
|
||||||
|
@ -414,7 +414,7 @@ static HRESULT WINAPI RecycleBin_GetDetailsOf(IShellFolder2 *iface, LPCITEMIDLIS
|
||||||
if (iColumn == COLUMN_NAME)
|
if (iColumn == COLUMN_NAME)
|
||||||
return RecycleBin_GetDisplayNameOf(iface, pidl, SHGDN_NORMAL, &pDetails->str);
|
return RecycleBin_GetDisplayNameOf(iface, pidl, SHGDN_NORMAL, &pDetails->str);
|
||||||
|
|
||||||
TRASH_UnpackItemID(&pidl->mkid, NULL, &data);
|
TRASH_UnpackItemID(&pidl->mkid, &data);
|
||||||
switch (iColumn)
|
switch (iColumn)
|
||||||
{
|
{
|
||||||
case COLUMN_DATEDEL:
|
case COLUMN_DATEDEL:
|
||||||
|
|
|
@ -320,24 +320,18 @@ BOOL TRASH_TrashFile(LPCWSTR wszPath)
|
||||||
* bucket name - currently only an empty string meaning the home bucket is supported
|
* bucket name - currently only an empty string meaning the home bucket is supported
|
||||||
* trash file name - a NUL-terminated string
|
* trash file name - a NUL-terminated string
|
||||||
*/
|
*/
|
||||||
struct tagTRASH_ELEMENT
|
static HRESULT TRASH_CreateSimplePIDL(LPCSTR filename, const WIN32_FIND_DATAW *data, LPITEMIDLIST *pidlOut)
|
||||||
{
|
{
|
||||||
TRASH_BUCKET *bucket;
|
LPITEMIDLIST pidl = SHAlloc(2+1+sizeof(WIN32_FIND_DATAW)+1+lstrlenA(filename)+1+2);
|
||||||
LPSTR filename;
|
|
||||||
};
|
|
||||||
|
|
||||||
static HRESULT TRASH_CreateSimplePIDL(const TRASH_ELEMENT *element, const WIN32_FIND_DATAW *data, LPITEMIDLIST *pidlOut)
|
|
||||||
{
|
|
||||||
LPITEMIDLIST pidl = SHAlloc(2+1+sizeof(WIN32_FIND_DATAW)+1+lstrlenA(element->filename)+1+2);
|
|
||||||
*pidlOut = NULL;
|
*pidlOut = NULL;
|
||||||
if (pidl == NULL)
|
if (pidl == NULL)
|
||||||
return E_OUTOFMEMORY;
|
return E_OUTOFMEMORY;
|
||||||
pidl->mkid.cb = (USHORT)(2+1+sizeof(WIN32_FIND_DATAW)+1+lstrlenA(element->filename)+1);
|
pidl->mkid.cb = (USHORT)(2+1+sizeof(WIN32_FIND_DATAW)+1+lstrlenA(filename)+1);
|
||||||
pidl->mkid.abID[0] = 0;
|
pidl->mkid.abID[0] = 0;
|
||||||
memcpy(pidl->mkid.abID+1, data, sizeof(WIN32_FIND_DATAW));
|
memcpy(pidl->mkid.abID+1, data, sizeof(WIN32_FIND_DATAW));
|
||||||
pidl->mkid.abID[1+sizeof(WIN32_FIND_DATAW)] = 0;
|
pidl->mkid.abID[1+sizeof(WIN32_FIND_DATAW)] = 0;
|
||||||
lstrcpyA((LPSTR)(pidl->mkid.abID+1+sizeof(WIN32_FIND_DATAW)+1), element->filename);
|
lstrcpyA((LPSTR)(pidl->mkid.abID+1+sizeof(WIN32_FIND_DATAW)+1), filename);
|
||||||
*(USHORT *)(pidl->mkid.abID+1+sizeof(WIN32_FIND_DATAW)+1+lstrlenA(element->filename)+1) = 0;
|
*(USHORT *)(pidl->mkid.abID+1+sizeof(WIN32_FIND_DATAW)+1+lstrlenA(filename)+1) = 0;
|
||||||
*pidlOut = pidl;
|
*pidlOut = pidl;
|
||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
@ -346,17 +340,15 @@ static HRESULT TRASH_CreateSimplePIDL(const TRASH_ELEMENT *element, const WIN32_
|
||||||
* TRASH_UnpackItemID [Internal]
|
* TRASH_UnpackItemID [Internal]
|
||||||
*
|
*
|
||||||
* DESCRIPTION:
|
* DESCRIPTION:
|
||||||
* Extract the information stored in an Item ID. The TRASH_ELEMENT
|
* Extract the information stored in an Item ID. The WIN32_FIND_DATA contains
|
||||||
* identifies the element in the Trash. The WIN32_FIND_DATA contains the
|
* the information about the original file. The data->ftLastAccessTime contains
|
||||||
* information about the original file. The data->ftLastAccessTime contains
|
|
||||||
* the deletion time
|
* the deletion time
|
||||||
*
|
*
|
||||||
* PARAMETER(S):
|
* PARAMETER(S):
|
||||||
* [I] id : the ID of the item
|
* [I] id : the ID of the item
|
||||||
* [O] element : the trash element this item id contains. Can be NULL if not needed
|
|
||||||
* [O] data : the WIN32_FIND_DATA of the original file. Can be NULL is not needed
|
* [O] data : the WIN32_FIND_DATA of the original file. Can be NULL is not needed
|
||||||
*/
|
*/
|
||||||
HRESULT TRASH_UnpackItemID(LPCSHITEMID id, TRASH_ELEMENT *element, WIN32_FIND_DATAW *data)
|
HRESULT TRASH_UnpackItemID(LPCSHITEMID id, WIN32_FIND_DATAW *data)
|
||||||
{
|
{
|
||||||
if (id->cb < 2+1+sizeof(WIN32_FIND_DATAW)+2)
|
if (id->cb < 2+1+sizeof(WIN32_FIND_DATAW)+2)
|
||||||
return E_INVALIDARG;
|
return E_INVALIDARG;
|
||||||
|
@ -367,22 +359,10 @@ HRESULT TRASH_UnpackItemID(LPCSHITEMID id, TRASH_ELEMENT *element, WIN32_FIND_DA
|
||||||
|
|
||||||
if (data != NULL)
|
if (data != NULL)
|
||||||
*data = *(WIN32_FIND_DATAW *)(id->abID+1);
|
*data = *(WIN32_FIND_DATAW *)(id->abID+1);
|
||||||
if (element != NULL)
|
|
||||||
{
|
|
||||||
element->bucket = home_trash;
|
|
||||||
element->filename = StrDupA((LPCSTR)(id->abID+1+sizeof(WIN32_FIND_DATAW)+1));
|
|
||||||
if (element->filename == NULL)
|
|
||||||
return E_OUTOFMEMORY;
|
|
||||||
}
|
|
||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TRASH_DisposeElement(TRASH_ELEMENT *element)
|
static HRESULT TRASH_GetDetails(const TRASH_BUCKET *bucket, LPCSTR filename, WIN32_FIND_DATAW *data)
|
||||||
{
|
|
||||||
SHFree(element->filename);
|
|
||||||
}
|
|
||||||
|
|
||||||
static HRESULT TRASH_GetDetails(const TRASH_ELEMENT *element, WIN32_FIND_DATAW *data)
|
|
||||||
{
|
{
|
||||||
LPSTR path = NULL;
|
LPSTR path = NULL;
|
||||||
XDG_PARSED_FILE *parsed = NULL;
|
XDG_PARSED_FILE *parsed = NULL;
|
||||||
|
@ -393,21 +373,21 @@ static HRESULT TRASH_GetDetails(const TRASH_ELEMENT *element, WIN32_FIND_DATAW *
|
||||||
HRESULT ret = S_FALSE;
|
HRESULT ret = S_FALSE;
|
||||||
LPWSTR original_dos_name;
|
LPWSTR original_dos_name;
|
||||||
int suffix_length = lstrlenA(trashinfo_suffix);
|
int suffix_length = lstrlenA(trashinfo_suffix);
|
||||||
int filename_length = lstrlenA(element->filename);
|
int filename_length = lstrlenA(filename);
|
||||||
int files_length = lstrlenA(element->bucket->files_dir);
|
int files_length = lstrlenA(bucket->files_dir);
|
||||||
int path_length = max(lstrlenA(element->bucket->info_dir), files_length);
|
int path_length = max(lstrlenA(bucket->info_dir), files_length);
|
||||||
|
|
||||||
path = SHAlloc(path_length + filename_length + 1);
|
path = SHAlloc(path_length + filename_length + 1);
|
||||||
if (path == NULL) return E_OUTOFMEMORY;
|
if (path == NULL) return E_OUTOFMEMORY;
|
||||||
wsprintfA(path, "%s%s", element->bucket->files_dir, element->filename);
|
wsprintfA(path, "%s%s", bucket->files_dir, filename);
|
||||||
path[path_length + filename_length - suffix_length] = 0; /* remove the '.trashinfo' */
|
path[path_length + filename_length - suffix_length] = 0; /* remove the '.trashinfo' */
|
||||||
if (lstat(path, &stats) == -1)
|
if (lstat(path, &stats) == -1)
|
||||||
{
|
{
|
||||||
ERR("Error accessing data file for trashinfo %s (errno=%d)\n", element->filename, errno);
|
ERR("Error accessing data file for trashinfo %s (errno=%d)\n", filename, errno);
|
||||||
goto failed;
|
goto failed;
|
||||||
}
|
}
|
||||||
|
|
||||||
wsprintfA(path, "%s%s", element->bucket->info_dir, element->filename);
|
wsprintfA(path, "%s%s", bucket->info_dir, filename);
|
||||||
fd = open(path, O_RDONLY);
|
fd = open(path, O_RDONLY);
|
||||||
if (fd == -1)
|
if (fd == -1)
|
||||||
{
|
{
|
||||||
|
@ -536,15 +516,14 @@ HRESULT TRASH_EnumItems(LPITEMIDLIST **pidls, int *count)
|
||||||
for (i=0; i<ti_count; i++)
|
for (i=0; i<ti_count; i++)
|
||||||
{
|
{
|
||||||
WIN32_FIND_DATAW data;
|
WIN32_FIND_DATAW data;
|
||||||
TRASH_ELEMENT elem;
|
LPCSTR filename;
|
||||||
|
|
||||||
elem.bucket = home_trash;
|
filename = DPA_GetPtr(tinfs, i);
|
||||||
elem.filename = DPA_GetPtr(tinfs, i);
|
if (FAILED(err = TRASH_GetDetails(home_trash, filename, &data)))
|
||||||
if (FAILED(err = TRASH_GetDetails(&elem, &data)))
|
|
||||||
goto failed;
|
goto failed;
|
||||||
if (err == S_FALSE)
|
if (err == S_FALSE)
|
||||||
continue;
|
continue;
|
||||||
if (FAILED(err = TRASH_CreateSimplePIDL(&elem, &data, &(*pidls)[pos])))
|
if (FAILED(err = TRASH_CreateSimplePIDL(filename, &data, &(*pidls)[pos])))
|
||||||
goto failed;
|
goto failed;
|
||||||
pos++;
|
pos++;
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,14 +37,10 @@ XDG_PARSED_FILE *XDG_ParseDesktopFile(int fd);
|
||||||
char *XDG_GetStringValue(XDG_PARSED_FILE *file, const char *group_name, const char *value_name, DWORD dwFlags);
|
char *XDG_GetStringValue(XDG_PARSED_FILE *file, const char *group_name, const char *value_name, DWORD dwFlags);
|
||||||
void XDG_FreeParsedFile(XDG_PARSED_FILE *file);
|
void XDG_FreeParsedFile(XDG_PARSED_FILE *file);
|
||||||
|
|
||||||
/* implemented in trash.c */
|
|
||||||
typedef struct tagTRASH_ELEMENT TRASH_ELEMENT;
|
|
||||||
|
|
||||||
BOOL TRASH_CanTrashFile(LPCWSTR wszPath);
|
BOOL TRASH_CanTrashFile(LPCWSTR wszPath);
|
||||||
BOOL TRASH_TrashFile(LPCWSTR wszPath);
|
BOOL TRASH_TrashFile(LPCWSTR wszPath);
|
||||||
HRESULT TRASH_UnpackItemID(LPCSHITEMID id, TRASH_ELEMENT *element, WIN32_FIND_DATAW *data);
|
HRESULT TRASH_UnpackItemID(LPCSHITEMID id, WIN32_FIND_DATAW *data);
|
||||||
HRESULT TRASH_EnumItems(LPITEMIDLIST **pidls, int *count);
|
HRESULT TRASH_EnumItems(LPITEMIDLIST **pidls, int *count);
|
||||||
void TRASH_DisposeElement(TRASH_ELEMENT *element);
|
|
||||||
|
|
||||||
HRESULT XDG_UserDirLookup(const char * const *xdg_dirs, const unsigned int num_dirs, char *** out_ptr);
|
HRESULT XDG_UserDirLookup(const char * const *xdg_dirs, const unsigned int num_dirs, char *** out_ptr);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue