开源鸿蒙6.1 bm安装应用失败

失败信息

# bm install -p nativeC++TestPrint.hap
error: failed to install bundle.
code:9568389
error: unknown.

追踪安装流程

错误调试信息

# bm install -p nativeC++TestPrint.hap
error: failed to install bundle.
code:9568389
error: unknown.
# hilog | grep "BMDEBUG"
01-01 08:02:19.577  2112  2112 I C01111/BMDEBUG: [BMDEBUG] bm exec start
01-01 08:02:19.579  2112  2112 I C01111/BMDEBUG: [BMDEBUG] begin to RunAsInstallCommand
01-01 08:02:19.579  2112  2112 I C01111/BMDEBUG: [BMDEBUG] option: 112, optopt: 0, optind: 3
01-01 08:02:19.579  2112  2112 I C01111/BMDEBUG: [BMDEBUG] 'bm install nativeC++TestPrint.hap'
01-01 08:02:19.579  2112  2112 I C01111/BMDEBUG: [BMDEBUG] option: -1, optopt: 0, optind: 3
01-01 08:02:19.579  2112  2112 I C01111/BMDEBUG: [BMDEBUG] install hap path nativeC++TestPrint.hap
01-01 08:02:19.579  2112  2112 I C01111/BMDEBUG: [BMDEBUG] install hap path nativeC++TestPrint.hap
01-01 08:02:19.579  2112  2112 I C01111/BMDEBUG: [BMDEBUG] InstallOperation start
01-01 08:02:19.579  2112  2112 I C01111/BMDEBUG: [BMDEBUG] stream install start
01-01 08:02:19.579   645  1848 I C01111/BMDEBUG: [BMDEBUG] BundleInstallerHost::CreateStreamInstaller start
01-01 08:02:19.580   645  1848 I C01111/BMDEBUG: [BMDEBUG] BundleStreamInstallerHostImpl::Init start
01-01 08:02:19.580   645  1848 I C01111/BMDEBUG: [BMDEBUG] BundleStreamInstallerHostImpl::Init end
01-01 08:02:19.580   645  1848 I C01111/BMDEBUG: [BMDEBUG] BundleInstallerHost::CreateStreamInstaller end
01-01 08:02:19.580  2112  2112 I C01111/BMDEBUG: [BMDEBUG] write file stream of hap path //nativeC++TestPrint.hap
01-01 08:02:19.580   645  1848 I C01111/BMDEBUG: [BMDEBUG] BundleStreamInstallerHostImpl::CreateStream start
01-01 08:02:19.580   645  1848 I C01111/BMDEBUG: [BMDEBUG] BundleStreamInstallerHostImpl::CreateStream end
01-01 08:02:19.580  2112  2112 I C01111/BMDEBUG: [BMDEBUG] write file stream to service terminal start
01-01 08:02:19.584  2112  2112 I C01111/BMDEBUG: [BMDEBUG] write file stream to service terminal end
01-01 08:02:19.584   645  1848 I C01111/BMDEBUG: [BMDEBUG] BundleStreamInstallerHostImpl::Install start
01-01 08:02:19.585   645  1848 I C01111/BMDEBUG: [a92ab6008b8ecf4, 0, 0] [BMDEBUG] BundleInstallerHost::Install start
01-01 08:02:19.585   645  1848 I C01111/BMDEBUG: [a92ab6008b8ecf4, 0, 0] [BMDEBUG] BundleInstallerHost::Install end
01-01 08:02:19.585   645  1848 I C01111/BMDEBUG: [a92ab6008b8ecf4, 0, 0] [BMDEBUG] BundleStreamInstallerHostImpl::Install end
01-01 08:02:19.585  2112  2112 I C01111/BMDEBUG: stream install end
01-01 08:02:19.585  2112  2112 I C01111/BMDEBUG: [BMDEBUG] StreamInstall result is 0
01-01 08:02:19.585   645  1918 I C01111/BMDEBUG: [a92ab6008b8ecf4, 0, 0] [BMDEBUG] BundleInstaller::Install start
01-01 08:02:19.585   645  1918 I C01111/BMDEBUG: [a92ab6008b8ecf4, 0, 0] [BMDEBUG] BaseBundleInstaller::InstallBundle start
01-01 08:02:19.585   645  1918 I C01111/BMDEBUG: [a92ab6008b8ecf4, 0, 0] [BMDEBUG] ProcessBundleInstall bundlePath install paths=["/data/service/el1/public/bms/bundle_manager_service/
stream_install/1392/"], hspPaths=[]
01-01 08:02:19.585   645  1918 I C01111/BMDEBUG: [a92ab6008b8ecf4, 0, 0] [BMDEBUG] CheckUserId return result : 0
01-01 08:02:19.585   645  1918 I C01111/BMDEBUG: [a92ab6008b8ecf4, 0, 0] [BMDEBUG] ParseHapPaths return result : 0
01-01 08:02:19.585   645  1918 I C01111/BMDEBUG: [a92ab6008b8ecf4, 0, 0] [BMDEBUG] BundleUtil::CheckFilePath return result : 0
01-01 08:02:19.585   645  1918 I C01111/BMDEBUG: [a92ab6008b8ecf4, 0, 0] 
01-01 08:02:19.589   645  1918 I C01111/BMDEBUG: [a92ab6008b8ecf4, 0, 0] [BMDEBUG] CopyHapsToSecurityDir return result : 0
01-01 08:02:19.633   645  1918 I C01111/BMDEBUG: [a92ab6008b8ecf4, 0, 0] [BMDEBUG] CheckMultipleHapsSignInfo return result : 0
01-01 08:02:19.633   645  1918 I C01111/BMDEBUG: [a92ab6008b8ecf4, 0, 0] [BMDEBUG] CheckShellInstall return result : 0
01-01 08:02:19.633   645  1918 I C01111/BMDEBUG: [a92ab6008b8ecf4, 0, 0] [BMDEBUG] CheckPreAppAllowHdcInstall return result : 0
01-01 08:02:19.635   645  1918 I C01111/BMDEBUG: [a92ab6008b8ecf4, 0, 0] 
01-01 08:02:19.635   645  1918 I C01111/BMDEBUG: [a92ab6008b8ecf4, 0, 0] [BMDEBUG] ParseHapFiles return result : 0
01-01 08:02:19.635   645  1918 I C01111/BMDEBUG: [a92ab6008b8ecf4, 0, 0] [BMDEBUG] CheckArkTSMode return result : 0
01-01 08:02:19.635   645  1918 I C01111/BMDEBUG: [a92ab6008b8ecf4, 0, 0] [BMDEBUG] check DataPreloadHap appIdentifier result : 0
01-01 08:02:19.635   645  1918 I C01111/BMDEBUG: [a92ab6008b8ecf4, 0, 0] [BMDEBUG] check install verifyActivation result : 0
01-01 08:02:19.635   645  1918 I C01111/BMDEBUG: [a92ab6008b8ecf4, 0, 0] [BMDEBUG] check shell can install pre app result : 0
01-01 08:02:19.635   645  1918 I C01111/BMDEBUG: [a92ab6008b8ecf4, 0, 0] [BMDEBUG] check install permission result : 0
01-01 08:02:19.635   645  1918 I C01111/BMDEBUG: [a92ab6008b8ecf4, 0, 0] [BMDEBUG] check install condition result : 0
01-01 08:02:19.635   645  1918 I C01111/BMDEBUG: [a92ab6008b8ecf4, 0, 0] [BMDEBUG] check dependency result : 0
01-01 08:02:19.635   645  1918 I C01111/BMDEBUG: [a92ab6008b8ecf4, 0, 0] [BMDEBUG] check debug scaner driver result : 0
01-01 08:02:19.635   645  1918 I C01111/BMDEBUG: [a92ab6008b8ecf4, 0, 0] [BMDEBUG] delivery profile result : 0
01-01 08:02:19.635   645  1918 I C01111/BMDEBUG: [a92ab6008b8ecf4, 0, 0] [BMDEBUG] userId check result : 0
01-01 08:02:19.635   645  1918 I C01111/BMDEBUG: [a92ab6008b8ecf4, 0, 0] [BMDEBUG] check hap hash param result : 0
01-01 08:02:19.635   645  1918 I C01111/BMDEBUG: [a92ab6008b8ecf4, 0, 0] [BMDEBUG] overlay hap check result : 0
01-01 08:02:19.639   645  1918 I C01111/BMDEBUG: [a92ab6008b8ecf4, 0, 0] [BMDEBUG] verisoncode or bundleName is different in all haps result : 0
01-01 08:02:19.639   645  1918 I C01111/BMDEBUG: [a92ab6008b8ecf4, 0, 0] [BMDEBUG] check space isolation result : 0
01-01 08:02:19.640   645  1918 I C01111/BMDEBUG: [a92ab6008b8ecf4, 0, 0] [BMDEBUG] bundle is already existed in bms extension result : 0
01-01 08:02:19.640   645  1918 I C01111/BMDEBUG: [a92ab6008b8ecf4, 0, 0] [BMDEBUG] native so is incompatible in all haps result : 0
01-01 08:02:19.640   645  1918 I C01111/BMDEBUG: [a92ab6008b8ecf4, 0, 0] [BMDEBUG] proxy data check result : 0
01-01 08:02:19.641   645  1918 I C01111/BMDEBUG: [a92ab6008b8ecf4, 0, 0] [BMDEBUG] install app control result : 0
01-01 08:02:19.641   645  1918 I C01111/BMDEBUG: [a92ab6008b8ecf4, 0, 0] [BMDEBUG] check app distribution type info result : 0
01-01 08:02:19.642   645  1918 I C01111/BMDEBUG: [a92ab6008b8ecf4, 0, 0] [BMDEBUG] ProcessBundleInstallStatus with bundleName com.example.nativec_test2 and packageName entry
01-01 08:02:19.645   645  1918 I C01111/BMDEBUG: [a92ab6008b8ecf4, 0, 0] 
01-01 08:02:19.651   645  1918 I C01111/BMDEBUG: [a92ab6008b8ecf4, 0, 0] 
01-01 08:02:19.652   645  1918 I C01111/BMDEBUG: [a92ab6008b8ecf4, 0, 0] 
01-01 08:02:19.652   645  1918 I C01111/BMDEBUG: [a92ab6008b8ecf4, 0, 0] 
01-01 08:02:19.652   645  1918 I C01111/BMDEBUG: [a92ab6008b8ecf4, 0, 0] 
01-01 08:02:19.652   645  1918 I C01111/BMDEBUG: [a92ab6008b8ecf4, 0, 0] 
01-01 08:02:19.652   645  1918 I C01111/BMDEBUG: [a92ab6008b8ecf4, 0, 0] [BMDEBUG] BaseBundleInstaller::ExtractModule start
01-01 08:02:19.652   645  1918 I C01111/BMDEBUG: [a92ab6008b8ecf4, 0, 0] 
01-01 08:02:19.658   645  1918 I C01111/BMDEBUG: [a92ab6008b8ecf4, 0, 0] 
01-01 08:02:19.659   645  1918 I C01111/BMDEBUG: [a92ab6008b8ecf4, 0, 0] 
01-01 08:02:19.659   645  1918 I C01111/BMDEBUG: [a92ab6008b8ecf4, 0, 0] 
01-01 08:02:19.659   645  1918 I C01111/BMDEBUG: [a92ab6008b8ecf4, 0, 0] 
01-01 08:02:19.659   645  1918 I C01111/BMDEBUG: [a92ab6008b8ecf4, 0, 0] [BMDEBUG] BaseBundleInstaller::ExtractModule end
01-01 08:02:19.660   645  1918 I C01111/BMDEBUG: [a92ab6008b8ecf4, 0, 0] [BMDEBUG] finish to call processBundleInstallStatus
01-01 08:02:19.660   645  1918 I C01111/BMDEBUG: [a92ab6008b8ecf4, 0, 0] [BMDEBUG] internal processing failed with result : 0
01-01 08:02:19.660   645  1918 I C01111/BMDEBUG: [a92ab6008b8ecf4, 0, 0] [BMDEBUG] VerifyArkWebInstall result : 0
01-01 08:02:19.660   645  1918 I C01111/BMDEBUG: [a92ab6008b8ecf4, 0, 0] [BMDEBUG] Save from /data/service/el1/public/bms/bundle_manager_service/security_stream_install/139585866000_2
/1392/nativeC++TestPrint.hap to /data/app/el1/bundle/public/com.example.nativec_test2/entry/entry.hap
01-01 08:02:19.660   645  1918 I C01111/BMDEBUG: [a92ab6008b8ecf4, 0, 0] [BMDEBUG] InstalldClient::MoveHapToCodeDir start
01-01 08:02:19.660   645  1918 I C01111/BMDEBUG: [a92ab6008b8ecf4, 0, 0] 
01-01 08:02:19.660   645  1918 E C01111/BMDEBUG: [a92ab6008b8ecf4, 0, 0] [BMDEBUG] Move hap to install path failed (ERR_APPEXECFWK_INSTALLD_MOVE_FILE_FAILED) result(8519902)
01-01 08:02:19.663   645  1918 I C01111/BMDEBUG: [a92ab6008b8ecf4, 0, 0] 
01-01 08:02:19.663   645  1918 I C01111/BMDEBUG: [a92ab6008b8ecf4, 0, 0] 
01-01 08:02:19.666   645  1918 I C01111/BMDEBUG: [a92ab6008b8ecf4, 0, 0] 
01-01 08:02:19.666   645  1918 I C01111/BMDEBUG: [a92ab6008b8ecf4, 0, 0] [BMDEBUG] ProcessBundleInstall return result(8519902)
01-01 08:02:19.666   645  1918 I C01111/BMDEBUG: [a92ab6008b8ecf4, 0, 0] [BMDEBUG] after CheckPreBundleRecoverResult(8519902)
01-01 08:02:19.667   645  1918 W C01111/BMDEBUG: [a92ab6008b8ecf4, 0, 0] [BMDEBUG] result(8519902) != ERR_OK, called RestoreHaps()
01-01 08:02:19.667   645  1918 I C01111/BMDEBUG: [a92ab6008b8ecf4, 0, 0] [BMDEBUG] InstallBundle finished -n com.example.nativec_test2 -u 100
01-01 08:02:19.667   645  1918 I C01111/BMDEBUG: [a92ab6008b8ecf4, 0, 0] [BMDEBUG] BaseBundleInstaller::InstallBundle end
01-01 08:02:19.667   645  1918 I C01111/BMDEBUG: [a92ab6008b8ecf4, 0, 0] [BMDEBUG] result 8519902, NULL
01-01 08:02:19.668  2112  2112 I C01111/BMDEBUG: [BMDEBUG] bundleInstallerProxy_->StreamInstall() return OK
01-01 08:02:19.668  2112  2112 I C01111/BMDEBUG: [BMDEBUG] statusReceiver->GetResultMsg() return [ERR_UNKNOWN]
01-01 08:02:19.668  2112  2112 I C01111/BMDEBUG: [BMDEBUG] statusReceiver->GetResultCode() is 9568389
01-01 08:02:19.668   645  1918 I C01111/BMDEBUG: [a92ab6008b8ecf4, 0, 0] [BMDEBUG] BundleInstaller::Install end
01-01 08:02:19.668  2112  2112 W C01111/BMDEBUG: [BMDEBUG] InstallOperation() return !OK(9568389)
01-01 08:02:19.668  2112  2112 I C01111/BMDEBUG: [BMDEBUG] end
  • 从调试信息中确定,第一次失败的位置在01-01 08:02:19.660 645 1918 E C01111/BMDEBUG: [a92ab6008b8ecf4, 0, 0] [BMDEBUG] Move hap to install path failed (ERR_APPEXECFWK_INSTALLD_MOVE_FILE_FAILED) result(8519902)

分析

  1. statusReceiver->GetResultCode()返回9568389
  • foundation/bundlemanager/bundle_tool/frameworks/src/main.cpp -> cmd.ExecCommand()
    • foundation/bundlemanager/bundle_tool/frameworks/src/shell_command.cpp -> OnCommand() -> respond()
      • foundation/bundlemanager/bundle_tool/frameworks/src/bundle_command.cpp -> RunAsInstallCommand() -> InstallOperation() 该函数返回值异常 -> StreamInstall()该函数返回ERR_OK,但是随后statusReceiver->GetResultCode()返回9568389
int32_t BundleManagerShellCommand::InstallOperation(const std::vector<std::string> &bundlePaths,
    InstallParam &installParam, int32_t waittingTime, std::string &resultMsg) const
{
  ...
  bundleInstallerProxy_->AsObject()->AddDeathRecipient(recipient);
    ErrCode res = bundleInstallerProxy_->StreamInstall(pathVec, installParam, statusReceiver);
    APP_LOGD("StreamInstall result is %{public}d", res);
#ifdef BMDEBUGPRINT
    HILOG_INFO(LOG_CORE, "[BMDEBUG] StreamInstall result is %{public}d", res);
#endif // BMDEBUGPRINT
    if (res == ERR_OK) {
        resultMsg = statusReceiver->GetResultMsg();
#ifdef BMDEBUGPRINT
        HILOG_INFO(LOG_CORE, "[BMDEBUG] bundleInstallerProxy_->StreamInstall() return OK");
        HILOG_INFO(LOG_CORE, "[BMDEBUG] statusReceiver->GetResultMsg() return %{public}s", resultMsg.c_str());
        int debug_ret = statusReceiver->GetResultCode();
        HILOG_INFO(LOG_CORE, "[BMDEBUG] statusReceiver->GetResultCode() is %{public}d", debug_ret);
        return debug_ret;
#else
        return statusReceiver->GetResultCode();
#endif // BMDEBUGPRINT
    }
  ...
}
  • foundation/bundlemanager/bundle_framework/interfaces/inner_api/appexecfwk_core/src/bundlemgr/bundle_installer_proxy.cpp-> StreamInstall()->streamInstaller->Install()
    • foundation/bundlemanager/bundle_framework/services/bundlemgr/src/bundle_stream_installer_host_impl.cpp->installer->Install
      • foundation/bundlemanager/bundle_framework/services/bundlemgr/src/bundle_installer_host.cpp->manager_->CreateInstallTask
        此时 StreamInstall() 返回 ERR_OK,bm 在 GetResultCode() 上等待
  • foundation/bundlemanager/bundle_framework/services/bundlemgr/src/bundle_installer.cpp -> InstallBundle
void BundleInstaller::Install(const std::vector<std::string> &bundleFilePaths, const InstallParam &installParam)
{
  ...
  ErrCode resultCode = ERR_OK;
    if (installParam.userId == Constants::ALL_USERID) {
        auto userInstallParam = installParam;
        userInstallParam.allUser = true;
        for (auto userId : GetExistsCommonUserIds()) {
            userInstallParam.userId = userId;
            userInstallParam.installFlag = InstallFlag::REPLACE_EXISTING;
            resultCode = InstallBundle(
                bundleFilePaths, userInstallParam, Constants::AppType::THIRD_PARTY_APP);
            ResetInstallProperties();
        }
        NotifyAllBundleStatus();
    } else {
        resultCode = InstallBundle(bundleFilePaths, installParam, Constants::AppType::THIRD_PARTY_APP);
        InstallForAllUsers(installParam);
    }
    std::string resultMsg = GetCheckResultMsg();
    SetCheckResultMsg("");
    if (statusReceiver_ != nullptr) {
        statusReceiver_->OnFinished(resultCode, resultMsg);
        // resultCode is 8519902(ERR_APPEXECFWK_INSTALLD_MOVE_FILE_FAILED)
    }
#ifdef BMDEBUGPRINT
    HILOG_INFO(LOG_CORE, "[BMDEBUG] BundleInstaller::Install end");
#endif // BMDEBUGPRINT
}
  • foundation/bundlemanager/bundle_framework/services/bundlemgr/src/base_bundle_installer.cpp->InstallBundle()->ProcessBundleInstall()->SaveHapToInstallPath()->InstalldClient::GetInstance()->MoveHapToCodeDir
ErrCode BaseBundleInstaller::ProcessBundleInstall(const std::vector<std::string> &inBundlePaths,
    const InstallParam &installParam, const Constants::AppType appType, int32_t &uid, bool isRecover)
{
  ...
  SaveHapPathToRecords(installParam.isPreInstallApp, newInfos);
    if (installParam.copyHapToInstallPath) {
        LOG_D(BMS_TAG_INSTALLER, "begin to copy hap to install path");
        result = SaveHapToInstallPath(newInfos, oldInfo); // return ERR_APPEXECFWK_INSTALLD_MOVE_FILE_FAILED
        CHECK_RESULT_WITH_ROLLBACK(result, "copy hap to install path failed %{public}d", newInfos, oldInfo);
#ifdef BMDEBUGPRINT
       HILOG_INFO(LOG_CORE, "[BMDEBUG] SaveHapToInstallPath result : %{public}d", result);
#endif // BMDEBUGPRINT
    } else {
        if ((result = CheckHapEncryption(newInfos, oldInfo, false)) != ERR_OK) {
            LOG_E(BMS_TAG_INSTALLER, "check encryption of pre-hap failed %{public}d", result);
#ifdef BMDEBUGPRINT
            HILOG_ERROR(LOG_CORE, "[BMDEBUG] check encryption of pre-hap failed %{public}d", result);
#endif // BMDEBUGPRINT
        }
    }
  ...
}
ErrCode BaseBundleInstaller::SaveHapToInstallPath(const std::unordered_map<std::string, InnerBundleInfo> &infos,
    const InnerBundleInfo &oldInfo)
{
  ...
  } else {
#ifdef BMDEBUGPRINT
            HILOG_INFO(LOG_CORE, "[BMDEBUG] Save from %{public}s to %{public}s",\
                hapPathRecord.first.c_str(), hapPathRecord.second.c_str());
#endif // BMDEBUGPRINT
            result = InstalldClient::GetInstance()->MoveHapToCodeDir(hapPathRecord.first, hapPathRecord.second);
            if (result == ERR_APPEXECFWK_INSTALL_FILE_PATH_INVALID) {
                LOG_W(BMS_TAG_INSTALLER, "rename hap failed, due to hap not existed");
                return result;
            }
            if (result != ERR_OK) { // bm install died here
                LOG_E(BMS_TAG_INSTALLER, "Move hap to install path failed");
#ifdef BMDEBUGPRINT
                HILOG_ERROR(LOG_CORE, \
                    "[BMDEBUG] Move hap to install path failed (ERR_APPEXECFWK_INSTALLD_MOVE_FILE_FAILED) result(%{public}d)",\
                     result);
#endif // BMDEBUGPRINT
                return ERR_APPEXECFWK_INSTALLD_MOVE_FILE_FAILED;
            }
    ...
  }
  • foundation/bundlemanager/bundle_framework/services/bundlemgr/src/installd_client.cpp->CallService->MoveHapToCodeDir()
    • foundation/bundlemanager/bundle_framework/services/bundlemgr/src/installd/installd_host_impl.cpp->InstalldOperator::MoveFile()
      • foundation/bundlemanager/bundle_framework/services/bundlemgr/src/installd/installd_operator.cpp->RenameFile()
bool InstalldOperator::RenameFile(const std::string &oldPath, const std::string &newPath)
{
    if (oldPath.empty() || newPath.empty()) {
        LOG_E(BMS_TAG_INSTALLD, "old path or new path is empty");
        return false;
    }
    if (oldPath == newPath) {
        LOG_W(BMS_TAG_INSTALLD, "old path %{public}s is same as new path", oldPath.c_str());
        return true;
    }
    if (!DeleteDir(newPath)) {
        return false;
    }
#ifdef BMDEBUGPRINT
    int debug_ret = rename(oldPath.c_str(), newPath.c_str());
    HILOG_INFO(LOG_CORE, "[BMDEBUG] rename return %{pubilc}d", debug_ret);
    if (debug_ret != 0) {
        if (errno == EXDEV || errno == ENOSYS) {
            if (CopyFileFast(oldPath, newPath) && OHOS::RemoveFile(oldPath)) {
                return true;
            }
        }
        return false;
    }
#else
    return rename(oldPath.c_str(), newPath.c_str()) == 0;
#endif // BMDEBUGPRINT
}

解决方法

在此处rename(oldPath.c_str(), newPath.c_str())返回非0值,最终导致失败,当前不清楚rename函数失败的具体原因是为何(errno=38调用的系统函数或功能在当前操作系统内核中不存在或未支持)
当前解决方法: 当rename失败时添加(CopyFileFast(oldPath, newPath) && OHOS::RemoveFile(oldPath)操作来达到rename操作等价的效果

bool InstalldOperator::RenameFile(const std::string &oldPath, const std::string &newPath)
{
    if (oldPath.empty() || newPath.empty()) {
        LOG_E(BMS_TAG_INSTALLD, "old path or new path is empty");
        return false;
    }
    if (oldPath == newPath) {
        LOG_W(BMS_TAG_INSTALLD, "old path %{public}s is same as new path", oldPath.c_str());
        return true;
    }
    if (!DeleteDir(newPath)) {
        return false;
    }
    if (rename(oldPath.c_str(), newPath.c_str()) != 0) {
        if (CopyFileFast(oldPath, newPath) && OHOS::RemoveFile(oldPath)) {
            return true;
        }
        return false;
    }

    return true;
}
Logo

openEuler 是由开放原子开源基金会孵化的全场景开源操作系统项目,面向数字基础设施四大核心场景(服务器、云计算、边缘计算、嵌入式),全面支持 ARM、x86、RISC-V、loongArch、PowerPC、SW-64 等多样性计算架构

更多推荐