1 /*
2 * Copyright (c) 2025 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15 #include "ecmascript/ohos/js_pandafile_snapshot_interfaces.h"
16
17 #include "ecmascript/ohos/ohos_version_info_tools.h"
18 #include "ecmascript/jspandafile/js_pandafile_snapshot.h"
19 #include "ecmascript/platform/filesystem.h"
20
21 namespace panda::ecmascript::ohos {
22
Serialize(const EcmaVM * vm,const CString & path)23 void JSPandaFileSnapshotInterfaces::Serialize(const EcmaVM *vm, const CString &path)
24 {
25 LOG_ECMA(INFO) << "PandaFileSnapshotInterfaces::Serialize: " << path;
26 ECMA_BYTRACE_NAME(HITRACE_LEVEL_COMMERCIAL, HITRACE_TAG_ARK, "PandaFileSnapshotInterfaces::Serialize", "");
27 // check application white list
28 if (!filesystem::Exists(path.c_str())) {
29 LOG_ECMA(INFO) << "PandaFileSnapshotInterfaces::Serialize: " << path << " is not exists";
30 return;
31 }
32 CString version = OhosVersionInfoTools::GetRomVersion();
33 if (version.empty()) {
34 LOG_ECMA(ERROR) << "PandaFileSnapshotInterfaces::Serialize rom version is empty";
35 return;
36 }
37 JSPandaFileSnapshot::PostWriteDataToFileJob(vm, path, version);
38 }
39 } // namespace panda::ecmascript