shell: return status for moveItemToTrash on all platforms

This commit is contained in:
Robo 2015-03-27 18:31:57 +05:30
parent 8aae7c4440
commit bedea89dcf
5 changed files with 38 additions and 16 deletions

View file

@ -126,19 +126,21 @@ void OpenExternal(const GURL& url) {
LOG(WARNING) << "NSWorkspace failed to open URL " << url;
}
void MoveItemToTrash(const base::FilePath& full_path) {
bool MoveItemToTrash(const base::FilePath& full_path) {
DCHECK([NSThread isMainThread]);
NSString* path_string = base::SysUTF8ToNSString(full_path.value());
NSArray* file_array =
[NSArray arrayWithObject:[path_string lastPathComponent]];
if (!path_string || !file_array || ![[NSWorkspace sharedWorkspace]
performFileOperation:NSWorkspaceRecycleOperation
source:[path_string stringByDeletingLastPathComponent]
destination:@""
files:file_array
tag:nil])
int status = [[NSWorkspace sharedWorkspace]
performFileOperation:NSWorkspaceRecycleOperation
source:[path_string stringByDeletingLastPathComponent]
destination:@""
files:file_array
tag:nil];
if (!path_string || !file_array || !status)
LOG(WARNING) << "NSWorkspace failed to move file " << full_path.value()
<< " to trash";
return (status == 0);
}
void Beep() {