Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qohosfileshare.cpp
Go to the documentation of this file.
1// Copyright (C) 2026 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
5#include <QtCore/private/qcore_ohos_p.h>
6#include <QtCore/private/qohoscommon_p.h>
7#include <QtCore/private/qohoslogger_p.h>
8#include <QtCore/private/qohospathutils_p.h>
9#include <QtCore/qscopeguard.h>
10#include <QtOhosAppKit/private/qohosoperationstatus_p.h>
11#include <cstdlib>
12#include <cstring>
13#include <memory>
14#include <optional>
15#include <string>
16#include <tuple>
17#include <utility>
18#include <vector>
19
20#include <filemanagement/fileshare/oh_file_share.h>
21
22QT_BEGIN_NAMESPACE
23
24namespace QtOhosAppKit {
25
26using namespace Private;
27
28/*!
29 \namespace QtOhosAppKit::FileShare
30 \inmodule QtOhosAppKit
31 \since 5.12.12
32 \brief The FileShare to expose file permission API.
33
34 This API uses file system paths, which differ from the URIs used internally by HarmonyOS. For example, the path
35 \c /data/storage/el1/bundle/entry/resources/resfile/test.txt
36 will be converted to the URI
37 \c file://com.your.example/data/storage/el1/bundle/entry/resources/resfile/test.txt , where \c com.your.example is app bundle name.
38
39 To learn more about file paths and URIs in HarmonyOS, see
40 \l{https://developer.huawei.com/consumer/en/doc/harmonyos-guides-V5/app-sandbox-directory-V5} {sandbox documentation}.
41
42 \warning
43 This API relies on the underlying OHOS implementation.
44 The following functions: persistPermission(), revokePermission(), activatePermission(), deactivatePermission(), and checkPersistent() may be unavailable on some devices.
45 Additionally, there may be limitations on the maximum number of policies, and certain permissions may need to be explicitly granted to the application.
46
47 For more details and limitations, refer to the
48 \l{https://developer.huawei.com/consumer/en/doc/harmonyos-guides-V14/native-fileshare-guidelines-V14} {API documentation}.
49*/
50namespace FileShare {
51
52namespace {
53
54std::shared_ptr<char> makeSharedNullTerminatedString(std::string str)
55{
56 auto sharedStrData = QtOhos::moveToSharedPtr(std::move(str) + '\0');
57 return std::shared_ptr<char>(sharedStrData, &sharedStrData->front());
58}
59
60std::shared_ptr<char> makeSharedNullTerminatedString(const char *str)
61{
62 return makeSharedNullTerminatedString(std::string(str != nullptr ? str : ""));
63}
64
65std::shared_ptr<::FileShare_PolicyInfo> makeFileSharePolicyInfo(
66 std::string uri, unsigned operationMode)
67{
68 auto sharedUri = makeSharedNullTerminatedString(std::move(uri));
69
70 auto policyInfo = QtOhos::moveToSharedPtr(
71 ::FileShare_PolicyInfo{
72 .uri = sharedUri.get(),
73 .length = static_cast<unsigned>(std::strlen(sharedUri.get())),
74 .operationMode = operationMode,
75 });
76
77 return QtOhos::makeSharedPtrWithAttachedExtraData(
78 policyInfo, sharedUri);
79}
80
81std::vector<std::shared_ptr<::FileShare_PolicyInfo>> convertToFileSharePolicyInfos(
82 const QList<PathPolicy> &policies)
83{
84 std::vector<std::shared_ptr<::FileShare_PolicyInfo>> fileSharePolicies;
85
86 for (const auto &policy : policies) {
87 fileSharePolicies.push_back(
88 makeFileSharePolicyInfo(
89 tryMapPathToOhosFileUri(policy.path.toStdString()).value_or(""),
90 static_cast<unsigned>(policy.operationModes.toInt())));
91 }
92
93 return fileSharePolicies;
94}
95
96std::shared_ptr<::FileShare_PolicyErrorResult> makeFileSharePolicyErrorResultFromRawStruct(
97 const ::FileShare_PolicyErrorResult &inputStruct)
98{
99 auto sharedUri = makeSharedNullTerminatedString(inputStruct.uri);
100 auto sharedMessage = makeSharedNullTerminatedString(inputStruct.message);
101
102 auto policyErrorResult = QtOhos::moveToSharedPtr(
103 ::FileShare_PolicyErrorResult{
104 .uri = sharedUri.get(),
105 .code = inputStruct.code,
106 .message = sharedMessage.get(),
107 });
108
109 return QtOhos::makeSharedPtrWithAttachedExtraData(
110 policyErrorResult,
111 QtOhos::moveToSharedPtr(std::make_tuple(sharedUri, sharedMessage)));
112};
113
114std::vector<::FileShare_PolicyInfo> makePoliciesRawVectorView(
115 const std::vector<std::shared_ptr<::FileShare_PolicyInfo>> &policies)
116{
117 std::vector<::FileShare_PolicyInfo> rawVectorView;
118 for (const auto &policyPtr : policies)
119 rawVectorView.push_back(*policyPtr);
120
121 return rawVectorView;
122}
123
124template<typename PermissionActionFunc>
125::FileManagement_ErrCode callFileSharePermissionActionFunc(
126 PermissionActionFunc permissionActionFunc,
127 const std::vector<std::shared_ptr<::FileShare_PolicyInfo>> &policies,
128 std::vector<std::shared_ptr<::FileShare_PolicyErrorResult>> &outResult)
129{
130 auto policiesRawVectorView = makePoliciesRawVectorView(policies);
131 ::FileShare_PolicyErrorResult *resultParam = nullptr;
132 unsigned resultNumParam = 0;
133 auto resultParamReleaseGuard = qScopeGuard(
134 [&]() {
135 if (resultParam != nullptr && resultNumParam != 0)
136 ::OH_FileShare_ReleasePolicyErrorResult(resultParam, resultNumParam);
137 });
138
139 auto errCode = permissionActionFunc(
140 policiesRawVectorView.data(), policiesRawVectorView.size(),
141 &resultParam, &resultNumParam);
142
143 outResult.clear();
144 if (resultParam != nullptr) {
145 for (unsigned i = 0; i < resultNumParam; ++i) {
146 outResult.push_back(
147 makeFileSharePolicyErrorResultFromRawStruct(resultParam[i]));
148 }
149 }
150
151 return errCode;
152}
153
154::FileManagement_ErrCode fileShareCheckPersistentPermission(
155 const std::vector<std::shared_ptr<::FileShare_PolicyInfo>> &policies,
156 std::vector<bool> &outResult)
157{
158 auto policiesRawVectorView = makePoliciesRawVectorView(policies);
159 bool *resultParam = nullptr;
160 auto resultParamReleaseGuard = qScopeGuard(
161 [&]() {
162 ::free(resultParam);
163 });
164 unsigned resultNumParam = 0;
165
166 auto errCode = ::OH_FileShare_CheckPersistentPermission(
167 policiesRawVectorView.data(), policiesRawVectorView.size(),
168 &resultParam, &resultNumParam);
169
170 outResult.clear();
171 if (resultParam != nullptr) {
172 for (unsigned i = 0; i < resultNumParam; ++i)
173 outResult.push_back(resultParam[i]);
174 }
175
176 return errCode;
177}
178
179::FileManagement_ErrCode fileSharePersistPermission(
180 const std::vector<std::shared_ptr<::FileShare_PolicyInfo>> &policies,
181 std::vector<std::shared_ptr<::FileShare_PolicyErrorResult>> &outResult)
182{
183 return callFileSharePermissionActionFunc(
184 Q_OHOS_NAMED_FUNC(::OH_FileShare_PersistPermission),
185 policies, outResult);
186}
187
188::FileManagement_ErrCode fileShareRevokePermission(
189 const std::vector<std::shared_ptr<::FileShare_PolicyInfo>> &policies,
190 std::vector<std::shared_ptr<::FileShare_PolicyErrorResult>> &outResult)
191{
192 return callFileSharePermissionActionFunc(
193 Q_OHOS_NAMED_FUNC(::OH_FileShare_RevokePermission),
194 policies, outResult);
195}
196
197::FileManagement_ErrCode fileShareActivatePermission(
198 const std::vector<std::shared_ptr<::FileShare_PolicyInfo>> &policies,
199 std::vector<std::shared_ptr<::FileShare_PolicyErrorResult>> &outResult)
200{
201 return callFileSharePermissionActionFunc(
202 Q_OHOS_NAMED_FUNC(::OH_FileShare_ActivatePermission),
203 policies, outResult);
204}
205
206::FileManagement_ErrCode fileShareDeactivatePermission(
207 const std::vector<std::shared_ptr<::FileShare_PolicyInfo>> &policies,
208 std::vector<std::shared_ptr<::FileShare_PolicyErrorResult>> &outResult)
209{
210 return callFileSharePermissionActionFunc(
211 Q_OHOS_NAMED_FUNC(::OH_FileShare_DeactivatePermission),
212 policies, outResult);
213}
214
215std::optional<PathPolicyError> tryMapFileSharePolicyErrorCode(::FileShare_PolicyErrorCode errorCode)
216{
217 switch (errorCode) {
218 case ::FileShare_PolicyErrorCode::PERSISTENCE_FORBIDDEN:
219 return std::make_optional(PathPolicyError::PersistenceForbidden);
220 case ::FileShare_PolicyErrorCode::INVALID_MODE:
221 return std::make_optional(PathPolicyError::InvalidMode);
222 case ::FileShare_PolicyErrorCode::INVALID_PATH:
223 return std::make_optional(PathPolicyError::InvalidPath);
224 case ::FileShare_PolicyErrorCode::PERMISSION_NOT_PERSISTED:
225 return std::make_optional(PathPolicyError::PermissionNotPersisted);
226 }
227 return std::nullopt;
228}
229
230QList<PathPolicyErrorInfo> convertToPathPolicyErrorInfos(
231 const std::vector<std::shared_ptr<::FileShare_PolicyErrorResult>> &policyErrorResults)
232{
233 QList<PathPolicyErrorInfo> result;
234 for (const auto &policyErrorResult : policyErrorResults) {
235 result.push_back({
236 .path = policyErrorResult->uri != nullptr
237 ? QString::fromStdString(tryMapOhosFileUriToPath(policyErrorResult->uri).value_or(""))
238 : QString(),
239 .error =
240 tryMapFileSharePolicyErrorCode(policyErrorResult->code)
241 .value_or(PathPolicyError::Unknown),
242 .errorMessage = QLatin1String(
243 policyErrorResult->message != nullptr ? policyErrorResult->message : ""),
244 });
245 }
246
247 return result;
248}
249
250QList<PathPolicyCheckResult> convertToPathPolicyCheckResults(
251 const std::vector<bool> &checkResults,
252 const QList<PathPolicy> &policies)
253{
254 QList<PathPolicyCheckResult> result;
255 for (std::size_t i = 0; i < checkResults.size() && policies.size(); ++i)
256 result.push_back({policies[i], checkResults[i]});
257
258 return result;
259}
260
261bool validateCheckResultsAgainstPolicies(
262 const std::vector<bool> &checkResults,
263 const QList<PathPolicy> &policies)
264{
265 return checkResults.size() == static_cast<std::size_t>(policies.size());
266}
267
268bool isSuccessErrorCode(::FileManagement_ErrCode errorCode)
269{
270 return errorCode == ::FileManagement_ErrCode::ERR_OK;
271}
272
273/*!
274 \class QtOhosAppKit::FileShare::ActionResult
275 \inmodule QtOhosAppKit
276 \since 5.12.12
277 \brief The ActionResult class encapsulates the result of all file requested access permission actions.
278
279 It contains any errors that occurred during the execution of these actions.
280
281 \sa persistPermission(), revokePermission(), activatePermission(), deactivatePermission()
282*/
283class ActionResultImpl : public ActionResult
284{
285public:
286 ActionResultImpl(bool successFlag, QList<PathPolicyErrorInfo> errorInfoList);
287 std::shared_ptr<OperationStatus> operationStatus() const override;
288 QList<PathPolicyErrorInfo> errorInfoList() const override;
289
290private:
291 std::shared_ptr<OperationStatus> m_operationStatus;
292 QList<PathPolicyErrorInfo> m_errorInfoList;
293};
294
295ActionResultImpl::ActionResultImpl(bool successFlag, QList<PathPolicyErrorInfo> errorInfoList)
296 : m_operationStatus(createOperationStatus(successFlag))
297 , m_errorInfoList(std::move(errorInfoList))
298{
299}
300
301/*!
302 \fn std::shared_ptr<OperationStatus> QtOhosAppKit::FileShare::ActionResult::operationStatus() const
303
304 Returns the overall result of all requested file access permission actions.
305
306 \sa OperationStatus
307*/
308std::shared_ptr<OperationStatus> ActionResultImpl::operationStatus() const
309{
310 return m_operationStatus;
311}
312
313/*!
314 \fn QList<PathPolicyErrorInfo> QtOhosAppKit::FileShare::ActionResult::errorInfoList() const
315
316 Returns a list of errors for each file access action.
317
318 Each entry in the list corresponds to a specific file operation that encountered an error.
319
320 \sa PathPolicyErrorInfo
321*/
322QList<PathPolicyErrorInfo> ActionResultImpl::errorInfoList() const
323{
324 return m_errorInfoList;
325}
326
327/*!
328 \class QtOhosAppKit::FileShare::CheckResult
329 \inmodule QtOhosAppKit
330 \since 5.12.12
331 \brief The CheckResult class encapsulates the result of all requested file access permission checks.
332
333 \sa checkPersistent()
334*/
335class CheckResultImpl : public CheckResult
336{
337public:
338 CheckResultImpl(
339 bool successFlag, const std::vector<bool> &checkResults,
340 const QList<PathPolicy> &policies);
341 std::shared_ptr<OperationStatus> operationStatus() const override;
342 QList<PathPolicyCheckResult> checkResultList() const override;
343
344private:
345 std::shared_ptr<OperationStatus> m_operationStatus;
346 QList<PathPolicyCheckResult> m_checkResultList;
347};
348
349CheckResultImpl::CheckResultImpl(
350 bool successFlag, const std::vector<bool> &checkResults,
351 const QList<PathPolicy> &policies)
352{
353 if (validateCheckResultsAgainstPolicies(checkResults, policies)) {
354 m_operationStatus = createOperationStatus(successFlag);
355 m_checkResultList = convertToPathPolicyCheckResults(checkResults, policies);
356 } else {
357 qOhosPrintfWarning(
358 "%s: didn't get check results for all requested paths. "
359 "Got %lld check results, but requested checks for %lld paths.",
360 Q_FUNC_INFO, static_cast<long long>(checkResults.size()),
361 static_cast<long long>(policies.size()));
362 m_operationStatus = createOperationStatus(false);
363 }
364}
365
366/*!
367 \fn std::shared_ptr<OperationStatus> QtOhosAppKit::FileShare::CheckResult::operationStatus() const
368
369 Returns the overall result of all requested file access permission checks.
370
371 \sa OperationStatus
372*/
373std::shared_ptr<OperationStatus> CheckResultImpl::operationStatus() const
374{
375 return m_operationStatus;
376}
377
378/*!
379 \fn QList<PathPolicyCheckResult> QtOhosAppKit::FileShare::CheckResult::checkResultList() const
380
381 Returns a list of results for each individual file access permission check.
382
383 Each entry in the list corresponds to a specific file and its check result.
384
385 \sa PathPolicyCheckResult
386*/
387QList<PathPolicyCheckResult> CheckResultImpl::checkResultList() const
388{
389 return m_checkResultList;
390}
391
392}
393
394/*!
395 \enum QtOhosAppKit::FileShare::OperationMode
396 \since 5.12.12
397
398 Defines permissions on path. See \l {https://developer.huawei.com/consumer/en/doc/harmonyos-references-V5/file_share-V5#fileshare_operationmode}
399 {FileShare_OperationMode}. The flags can be combined using bitwise operations.
400
401 \value Read Read on path
402 \value Write Write on path
403
404 \sa PathPolicy
405*/
406
407/*!
408 \enum QtOhosAppKit::FileShare::PathPolicyError
409 \since 5.12.12
410
411 Defines permission policy error codes. See \l {https://developer.huawei.com/consumer/en/doc/harmonyos-references-V5/file_share-V5#fileshare_policyerrorcode}
412 {FileShare_PolicyErrorCode}.
413
414 \value Unknown Error type is unknown or not recognized
415 \value PersistenceForbidden The permission on the path cannot be persisted
416 \value InvalidMode Invalid operation mode
417 \value InvalidPath Invalid path
418 \value PermissionNotPersisted The permission is not persisted
419
420 \sa PathPolicyErrorInfo
421*/
422
423/*!
424 \class QtOhosAppKit::FileShare::PathPolicy
425 \inmodule QtOhosAppKit
426 \since 5.12.12
427 \brief The PathPolicy struct encapsulates information required to request file access permissions for a specified path.
428*/
429
430/*!
431 \variable QtOhosAppKit::FileShare::PathPolicy::path
432 \brief The path for which access permission is requested.
433*/
434
435/*!
436 \variable QtOhosAppKit::FileShare::PathPolicy::operationModes
437 \brief The types of access being requested for the file.
438
439 \sa OperationMode
440*/
441
442/*!
443 \class QtOhosAppKit::FileShare::PathPolicyErrorInfo
444 \inmodule QtOhosAppKit
445 \since 5.12.12
446 \brief The PathPolicyErrorInfo struct contains the result of a file access permission request for a specified path.
447
448 \sa ActionResult
449*/
450
451/*!
452 \variable QtOhosAppKit::FileShare::PathPolicyErrorInfo::path
453 \brief The path for which access permission was requested.
454*/
455
456/*!
457 \variable QtOhosAppKit::FileShare::PathPolicyErrorInfo::error
458 \brief The error code indicating the result of the file access permission request.
459
460 \sa PathPolicyError
461*/
462
463/*!
464 \variable QtOhosAppKit::FileShare::PathPolicyErrorInfo::errorMessage
465 \brief Detailed error message.
466*/
467
468/*!
469 \class QtOhosAppKit::FileShare::PathPolicyCheckResult
470 \inmodule QtOhosAppKit
471 \since 5.12.12
472 \brief The PathPolicyCheckResult struct contains the result of a file permission check request for a specified path, indicating whether access is granted or denied.
473*/
474
475/*!
476 \variable QtOhosAppKit::FileShare::PathPolicyCheckResult::policy
477 \brief The requested path and the corresponding operation mode information.
478
479 \sa PathPolicy
480*/
481
482/*!
483 \variable QtOhosAppKit::FileShare::PathPolicyCheckResult::result
484 \brief The outcome of the permission check for the requested path and operation mode.
485*/
486
487ActionResult::ActionResult() = default;
488
489ActionResult::~ActionResult() = default;
490
491CheckResult::CheckResult() = default;
492
493CheckResult::~CheckResult() = default;
494
495/*!
496 \fn std::shared_ptr<ActionResult> QtOhosAppKit::FileShare::persistPermission(const QList<PathPolicy> &policies)
497
498 Persists file or folder permissions from \a policies.
499 The success of the action can be determined from ActionResult.
500
501 This function calls \l {https://developer.huawei.com/consumer/en/doc/harmonyos-references-V5/file_share-V5#oh_fileshare_persistpermission} {OH_FileShare_PersistPermission}.
502 persistPermission() stores persistence data in the system database. After persistPermission() call, permissions are not yet active. Use activatePermission() to activate permissions.
503 persistPermission() must be called at least once before activatePermission().
504
505 To revoke a persistent permission, use revokePermission().
506
507 \sa ActionResult, PathPolicy, revokePermission(), activatePermission()
508*/
509std::shared_ptr<ActionResult> persistPermission(const QList<PathPolicy> &policies)
510{
511 auto actionResult = QOhosJsThreadGateway::eval(
512 [&](QOhosJsState &) {
513 std::vector<std::shared_ptr<::FileShare_PolicyErrorResult>> outResults;
514 auto retCode = fileSharePersistPermission(
515 convertToFileSharePolicyInfos(policies), outResults);
516
517 return std::make_pair(isSuccessErrorCode(retCode), convertToPathPolicyErrorInfos(outResults));
518 },
519 Q_FUNC_INFO);
520 return std::make_shared<ActionResultImpl>(actionResult.first, actionResult.second);
521}
522
523/*!
524 \fn std::shared_ptr<ActionResult> QtOhosAppKit::FileShare::revokePermission(const QList<PathPolicy> &policies)
525
526 Revokes file or folder permissions from \a policies.
527 The success of the action can be determined from ActionResult.
528
529 This function calls \l {https://developer.huawei.com/consumer/en/doc/harmonyos-references-V5/file_share-V5#oh_fileshare_revokepermission} {OH_FileShare_RevokePermission}.
530
531 To persist permission, use persistPermission().
532
533 \sa ActionResult, PathPolicy, persistPermission()
534*/
535std::shared_ptr<ActionResult> revokePermission(const QList<PathPolicy> &policies)
536{
537 auto actionResult = QOhosJsThreadGateway::eval(
538 [&](QOhosJsState &) {
539 std::vector<std::shared_ptr<::FileShare_PolicyErrorResult>> outResults;
540 auto retCode = fileShareRevokePermission(
541 convertToFileSharePolicyInfos(policies), outResults);
542
543 return std::make_pair(isSuccessErrorCode(retCode), convertToPathPolicyErrorInfos(outResults));
544 },
545 Q_FUNC_INFO);
546 return std::make_shared<ActionResultImpl>(actionResult.first, actionResult.second);
547}
548
549/*!
550 \fn std::shared_ptr<ActionResult> QtOhosAppKit::FileShare::activatePermission(const QList<PathPolicy> &policies)
551
552 Activates file or folder permissions from \a policies.
553 The success of the action can be determined from ActionResult.
554
555 This function calls \l {https://developer.huawei.com/consumer/en/doc/harmonyos-references-V5/file_share-V5#oh_fileshare_activatepermission} {OH_FileShare_ActivatePermission}.
556 Each time an application is started, its persistent permissions have not been loaded to the memory. Use this function to make a persistent permission active after the application is started.
557 If the activation fails because the permission has not been persisted, use persistPermission() first.
558
559 To deactivate an active permission, use deactivatePermission().
560
561 \sa ActionResult, PathPolicy, persistPermission(), deactivatePermission()
562*/
563std::shared_ptr<ActionResult> activatePermission(const QList<PathPolicy> &policies)
564{
565 auto actionResult = QOhosJsThreadGateway::eval(
566 [&](QOhosJsState &) {
567 std::vector<std::shared_ptr<::FileShare_PolicyErrorResult>> outResults;
568 auto retCode = fileShareActivatePermission(
569 convertToFileSharePolicyInfos(policies), outResults);
570
571 return std::make_pair(isSuccessErrorCode(retCode), convertToPathPolicyErrorInfos(outResults));
572 },
573 Q_FUNC_INFO);
574 return std::make_shared<ActionResultImpl>(actionResult.first, actionResult.second);
575}
576
577/*!
578 \fn std::shared_ptr<ActionResult> QtOhosAppKit::FileShare::deactivatePermission(const QList<PathPolicy> &policies)
579
580 Deactivates file or folder permissions from \a policies.
581 The success of the action can be determined from ActionResult.
582
583 This function calls \l {https://developer.huawei.com/consumer/en/doc/harmonyos-references-V5/file_share-V5#oh_fileshare_deactivatepermission} {OH_FileShare_DeactivatePermission}.
584
585 To activate permission, use activatePermission().
586
587 \sa ActionResult, PathPolicy, activatePermission()
588*/
589std::shared_ptr<ActionResult> deactivatePermission(const QList<PathPolicy> &policies)
590{
591 auto actionResult = QOhosJsThreadGateway::eval(
592 [&](QOhosJsState &) {
593 std::vector<std::shared_ptr<::FileShare_PolicyErrorResult>> outResults;
594 auto retCode = fileShareDeactivatePermission(
595 convertToFileSharePolicyInfos(policies), outResults);
596
597 return std::make_pair(isSuccessErrorCode(retCode), convertToPathPolicyErrorInfos(outResults));
598 },
599 Q_FUNC_INFO);
600 return std::make_shared<ActionResultImpl>(actionResult.first, actionResult.second);
601}
602
603/*!
604 \fn std::shared_ptr<CheckResult> QtOhosAppKit::FileShare::checkPersistent(const QList<PathPolicy> &policies)
605
606 Checks if file or folder permissions from \a policies have persistent permissions.
607 The result check for each file or folder can be determined from CheckResult.
608 CheckResult::PathPolicyCheckResult::result will be set to \c true for each file or folder only for succesufull check and persistent permission found, \c false otherwise.
609
610 This function calls \l {https://developer.huawei.com/consumer/en/doc/harmonyos-references-V5/file_share-V5#oh_fileshare_checkpersistentpermission} {OH_FileShare_CheckPersistentPermission}.
611
612 To persist permission, use persistPermission().
613
614 \sa CheckResult, PathPolicy, persistPermission()
615*/
616std::shared_ptr<CheckResult> checkPersistent(const QList<PathPolicy> &policies)
617{
618 auto checkResult = QOhosJsThreadGateway::eval(
619 [&](QOhosJsState &) {
620 std::vector<bool> outResults;
621 auto retCode = fileShareCheckPersistentPermission(
622 convertToFileSharePolicyInfos(policies), outResults);
623
624 return std::make_pair(isSuccessErrorCode(retCode), outResults);
625 },
626 Q_FUNC_INFO);
627 return std::make_shared<CheckResultImpl>(checkResult.first, checkResult.second, policies);
628}
629
630}
631
632}
633
634QT_END_NAMESPACE
std::shared_ptr< ActionResult > activatePermission(const QList< PathPolicy > &policies)
Activates file or folder permissions from policies.
std::shared_ptr< ActionResult > deactivatePermission(const QList< PathPolicy > &policies)
Deactivates file or folder permissions from policies.
std::shared_ptr< ActionResult > persistPermission(const QList< PathPolicy > &policies)
Persists file or folder permissions from policies.
std::shared_ptr< CheckResult > checkPersistent(const QList< PathPolicy > &policies)
Checks if file or folder permissions from policies have persistent permissions.
std::shared_ptr< ActionResult > revokePermission(const QList< PathPolicy > &policies)
Revokes file or folder permissions from policies.