Skip to content

Commit

Permalink
feat: check for operation abort
Browse files Browse the repository at this point in the history
  • Loading branch information
anatawa12 committed Aug 9, 2024
1 parent a754f4a commit 7919178
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/windows.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,15 @@ impl TrashContext {
pfo.DeleteItem(&shi, None)?;
}
pfo.PerformOperations()?;

// https://learn.microsoft.com/en-us/windows/win32/api/shobjidl_core/nf-shobjidl_core-ifileoperation-performoperations
// this method can still return a success code. Use the GetAnyOperationsAborted method to determine if this was the case.
if pfo.GetAnyOperationsAborted()?.as_bool() {
// TODO: return the reason why the operation was aborted.
// We may retrieve reason from the IFileOperationProgressSink but
// the list of HRESULT codes is not documented.
return Err(Error::Unknown { description: "Some operations were aborted".into() });
}
Ok(())
}
}
Expand Down

0 comments on commit 7919178

Please sign in to comment.