24 return QOhosJsThreadGateway::evalWithConsumer<
bool>(
25 [&](QOhosJsState &jsState, QOhosConsumer<
bool> resultConsumer) {
26 auto optFileOhosUri = tryMapPathToOhosFileUri(filePath.toStdString());
27 if (!optFileOhosUri.has_value()) {
28 resultConsumer(
false);
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 QNapi::checkedCast<QNapi::Promise>(deletePromiseOrValue)
45 .withContext(std::move(resultConsumer))
47 [](
const QOhosCallbackInfo &cbInfo,
auto &resultConsumer) {
48 std::string deletedPath = cbInfo.getFirstArg<QNapi::String>(Q_FUNC_INFO);
49 resultConsumer(!deletedPath.empty());
52 [](
const QOhosCallbackInfo &cbInfo,
auto &resultConsumer) {
53 QtOhos::logJsCallbackError(cbInfo,
"Got error from deleteToTrash()");
54 resultConsumer(
false);
57 qOhosPrintfWarning(
"Got non-Promise from deleteToTrash()");
58 resultConsumer(
false);
70bool QFileSystemEngine::moveFileToTrash(
const QFileSystemEntry &source,