24 return QOhosJsThreadGateway::evalWithPromise<
bool>(
25 [&](QOhosJsState &jsState, QOhosTaskPromise<
bool> resultPromise) {
26 auto optFileOhosUri = tryMapPathToOhosFileUri(filePath.toStdString());
27 if (!optFileOhosUri.has_value()) {
32 QNapi::Value deletePromiseOrValue;
34 deletePromiseOrValue = jsState.eval(
35 "@kit.FileManagerServiceKit.fileManagerService.deleteToTrash(*)",
36 {optFileOhosUri.value()});
37 }
catch (
const Napi::Error &error) {
39 "deleteToTrash('%s') failed with error: %s",
40 optFileOhosUri.value().c_str(), error.what());
43 if (deletePromiseOrValue.IsPromise()) {
44 auto thenCatchPromises = std::move(resultPromise).makeThenCatchBranches(Q_FUNC_INFO);
45 QNapi::checkedCast<QNapi::Promise>(deletePromiseOrValue)
47 [thenPromise = std::move(thenCatchPromises.first)](
const QOhosCallbackInfo &cbInfo) {
48 std::string deletedPath = cbInfo.getFirstArg<QNapi::String>(Q_FUNC_INFO);
49 thenPromise(!deletedPath.empty());
52 [catchPromise = std::move(thenCatchPromises.second)](
const QOhosCallbackInfo &cbInfo) {
53 QtOhos::logJsCallbackError(cbInfo,
"Got error from deleteToTrash()");
57 qOhosPrintfWarning(
"Got non-Promise from deleteToTrash()");
71bool QFileSystemEngine::moveFileToTrash(
const QFileSystemEntry &source,