2 * The freedesktop.org Trash, implemented using the 0.7 spec version
3 * (see http://www.ramendik.ru/docs/trashspec.html)
5 * Copyright (C) 2006 Mikolaj Zalewski
6 * Copyright 2011 Jay Yang
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
25 #ifdef HAVE_CORESERVICES_CORESERVICES_H
26 #define GetCurrentThread MacGetCurrentThread
27 #define LoadResource MacLoadResource
28 #include <CoreServices/CoreServices.h>
29 #undef GetCurrentThread
39 #ifdef HAVE_SYS_STAT_H
40 # include <sys/stat.h>
42 #include <sys/types.h>
57 #include "wine/debug.h"
58 #include "shell32_main.h"
61 WINE_DEFAULT_DEBUG_CHANNEL(trash
);
64 * The item ID of a trashed element is built as follows:
65 * NUL byte - in most PIDLs the first byte is the type so we keep it constant
66 * WIN32_FIND_DATAW structure - with data about original file attributes
67 * bucket name - currently only an empty string meaning the home bucket is supported
68 * trash file name - a NUL-terminated string
70 static HRESULT
TRASH_CreateSimplePIDL(LPCSTR filename
, const WIN32_FIND_DATAW
*data
, LPITEMIDLIST
*pidlOut
)
72 LPITEMIDLIST pidl
= SHAlloc(2+1+sizeof(WIN32_FIND_DATAW
)+1+lstrlenA(filename
)+1+2);
76 pidl
->mkid
.cb
= (USHORT
)(2+1+sizeof(WIN32_FIND_DATAW
)+1+lstrlenA(filename
)+1);
77 pidl
->mkid
.abID
[0] = 0;
78 memcpy(pidl
->mkid
.abID
+1, data
, sizeof(WIN32_FIND_DATAW
));
79 pidl
->mkid
.abID
[1+sizeof(WIN32_FIND_DATAW
)] = 0;
80 lstrcpyA((LPSTR
)(pidl
->mkid
.abID
+1+sizeof(WIN32_FIND_DATAW
)+1), filename
);
81 *(USHORT
*)(pidl
->mkid
.abID
+1+sizeof(WIN32_FIND_DATAW
)+1+lstrlenA(filename
)+1) = 0;
86 /***********************************************************************
87 * TRASH_UnpackItemID [Internal]
90 * Extract the information stored in an Item ID. The WIN32_FIND_DATA contains
91 * the information about the original file. The data->ftLastAccessTime contains
95 * [I] id : the ID of the item
96 * [O] data : the WIN32_FIND_DATA of the original file. Can be NULL is not needed
98 HRESULT
TRASH_UnpackItemID(LPCSHITEMID id
, WIN32_FIND_DATAW
*data
)
100 if (id
->cb
< 2+1+sizeof(WIN32_FIND_DATAW
)+2)
102 if (id
->abID
[0] != 0 || id
->abID
[1+sizeof(WIN32_FIND_DATAW
)] != 0)
104 if (memchr(id
->abID
+1+sizeof(WIN32_FIND_DATAW
)+1, 0, id
->cb
-(2+1+sizeof(WIN32_FIND_DATAW
)+1)) == NULL
)
108 *data
= *(const WIN32_FIND_DATAW
*)(id
->abID
+1);
112 #ifdef HAVE_CORESERVICES_CORESERVICES_H
114 BOOL
TRASH_CanTrashFile(LPCWSTR wszPath
)
119 FSCatalogInfo catalogInfo
;
121 TRACE("(%s)\n", debugstr_w(wszPath
));
122 if (!(unix_path
= wine_get_unix_file_name(wszPath
)))
125 status
= FSPathMakeRef((UInt8
*)unix_path
, &ref
, NULL
);
126 heap_free(unix_path
);
128 status
= FSGetCatalogInfo(&ref
, kFSCatInfoVolume
, &catalogInfo
, NULL
,
131 status
= FSFindFolder(catalogInfo
.volume
, kTrashFolderType
,
132 kCreateFolder
, &ref
);
134 return (status
== noErr
);
137 BOOL
TRASH_TrashFile(LPCWSTR wszPath
)
142 TRACE("(%s)\n", debugstr_w(wszPath
));
143 if (!(unix_path
= wine_get_unix_file_name(wszPath
)))
146 status
= FSPathMoveObjectToTrashSync(unix_path
, NULL
, kFSFileOperationSkipPreflight
);
148 heap_free(unix_path
);
149 return (status
== noErr
);
153 * - set file deletion time
154 * - set original file location
156 HRESULT
TRASH_GetDetails(const char *trash_path
, const char *name
, WIN32_FIND_DATAW
*data
)
160 int trash_path_length
= lstrlenA(trash_path
);
161 int name_length
= lstrlenA(name
);
162 char *path
= SHAlloc(trash_path_length
+1+name_length
+1);
166 if(!once
++) FIXME("semi-stub\n");
168 if(!path
) return E_OUTOFMEMORY
;
169 memcpy(path
, trash_path
, trash_path_length
);
170 path
[trash_path_length
] = '/';
171 memcpy(path
+trash_path_length
+1, name
, name_length
+1);
173 ret
= lstat(path
, &stats
);
175 if(ret
== -1) return S_FALSE
;
176 memset(data
, 0, sizeof(*data
));
177 data
->nFileSizeHigh
= stats
.st_size
>>32;
178 data
->nFileSizeLow
= stats
.st_size
& 0xffffffff;
179 RtlSecondsSince1970ToTime(stats
.st_mtime
, (LARGE_INTEGER
*)&data
->ftLastWriteTime
);
181 if(!MultiByteToWideChar(CP_UNIXCP
, 0, name
, -1, data
->cFileName
, MAX_PATH
))
186 HRESULT
TRASH_EnumItems(const WCHAR
*path
, LPITEMIDLIST
**pidls
, int *count
)
188 WCHAR volume_path
[MAX_PATH
];
189 char *unix_path
, trash_path
[MAX_PATH
];
190 FSCatalogInfo catalog_info
;
193 struct dirent
*entry
;
199 TRACE("(%s %p %p)\n", debugstr_w(path
), pidls
, count
);
202 FIXME("All trashes enumeration not supported\n");
203 volume_path
[0] = 'C';
204 volume_path
[1] = ':';
207 if(!GetVolumePathNameW(path
, volume_path
, MAX_PATH
))
211 if(!(unix_path
= wine_get_unix_file_name(volume_path
)))
212 return E_OUTOFMEMORY
;
214 status
= FSPathMakeRef((UInt8
*)unix_path
, &ref
, NULL
);
215 heap_free(unix_path
);
216 if(status
!= noErr
) return E_FAIL
;
217 status
= FSGetCatalogInfo(&ref
, kFSCatInfoVolume
, &catalog_info
, NULL
, NULL
, NULL
);
218 if(status
!= noErr
) return E_FAIL
;
219 status
= FSFindFolder(catalog_info
.volume
, kTrashFolderType
, kCreateFolder
, &ref
);
220 if(status
!= noErr
) return E_FAIL
;
221 status
= FSRefMakePath(&ref
, (UInt8
*)trash_path
, MAX_PATH
);
222 if(status
!= noErr
) return E_FAIL
;
224 if(!(dir
= opendir(trash_path
))) return E_FAIL
;
225 ret
= heap_alloc(ret_size
* sizeof(*ret
));
228 return E_OUTOFMEMORY
;
230 while((entry
= readdir(dir
))) {
231 WIN32_FIND_DATAW data
;
233 if(!lstrcmpA(entry
->d_name
, ".") || !lstrcmpA(entry
->d_name
, ".." )
234 || !lstrcmpA(entry
->d_name
, ".DS_Store"))
238 LPITEMIDLIST
*resized
;
240 resized
= heap_realloc(ret
, ret_size
* sizeof(*ret
));
241 if(!resized
) hr
= E_OUTOFMEMORY
;
246 hr
= TRASH_GetDetails(trash_path
, entry
->d_name
, &data
);
247 if(hr
== S_FALSE
) continue;
250 hr
= TRASH_CreateSimplePIDL(entry
->d_name
, &data
, ret
+i
);
252 while(i
>0) SHFree(ret
+(--i
));
261 *pidls
= SHAlloc(sizeof(**pidls
) * i
);
263 while(i
>0) SHFree(ret
+(--i
));
265 return E_OUTOFMEMORY
;
268 for(i
--; i
>=0; i
--) (*pidls
)[i
] = ret
[i
];
273 HRESULT
TRASH_RestoreItem(LPCITEMIDLIST pidl
)
279 HRESULT
TRASH_EraseItem(LPCITEMIDLIST pidl
)
285 #else /* HAVE_CORESERVICES_CORESERVICES_H */
287 static CRITICAL_SECTION TRASH_Creating
;
288 static CRITICAL_SECTION_DEBUG TRASH_Creating_Debug
=
290 0, 0, &TRASH_Creating
,
291 { &TRASH_Creating_Debug
.ProcessLocksList
,
292 &TRASH_Creating_Debug
.ProcessLocksList
},
293 0, 0, { (DWORD_PTR
)__FILE__
": TRASH_Creating"}
295 static CRITICAL_SECTION TRASH_Creating
= { &TRASH_Creating_Debug
, -1, 0, 0, 0, 0 };
297 static const char trashinfo_suffix
[] = ".trashinfo";
298 static const char trashinfo_header
[] = "[Trash Info]\n";
299 static const char trashinfo_group
[] = "Trash Info";
308 static TRASH_BUCKET
*home_trash
=NULL
;
310 static char *init_home_dir(const char *subpath
)
312 char *path
= XDG_BuildPath(XDG_DATA_HOME
, subpath
);
313 if (path
== NULL
) return NULL
;
314 if (!XDG_MakeDirs(path
))
316 ERR("Couldn't create directory %s (errno=%d). Trash won't be available\n", debugstr_a(path
), errno
);
323 static TRASH_BUCKET
*TRASH_CreateHomeBucket(void)
325 TRASH_BUCKET
*bucket
;
326 struct stat trash_stat
;
327 char *trash_path
= NULL
;
329 bucket
= SHAlloc(sizeof(TRASH_BUCKET
));
335 memset(bucket
, 0, sizeof(*bucket
));
336 bucket
->info_dir
= init_home_dir("Trash/info/");
337 if (bucket
->info_dir
== NULL
) goto error
;
338 bucket
->files_dir
= init_home_dir("Trash/files/");
339 if (bucket
->files_dir
== NULL
) goto error
;
341 trash_path
= XDG_BuildPath(XDG_DATA_HOME
, "Trash/");
342 if (stat(trash_path
, &trash_stat
) == -1)
344 bucket
->device
= trash_stat
.st_dev
;
351 SHFree(bucket
->info_dir
);
352 SHFree(bucket
->files_dir
);
358 static BOOL
TRASH_EnsureInitialized(void)
360 if (home_trash
== NULL
)
362 EnterCriticalSection(&TRASH_Creating
);
363 if (home_trash
== NULL
)
364 home_trash
= TRASH_CreateHomeBucket();
365 LeaveCriticalSection(&TRASH_Creating
);
368 if (home_trash
== NULL
)
370 ERR("Couldn't initialize home trash (errno=%d)\n", errno
);
376 static BOOL
file_good_for_bucket(const TRASH_BUCKET
*pBucket
, const struct stat
*file_stat
)
378 if (pBucket
->device
!= file_stat
->st_dev
)
383 BOOL
TRASH_CanTrashFile(LPCWSTR wszPath
)
385 struct stat file_stat
;
389 TRACE("(%s)\n", debugstr_w(wszPath
));
390 if (!TRASH_EnsureInitialized()) return FALSE
;
391 if (!(unix_path
= wine_get_unix_file_name(wszPath
)))
393 ret
= lstat(unix_path
, &file_stat
);
394 heap_free(unix_path
);
397 return file_good_for_bucket(home_trash
, &file_stat
);
401 * Try to create a single .trashinfo file. Return TRUE if successful, else FALSE
403 static BOOL
try_create_trashinfo_file(const char *info_dir
, const char *file_name
,
404 const char *original_file_name
)
406 SYSTEMTIME curr_time
;
408 char *path
= SHAlloc(strlen(info_dir
)+strlen(file_name
)+strlen(trashinfo_suffix
)+1);
411 if (path
==NULL
) return FALSE
;
412 wsprintfA(path
, "%s%s%s", info_dir
, file_name
, trashinfo_suffix
);
413 TRACE("Trying to create '%s'\n", path
);
414 writer
= open(path
, O_CREAT
|O_WRONLY
|O_TRUNC
|O_EXCL
, 0600);
415 if (writer
==-1) goto error
;
417 write(writer
, trashinfo_header
, strlen(trashinfo_header
));
418 if (!XDG_WriteDesktopStringEntry(writer
, "Path", XDG_URLENCODE
, original_file_name
))
421 GetLocalTime( &curr_time
);
422 wnsprintfA(datebuf
, 200, "%04d-%02d-%02dT%02d:%02d:%02d",
423 curr_time
.wYear
, curr_time
.wMonth
, curr_time
.wDay
,
424 curr_time
.wHour
, curr_time
.wMinute
, curr_time
.wSecond
);
425 if (!XDG_WriteDesktopStringEntry(writer
, "DeletionDate", 0, datebuf
))
442 * Try to create a .trashinfo file. This function will make several attempts with
443 * different filenames. It will return the filename that succeeded or NULL if a file
444 * couldn't be created.
446 static char *create_trashinfo(const char *info_dir
, const char *file_path
)
448 const char *base_name
;
449 char *filename_buffer
;
450 ULONG seed
= GetTickCount();
453 errno
= ENOMEM
; /* out-of-memory is the only case when errno isn't set */
454 base_name
= strrchr(file_path
, '/');
455 if (base_name
== NULL
)
456 base_name
= file_path
;
460 filename_buffer
= SHAlloc(strlen(base_name
)+9+1);
461 if (filename_buffer
== NULL
)
463 lstrcpyA(filename_buffer
, base_name
);
464 if (try_create_trashinfo_file(info_dir
, filename_buffer
, file_path
))
465 return filename_buffer
;
468 sprintf(filename_buffer
, "%s-%d", base_name
, i
+1);
469 if (try_create_trashinfo_file(info_dir
, filename_buffer
, file_path
))
470 return filename_buffer
;
473 for (i
=0; i
<1000; i
++)
475 sprintf(filename_buffer
, "%s-%08x", base_name
, RtlRandom(&seed
));
476 if (try_create_trashinfo_file(info_dir
, filename_buffer
, file_path
))
477 return filename_buffer
;
480 WARN("Couldn't create trashinfo after 1031 tries (errno=%d)\n", errno
);
481 SHFree(filename_buffer
);
485 static void remove_trashinfo_file(const char *info_dir
, const char *base_name
)
487 char *filename_buffer
;
489 filename_buffer
= SHAlloc(lstrlenA(info_dir
)+lstrlenA(base_name
)+lstrlenA(trashinfo_suffix
)+1);
490 if (filename_buffer
== NULL
) return;
491 sprintf(filename_buffer
, "%s%s%s", info_dir
, base_name
, trashinfo_suffix
);
492 unlink(filename_buffer
);
493 SHFree(filename_buffer
);
496 static BOOL
TRASH_MoveFileToBucket(TRASH_BUCKET
*pBucket
, const char *unix_path
)
498 struct stat file_stat
;
499 char *trash_file_name
= NULL
;
500 char *trash_path
= NULL
;
503 if (lstat(unix_path
, &file_stat
)==-1)
505 if (!file_good_for_bucket(pBucket
, &file_stat
))
508 trash_file_name
= create_trashinfo(pBucket
->info_dir
, unix_path
);
509 if (trash_file_name
== NULL
)
512 trash_path
= SHAlloc(strlen(pBucket
->files_dir
)+strlen(trash_file_name
)+1);
513 if (trash_path
== NULL
) goto error
;
514 lstrcpyA(trash_path
, pBucket
->files_dir
);
515 lstrcatA(trash_path
, trash_file_name
);
517 if (rename(unix_path
, trash_path
)==0)
519 TRACE("rename succeeded\n");
523 /* TODO: try to manually move the file */
524 ERR("Couldn't move file\n");
527 remove_trashinfo_file(pBucket
->info_dir
, trash_file_name
);
529 SHFree(trash_file_name
);
534 BOOL
TRASH_TrashFile(LPCWSTR wszPath
)
539 TRACE("(%s)\n", debugstr_w(wszPath
));
540 if (!TRASH_EnsureInitialized()) return FALSE
;
541 if (!(unix_path
= wine_get_unix_file_name(wszPath
)))
543 result
= TRASH_MoveFileToBucket(home_trash
, unix_path
);
544 heap_free(unix_path
);
548 static HRESULT
TRASH_GetDetails(const TRASH_BUCKET
*bucket
, LPCSTR filename
, WIN32_FIND_DATAW
*data
)
551 XDG_PARSED_FILE
*parsed
= NULL
;
552 char *original_file_name
= NULL
;
553 char *deletion_date
= NULL
;
556 HRESULT ret
= S_FALSE
;
557 LPWSTR original_dos_name
;
558 int suffix_length
= lstrlenA(trashinfo_suffix
);
559 int filename_length
= lstrlenA(filename
);
560 int files_length
= lstrlenA(bucket
->files_dir
);
561 int path_length
= max(lstrlenA(bucket
->info_dir
), files_length
);
563 path
= SHAlloc(path_length
+ filename_length
+ 1);
564 if (path
== NULL
) return E_OUTOFMEMORY
;
565 wsprintfA(path
, "%s%s", bucket
->files_dir
, filename
);
566 path
[path_length
+ filename_length
- suffix_length
] = 0; /* remove the '.trashinfo' */
567 if (lstat(path
, &stats
) == -1)
569 ERR("Error accessing data file for trashinfo %s (errno=%d)\n", filename
, errno
);
573 wsprintfA(path
, "%s%s", bucket
->info_dir
, filename
);
574 fd
= open(path
, O_RDONLY
);
577 ERR("Couldn't open trashinfo file %s (errno=%d)\n", path
, errno
);
581 parsed
= XDG_ParseDesktopFile(fd
);
584 ERR("Parse error in trashinfo file %s\n", path
);
588 original_file_name
= XDG_GetStringValue(parsed
, trashinfo_group
, "Path", XDG_URLENCODE
);
589 if (original_file_name
== NULL
)
591 ERR("No 'Path' entry in trashinfo file\n");
595 ZeroMemory(data
, sizeof(*data
));
596 data
->nFileSizeHigh
= (DWORD
)((LONGLONG
)stats
.st_size
>>32);
597 data
->nFileSizeLow
= stats
.st_size
& 0xffffffff;
598 RtlSecondsSince1970ToTime(stats
.st_mtime
, (LARGE_INTEGER
*)&data
->ftLastWriteTime
);
600 original_dos_name
= wine_get_dos_file_name(original_file_name
);
601 if (original_dos_name
!= NULL
)
603 lstrcpynW(data
->cFileName
, original_dos_name
, MAX_PATH
);
604 SHFree(original_dos_name
);
608 /* show only the file name */
609 char *file
= strrchr(original_file_name
, '/');
611 file
= original_file_name
;
612 MultiByteToWideChar(CP_UNIXCP
, 0, file
, -1, data
->cFileName
, MAX_PATH
);
615 deletion_date
= XDG_GetStringValue(parsed
, trashinfo_group
, "DeletionDate", 0);
621 sscanf(deletion_date
, "%d-%d-%dT%d:%d:%d",
622 &del_time
.tm_year
, &del_time
.tm_mon
, &del_time
.tm_mday
,
623 &del_time
.tm_hour
, &del_time
.tm_min
, &del_time
.tm_sec
);
624 del_time
.tm_year
-= 1900;
626 del_time
.tm_isdst
= -1;
627 del_secs
= mktime(&del_time
);
629 RtlSecondsSince1970ToTime(del_secs
, (LARGE_INTEGER
*)&data
->ftLastAccessTime
);
635 SHFree(original_file_name
);
636 SHFree(deletion_date
);
639 XDG_FreeParsedFile(parsed
);
643 static INT CALLBACK
free_item_callback(void *item
, void *lParam
)
649 static HDPA
enum_bucket_trashinfos(const TRASH_BUCKET
*bucket
, int *count
)
651 HDPA ret
= DPA_Create(32);
652 struct dirent
*entry
;
657 if (ret
== NULL
) goto failed
;
658 dir
= opendir(bucket
->info_dir
);
659 if (dir
== NULL
) goto failed
;
660 while ((entry
= readdir(dir
)) != NULL
)
663 int namelen
= lstrlenA(entry
->d_name
);
664 int suffixlen
= lstrlenA(trashinfo_suffix
);
665 if (namelen
<= suffixlen
||
666 lstrcmpA(entry
->d_name
+namelen
-suffixlen
, trashinfo_suffix
) != 0)
669 filename
= StrDupA(entry
->d_name
);
670 if (filename
== NULL
)
672 if (DPA_InsertPtr(ret
, DPA_APPEND
, filename
) == -1)
682 if (dir
) closedir(dir
);
684 DPA_DestroyCallback(ret
, free_item_callback
, NULL
);
688 HRESULT
TRASH_EnumItems(const WCHAR
*path
, LPITEMIDLIST
**pidls
, int *count
)
692 HRESULT err
= E_OUTOFMEMORY
;
696 FIXME("Ignoring path = %s\n", debugstr_w(path
));
698 if (!TRASH_EnsureInitialized()) return E_FAIL
;
699 tinfs
= enum_bucket_trashinfos(home_trash
, &ti_count
);
700 if (tinfs
== NULL
) return E_FAIL
;
701 *pidls
= SHAlloc(sizeof(LPITEMIDLIST
)*ti_count
);
702 if (!*pidls
) goto failed
;
703 for (i
=0; i
<ti_count
; i
++)
705 WIN32_FIND_DATAW data
;
708 filename
= DPA_GetPtr(tinfs
, i
);
709 if (FAILED(err
= TRASH_GetDetails(home_trash
, filename
, &data
)))
713 if (FAILED(err
= TRASH_CreateSimplePIDL(filename
, &data
, &(*pidls
)[pos
])))
718 DPA_DestroyCallback(tinfs
, free_item_callback
, NULL
);
724 for (j
=0; j
<pos
; j
++)
728 DPA_DestroyCallback(tinfs
, free_item_callback
, NULL
);
733 HRESULT
TRASH_RestoreItem(LPCITEMIDLIST pidl
){
734 int suffix_length
= strlen(trashinfo_suffix
);
735 LPCSHITEMID id
= &(pidl
->mkid
);
736 const char *bucket_name
= (const char*)(id
->abID
+1+sizeof(WIN32_FIND_DATAW
));
737 const char *filename
= (const char*)(id
->abID
+1+sizeof(WIN32_FIND_DATAW
)+strlen(bucket_name
)+1);
739 WIN32_FIND_DATAW data
;
742 TRACE("(%p)\n",pidl
);
743 if(strcmp(filename
+strlen(filename
)-suffix_length
,trashinfo_suffix
))
745 ERR("pidl at %p is not a valid recycle bin entry\n",pidl
);
748 TRASH_UnpackItemID(id
,&data
);
749 restore_path
= wine_get_unix_file_name(data
.cFileName
);
750 file_path
= SHAlloc(max(strlen(home_trash
->files_dir
),strlen(home_trash
->info_dir
))+strlen(filename
)+1);
751 sprintf(file_path
,"%s%s",home_trash
->files_dir
,filename
);
752 file_path
[strlen(home_trash
->files_dir
)+strlen(filename
)-suffix_length
] = '\0';
753 if(!rename(file_path
,restore_path
))
755 sprintf(file_path
,"%s%s",home_trash
->info_dir
,filename
);
756 if(unlink(file_path
))
757 WARN("failed to delete the trashinfo file %s\n",filename
);
760 WARN("could not erase %s from the trash (errno=%i)\n",filename
,errno
);
762 heap_free(restore_path
);
766 HRESULT
TRASH_EraseItem(LPCITEMIDLIST pidl
)
768 int suffix_length
= strlen(trashinfo_suffix
);
770 LPCSHITEMID id
= &(pidl
->mkid
);
771 const char *bucket_name
= (const char*)(id
->abID
+1+sizeof(WIN32_FIND_DATAW
));
772 const char *filename
= (const char*)(id
->abID
+1+sizeof(WIN32_FIND_DATAW
)+strlen(bucket_name
)+1);
775 TRACE("(%p)\n",pidl
);
776 if(strcmp(filename
+strlen(filename
)-suffix_length
,trashinfo_suffix
))
778 ERR("pidl at %p is not a valid recycle bin entry\n",pidl
);
781 file_path
= SHAlloc(max(strlen(home_trash
->files_dir
),strlen(home_trash
->info_dir
))+strlen(filename
)+1);
782 sprintf(file_path
,"%s%s",home_trash
->info_dir
,filename
);
783 if(unlink(file_path
))
784 WARN("failed to delete the trashinfo file %s\n",filename
);
785 sprintf(file_path
,"%s%s",home_trash
->files_dir
,filename
);
786 file_path
[strlen(home_trash
->files_dir
)+strlen(filename
)-suffix_length
] = '\0';
787 if(unlink(file_path
))
788 WARN("could not erase %s from the trash (errno=%i)\n",filename
,errno
);
793 #endif /* HAVE_CORESERVICES_CORESERVICES_H */