diff --git a/FA/thirdparty/minizip_demo/AppScope/app.json5 b/FA/thirdparty/minizip_demo/AppScope/app.json5 new file mode 100755 index 0000000000000000000000000000000000000000..70940d4c00fdf3722b425ec9baad1a2b40d99276 --- /dev/null +++ b/FA/thirdparty/minizip_demo/AppScope/app.json5 @@ -0,0 +1,11 @@ +{ + "app": { + "bundleName": "com.example.minizip", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_icon", + "label": "$string:app_name", + "distributedNotificationEnabled": true + } +} diff --git a/FA/thirdparty/minizip_demo/AppScope/resources/base/element/string.json b/FA/thirdparty/minizip_demo/AppScope/resources/base/element/string.json new file mode 100755 index 0000000000000000000000000000000000000000..a194d36da6507ca565d740c9e7bfb4ea765ee1be --- /dev/null +++ b/FA/thirdparty/minizip_demo/AppScope/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "app_name", + "value": "minizip" + } + ] +} diff --git a/FA/thirdparty/minizip_demo/AppScope/resources/base/media/app_icon.png b/FA/thirdparty/minizip_demo/AppScope/resources/base/media/app_icon.png new file mode 100755 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/FA/thirdparty/minizip_demo/AppScope/resources/base/media/app_icon.png differ diff --git a/FA/thirdparty/minizip_demo/build-profile.json5 b/FA/thirdparty/minizip_demo/build-profile.json5 new file mode 100755 index 0000000000000000000000000000000000000000..64f1ae49cf09bb3bf37cb40efb83e4da24820cde --- /dev/null +++ b/FA/thirdparty/minizip_demo/build-profile.json5 @@ -0,0 +1,28 @@ +{ + "app": { + "signingConfigs": [ + ], + "compileSdkVersion": 9, + "compatibleSdkVersion": 9, + "products": [ + { + "name": "default", + "signingConfig": "default", + } + ] + }, + "modules": [ + { + "name": "entry", + "srcPath": "./entry", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/FA/thirdparty/minizip_demo/entry/build-profile.json5 b/FA/thirdparty/minizip_demo/entry/build-profile.json5 new file mode 100755 index 0000000000000000000000000000000000000000..ad3b00d3b723f9cda0feac66de28c38575f4bc35 --- /dev/null +++ b/FA/thirdparty/minizip_demo/entry/build-profile.json5 @@ -0,0 +1,21 @@ +{ + "apiType": 'stageMode', + "buildOption": { + "externalNativeOptions": { + "path": "./src/main/cpp/CMakeLists.txt", + "arguments": "-v", + "abiFilters": [ + "arm64-v8a" + ], + "cppFlags": "", + } + }, + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] +} \ No newline at end of file diff --git a/FA/thirdparty/minizip_demo/entry/hvigorfile.js b/FA/thirdparty/minizip_demo/entry/hvigorfile.js new file mode 100755 index 0000000000000000000000000000000000000000..d7720ee6a7aad5c617d1fd2f6fc8c87067bfa32c --- /dev/null +++ b/FA/thirdparty/minizip_demo/entry/hvigorfile.js @@ -0,0 +1,2 @@ +// Script for compiling build behavior. It is built in the build plug-in and cannot be modified currently. +module.exports = require('@ohos/hvigor-ohos-plugin').hapTasks diff --git a/FA/thirdparty/minizip_demo/entry/package-lock.json b/FA/thirdparty/minizip_demo/entry/package-lock.json new file mode 100755 index 0000000000000000000000000000000000000000..8fe0620a2347567342a28f4f60e98db8091dbae6 --- /dev/null +++ b/FA/thirdparty/minizip_demo/entry/package-lock.json @@ -0,0 +1,12 @@ +{ + "name": "entry", + "version": "1.0.0", + "lockfileVersion": 1, + "requires": true, + "dependencies": { + "@types/libentry.so": { + "version": "file:src/main/cpp/types/libentry", + "dev": true + } + } +} diff --git a/FA/thirdparty/minizip_demo/entry/package.json b/FA/thirdparty/minizip_demo/entry/package.json new file mode 100755 index 0000000000000000000000000000000000000000..55850f65d9824a848abfe33d8d28d78b025f16e5 --- /dev/null +++ b/FA/thirdparty/minizip_demo/entry/package.json @@ -0,0 +1,16 @@ +{ + "license": "ISC", + "devDependencies": { + "@types/libentry.so": "file:./src/main/cpp/types/libentry" + }, + "name": "entry", + "ohos": { + "org": "huawei", + "directoryLevel": "module", + "buildTool": "hvigor" + }, + "description": "example description", + "repository": {}, + "version": "1.0.0", + "dependencies": {} +} diff --git a/FA/thirdparty/minizip_demo/entry/src/main/cpp/CMakeLists.txt b/FA/thirdparty/minizip_demo/entry/src/main/cpp/CMakeLists.txt new file mode 100755 index 0000000000000000000000000000000000000000..bc5bfd19360fec50e90bed338fa0d5521219a4b2 --- /dev/null +++ b/FA/thirdparty/minizip_demo/entry/src/main/cpp/CMakeLists.txt @@ -0,0 +1,24 @@ + +# Copyright (c) 2022 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# the minimum version of CMake. +cmake_minimum_required(VERSION 3.4.1) +project(minizip) + +add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/minizip-ng) + +add_library(entry SHARED minizipNapi.cpp minizip.cpp) + +target_include_directories(entry PUBLIC thirdparty/minizip-ng/minizip-ng) +target_link_libraries(entry PUBLIC libace_napi.z.so minizip_shared) diff --git a/FA/thirdparty/minizip_demo/entry/src/main/cpp/hello.cpp b/FA/thirdparty/minizip_demo/entry/src/main/cpp/hello.cpp new file mode 100755 index 0000000000000000000000000000000000000000..474d42dcfef03bc7ee5d91a155245f13a1ddfee0 --- /dev/null +++ b/FA/thirdparty/minizip_demo/entry/src/main/cpp/hello.cpp @@ -0,0 +1,70 @@ + +/** +* Copyright (c) 2022 Huawei Device Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#include "napi/native_api.h" + +static napi_value Add(napi_env env, napi_callback_info info) +{ + size_t requireArgc = 2; + size_t argc = 2; + napi_value args[2] = {nullptr}; + + napi_get_cb_info(env, info, &argc, args , nullptr, nullptr); + + napi_valuetype valuetype0; + napi_typeof(env, args[0], &valuetype0); + + napi_valuetype valuetype1; + napi_typeof(env, args[1], &valuetype1); + + double value0; + napi_get_value_double(env, args[0], &value0); + + double value1; + napi_get_value_double(env, args[1], &value1); + + napi_value sum; + napi_create_double(env, value0 + value1, &sum); + + return sum; + +} + +EXTERN_C_START +static napi_value Init(napi_env env, napi_value exports) +{ + napi_property_descriptor desc[] = { + { "add", nullptr, Add, nullptr, nullptr, nullptr, napi_default, nullptr } + }; + napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); + return exports; +} +EXTERN_C_END + +static napi_module demoModule = { + .nm_version =1, + .nm_flags = 0, + .nm_filename = nullptr, + .nm_register_func = Init, + .nm_modname = "hello", + .nm_priv = ((void*)0), + .reserved = { 0 }, +}; + +extern "C" __attribute__((constructor)) void RegisterHelloModule(void) +{ + napi_module_register(&demoModule); +} diff --git a/FA/thirdparty/minizip_demo/entry/src/main/cpp/log.h b/FA/thirdparty/minizip_demo/entry/src/main/cpp/log.h new file mode 100755 index 0000000000000000000000000000000000000000..a75ae4c856e22b1c4087715be0d8da8a96661060 --- /dev/null +++ b/FA/thirdparty/minizip_demo/entry/src/main/cpp/log.h @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef __MINIZIP_LOG_H__ +#define __MINIZIP_LOG_H__ + +#include +#include +#include +#include + +#include "hilog/log.h" + +static const OHOS::HiviewDFX::HiLogLabel LOG_LABEL = { LOG_CORE, 0, "Minizip" }; + +#ifdef HILOGD +#undef HILOGD +#endif + +#ifdef HILOGF +#undef HILOGF +#endif + +#ifdef HILOGE +#undef HILOGE +#endif + +#ifdef HILOGW +#undef HILOGW +#endif + +#ifdef HILOGI +#undef HILOGI +#endif + + +#define HILOGD(fmt, ...) (void)OHOS::HiviewDFX::HiLog::Debug(LOG_LABEL, "%{public}s: " fmt, __func__, ##__VA_ARGS__) +#define HILOGI(fmt, ...) (void)OHOS::HiviewDFX::HiLog::Info(LOG_LABEL, "%{public}s: " fmt, __func__, ##__VA_ARGS__) +#define HILOGW(fmt, ...) (void)OHOS::HiviewDFX::HiLog::Warn(LOG_LABEL, "%{public}s: " fmt, __func__, ##__VA_ARGS__) +#define HILOGE(fmt, ...) (void)OHOS::HiviewDFX::HiLog::Error(LOG_LABEL, "%{public}s: " fmt, __func__, ##__VA_ARGS__) +#define HILOGF(fmt, ...) (void)OHOS::HiviewDFX::HiLog::Fatal(LOG_LABEL, "%{public}s: " fmt, __func__, ##__VA_ARGS__) + +#endif /* __MINIZIP_LOG_H__ */ diff --git a/FA/thirdparty/minizip_demo/entry/src/main/cpp/minizip.cpp b/FA/thirdparty/minizip_demo/entry/src/main/cpp/minizip.cpp new file mode 100755 index 0000000000000000000000000000000000000000..adfbafea1eaa449938569501ff891772d3818db4 --- /dev/null +++ b/FA/thirdparty/minizip_demo/entry/src/main/cpp/minizip.cpp @@ -0,0 +1,448 @@ +/** +* Copyright (c) 2022 Huawei Device Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +#include +#include + +#include + +#include "minizip.h" + +/***************************************************************************/ + +int32_t minizip_add_entry_cb(void *handle, void *userdata, mz_zip_file *file_info); +int32_t minizip_add_progress_cb(void *handle, void *userdata, mz_zip_file *file_info, int64_t position); +int32_t minizip_add_overwrite_cb(void *handle, void *userdata, const char *path); + +int32_t minizip_extract_entry_cb(void *handle, void *userdata, mz_zip_file *file_info, const char *path); +int32_t minizip_extract_progress_cb(void *handle, void *userdata, mz_zip_file *file_info, int64_t position); +int32_t minizip_extract_overwrite_cb(void *handle, void *userdata, mz_zip_file *file_info, const char *path); + +/***************************************************************************/ + +int32_t minizip_list(const char *path) { + mz_zip_file *file_info = NULL; + uint32_t ratio = 0; + int32_t err = MZ_OK; + struct tm tmu_date; + const char *method = NULL; + char crypt = ' '; + void *reader = NULL; + + + mz_zip_reader_create(&reader); + err = mz_zip_reader_open_file(reader, path); + if (err != MZ_OK) { + printf("Error %" PRId32 " opening archive %s\n", err, path); + mz_zip_reader_delete(&reader); + return err; + } + + err = mz_zip_reader_goto_first_entry(reader); + + if (err != MZ_OK && err != MZ_END_OF_LIST) { + printf("Error %" PRId32 " going to first entry in archive\n", err); + mz_zip_reader_delete(&reader); + return err; + } + + printf(" Packed Unpacked Ratio Method Attribs Date Time CRC-32 Name\n"); + printf(" ------ -------- ----- ------ ------- ---- ---- ------ ----\n"); + + /* Enumerate all entries in the archive */ + do { + err = mz_zip_reader_entry_get_info(reader, &file_info); + + if (err != MZ_OK) { + printf("Error %" PRId32 " getting entry info in archive\n", err); + break; + } + + ratio = 0; + if (file_info->uncompressed_size > 0) + ratio = (uint32_t)((file_info->compressed_size * 100) / file_info->uncompressed_size); + + /* Display a '*' if the file is encrypted */ + if (file_info->flag & MZ_ZIP_FLAG_ENCRYPTED) + crypt = '*'; + else + crypt = ' '; + + method = mz_zip_get_compression_method_string(file_info->compression_method); + mz_zip_time_t_to_tm(file_info->modified_date, &tmu_date); + + /* Print entry information */ + printf("%12" PRId64 " %12" PRId64 " %3" PRIu32 "%% %6s%c %8" PRIx32 " %2.2" PRIu32 \ + "-%2.2" PRIu32 "-%2.2" PRIu32 " %2.2" PRIu32 ":%2.2" PRIu32 " %8.8" PRIx32 " %s\n", + file_info->compressed_size, file_info->uncompressed_size, ratio, + method, crypt, file_info->external_fa, + (uint32_t)tmu_date.tm_mon + 1, (uint32_t)tmu_date.tm_mday, + (uint32_t)tmu_date.tm_year % 100, + (uint32_t)tmu_date.tm_hour, (uint32_t)tmu_date.tm_min, + file_info->crc, file_info->filename); + + err = mz_zip_reader_goto_next_entry(reader); + + if (err != MZ_OK && err != MZ_END_OF_LIST) { + printf("Error %" PRId32 " going to next entry in archive\n", err); + break; + } + } while (err == MZ_OK); + + mz_zip_reader_delete(&reader); + + if (err == MZ_END_OF_LIST) + return MZ_OK; + + return err; +} + +/***************************************************************************/ + +int32_t minizip_add_entry_cb(void *handle, void *userdata, mz_zip_file *file_info) { + MZ_UNUSED(handle); + MZ_UNUSED(userdata); + + /* Print the current file we are trying to compress */ + printf("Adding %s\n", file_info->filename); + return MZ_OK; +} + +int32_t minizip_add_progress_cb(void *handle, void *userdata, mz_zip_file *file_info, int64_t position) { + minizip_opt *options = (minizip_opt *)userdata; + double progress = 0; + uint8_t raw = 0; + + MZ_UNUSED(userdata); + + mz_zip_writer_get_raw(handle, &raw); + + if (raw && file_info->compressed_size > 0) + progress = ((double)position / file_info->compressed_size) * 100; + else if (!raw && file_info->uncompressed_size > 0) + progress = ((double)position / file_info->uncompressed_size) * 100; + + /* Print the progress of the current compress operation */ + if (options->verbose) + printf("%s - %" PRId64 " / %" PRId64 " (%.02f%%)\n", file_info->filename, position, + file_info->uncompressed_size, progress); + return MZ_OK; +} + +int32_t minizip_add_overwrite_cb(void *handle, void *userdata, const char *path) { + minizip_opt *options = (minizip_opt *)userdata; + + MZ_UNUSED(handle); + + if (options->overwrite == 0) { + /* If ask the user what to do because append and overwrite args not set */ + char rep = 0; + do { + char answer[128]; + printf("The file %s exists. Overwrite ? [y]es, [n]o, [a]ppend : ", path); + if (scanf("%1s", answer) != 1) + exit(EXIT_FAILURE); + rep = answer[0]; + + if ((rep >= 'a') && (rep <= 'z')) + rep -= 0x20; + } while ((rep != 'Y') && (rep != 'N') && (rep != 'A')); + + if (rep == 'A') { + return MZ_EXIST_ERROR; + } else if (rep == 'N') { + return MZ_INTERNAL_ERROR; + } + } + + return MZ_OK; +} + +int32_t minizip_add(const char *path, const char *password, minizip_opt *options, int32_t arg_count, const char **args) { + void *writer = NULL; + int32_t err = MZ_OK; + int32_t err_close = MZ_OK; + int32_t i = 0; + const char *filename_in_zip = NULL; + + // HILOGI("Archive %{public}s\n", path); + printf("Archive %s\n", path); + + /* Create zip writer */ + mz_zip_writer_create(&writer); + mz_zip_writer_set_password(writer, password); + mz_zip_writer_set_aes(writer, options->aes); + mz_zip_writer_set_compress_method(writer, options->compress_method); + mz_zip_writer_set_compress_level(writer, options->compress_level); + mz_zip_writer_set_follow_links(writer, options->follow_links); + mz_zip_writer_set_store_links(writer, options->store_links); + mz_zip_writer_set_overwrite_cb(writer, options, minizip_add_overwrite_cb); + mz_zip_writer_set_progress_cb(writer, options, minizip_add_progress_cb); + mz_zip_writer_set_entry_cb(writer, options, minizip_add_entry_cb); + mz_zip_writer_set_zip_cd(writer, options->zip_cd); +// HILOGI("cert_path : %{public}s", options->cert_path); + if (options->cert_path != NULL) + mz_zip_writer_set_certificate(writer, options->cert_path, options->cert_pwd); + err = mz_zip_writer_open_file(writer, path, options->disk_size, options->append); + + if (err == MZ_OK) { + for (i = 0; i < arg_count; i += 1) { + filename_in_zip = args[i]; + /* Add file system path to archive */ + err = mz_zip_writer_add_path(writer, filename_in_zip, NULL, options->include_path, 1); + if (err != MZ_OK) { + printf("Error %" PRId32 " adding path to archive %s\n", err, filename_in_zip); + // HILOGE("[%{public}d]Error %{public}" PRId32 " adding path to archive %{public}s, errcode:%{public}d(%{public}s)\n", __LINE__, err, filename_in_zip,errno, strerror(errno)); + } + } + } else { + printf("Error %" PRId32 " opening archive for writing\n", err); + // HILOGE("[%{public}d]Error %{public}" PRId32 " opening archive for writing[%{public}s]\n", __LINE__, err, strerror(errno)); + } + + err_close = mz_zip_writer_close(writer); + if (err_close != MZ_OK) { + printf("Error %" PRId32 " closing archive for writing %s\n", err_close, path); + // HILOGE("[%{public}d]Error %{public}" PRId32 " adding path to archive %{public}s\n", __LINE__, err_close, path); + err = err_close; + } + + mz_zip_writer_delete(&writer); + return err; +} + +/***************************************************************************/ + +int32_t minizip_extract_entry_cb(void *handle, void *userdata, mz_zip_file *file_info, const char *path) { + MZ_UNUSED(handle); + MZ_UNUSED(userdata); + MZ_UNUSED(path); + + /* Print the current entry extracting */ + printf("Extracting %s\n", file_info->filename); + return MZ_OK; +} + +int32_t minizip_extract_progress_cb(void *handle, void *userdata, mz_zip_file *file_info, int64_t position) { + minizip_opt *options = (minizip_opt *)userdata; + double progress = 0; + uint8_t raw = 0; + + MZ_UNUSED(userdata); + + mz_zip_reader_get_raw(handle, &raw); + + if (raw && file_info->compressed_size > 0) + progress = ((double)position / file_info->compressed_size) * 100; + else if (!raw && file_info->uncompressed_size > 0) + progress = ((double)position / file_info->uncompressed_size) * 100; + + /* Print the progress of the current extraction */ + if (options->verbose) + printf("%s - %" PRId64 " / %" PRId64 " (%.02f%%)\n", file_info->filename, position, + file_info->uncompressed_size, progress); + + return MZ_OK; +} + +int32_t minizip_extract_overwrite_cb(void *handle, void *userdata, mz_zip_file *file_info, const char *path) { + minizip_opt *options = (minizip_opt *)userdata; + + MZ_UNUSED(handle); + MZ_UNUSED(file_info); + + /* Verify if we want to overwrite current entry on disk */ + if (options->overwrite == 0) { + char rep = 0; + do { + char answer[128]; + printf("The file %s exists. Overwrite ? [y]es, [n]o, [A]ll: ", path); + if (scanf("%1s", answer) != 1) + exit(EXIT_FAILURE); + rep = answer[0]; + if ((rep >= 'a') && (rep <= 'z')) + rep -= 0x20; + } while ((rep != 'Y') && (rep != 'N') && (rep != 'A')); + + if (rep == 'N') + return MZ_EXIST_ERROR; + if (rep == 'A') + options->overwrite = 1; + } + + return MZ_OK; +} + +int32_t minizip_extract(const char *path, const char *pattern, const char *destination, const char *password, minizip_opt *options) { + void *reader = NULL; + int32_t err = MZ_OK; + int32_t err_close = MZ_OK; + + + printf("Archive %s\n", path); + // HILOGI("path:%{public}s, pattern:%{public}s, destination:%{public}s, password:%{public}s \n", path, pattern, destination, password); + /* Create zip reader */ + mz_zip_reader_create(&reader); + mz_zip_reader_set_pattern(reader, pattern, 1); + mz_zip_reader_set_password(reader, password); + mz_zip_reader_set_encoding(reader, options->encoding); + mz_zip_reader_set_entry_cb(reader, options, minizip_extract_entry_cb); + mz_zip_reader_set_progress_cb(reader, options, minizip_extract_progress_cb); + mz_zip_reader_set_overwrite_cb(reader, options, minizip_extract_overwrite_cb); + + err = mz_zip_reader_open_file(reader, path); + + if (err != MZ_OK) { + printf("Error %" PRId32 " opening archive %s\n", err, path); + // HILOGE("Error %{public}" PRId32 " opening archive %{public}s\n", err, path); + } else { + /* Save all entries in archive to destination directory */ + err = mz_zip_reader_save_all(reader, destination); + + if (err == MZ_END_OF_LIST) { + if (pattern != NULL) { + printf("Files matching %s not found in archive\n", pattern); + // HILOGE("Files matching %{public}s not found in archive\n", pattern); + } else { + printf("No files in archive\n"); + // HILOGE("No files in archive\n"); + err = MZ_OK; + } + } else if (err != MZ_OK) { + printf("Error %" PRId32 " saving entries to disk %s\n", err, path); + } + } + err_close = mz_zip_reader_close(reader); + if (err_close != MZ_OK) { + printf("Error %" PRId32 " closing archive for reading\n", err_close); + err = err_close; + } + + mz_zip_reader_delete(&reader); + return err; +} + +/***************************************************************************/ + +int32_t minizip_erase(const char *src_path, const char *target_path, int32_t arg_count, const char **args) { + mz_zip_file *file_info = NULL; + const char *filename_in_zip = NULL; + const char *target_path_ptr = target_path; + void *reader = NULL; + void *writer = NULL; + int32_t skip = 0; + int32_t err = MZ_OK; + int32_t i = 0; + uint8_t zip_cd = 0; + char bak_path[256]; + char tmp_path[256]; + + if (target_path == NULL) { + /* Construct temporary zip name */ + strncpy(tmp_path, src_path, sizeof(tmp_path) - 1); + tmp_path[sizeof(tmp_path) - 1] = 0; + strncat(tmp_path, ".tmp.zip", sizeof(tmp_path) - strlen(tmp_path) - 1); + target_path_ptr = tmp_path; + } + + mz_zip_reader_create(&reader); + mz_zip_writer_create(&writer); + + /* Open original archive we want to erase an entry in */ + err = mz_zip_reader_open_file(reader, src_path); + if (err != MZ_OK) { + printf("Error %" PRId32 " opening archive for reading %s\n", err, src_path); + mz_zip_reader_delete(&reader); + return err; + } + + /* Open temporary archive */ + err = mz_zip_writer_open_file(writer, target_path_ptr, 0, 0); + if (err != MZ_OK) { + printf("Error %" PRId32 " opening archive for writing %s\n", err, target_path_ptr); + mz_zip_reader_delete(&reader); + mz_zip_writer_delete(&writer); + return err; + } + + err = mz_zip_reader_goto_first_entry(reader); + + if (err != MZ_OK && err != MZ_END_OF_LIST) + printf("Error %" PRId32 " going to first entry in archive\n", err); + + while (err == MZ_OK) { + err = mz_zip_reader_entry_get_info(reader, &file_info); + if (err != MZ_OK) { + printf("Error %" PRId32 " getting info from archive\n", err); + break; + } + + /* Copy all entries from original archive to temporary archive + except the ones we don't want */ + for (i = 0, skip = 0; i < arg_count; i += 1) { + filename_in_zip = args[i]; + + if (mz_path_compare_wc(file_info->filename, filename_in_zip, 1) == MZ_OK) + skip = 1; + } + + if (skip) { + printf("Skipping %s\n", file_info->filename); + } else { + printf("Copying %s\n", file_info->filename); + err = mz_zip_writer_copy_from_reader(writer, reader); + } + + if (err != MZ_OK) { + printf("Error %" PRId32 " copying entry into new zip\n", err); + break; + } + + err = mz_zip_reader_goto_next_entry(reader); + + if (err != MZ_OK && err != MZ_END_OF_LIST) + printf("Error %" PRId32 " going to next entry in archive\n", err); + } + + mz_zip_reader_get_zip_cd(reader, &zip_cd); + mz_zip_writer_set_zip_cd(writer, zip_cd); + + mz_zip_reader_close(reader); + mz_zip_reader_delete(&reader); + + mz_zip_writer_close(writer); + mz_zip_writer_delete(&writer); + + if (err == MZ_END_OF_LIST) { + if (target_path == NULL) { + /* Swap original archive with temporary archive, backup old archive if possible */ + strncpy(bak_path, src_path, sizeof(bak_path) - 1); + bak_path[sizeof(bak_path) - 1] = 0; + strncat(bak_path, ".bak", sizeof(bak_path) - strlen(bak_path) - 1); + + if (mz_os_file_exists(bak_path) == MZ_OK) + mz_os_unlink(bak_path); + + if (mz_os_rename(src_path, bak_path) != MZ_OK) + printf("Error backing up archive before replacing %s\n", bak_path); + + if (mz_os_rename(tmp_path, src_path) != MZ_OK) + printf("Error replacing archive with temp %s\n", tmp_path); + } + + return MZ_OK; + } + + return err; +} diff --git a/FA/thirdparty/minizip_demo/entry/src/main/cpp/minizip.h b/FA/thirdparty/minizip_demo/entry/src/main/cpp/minizip.h new file mode 100755 index 0000000000000000000000000000000000000000..d3931af68740b3a260ea1965baa9452247542d0b --- /dev/null +++ b/FA/thirdparty/minizip_demo/entry/src/main/cpp/minizip.h @@ -0,0 +1,60 @@ +/** +* Copyright (c) 2022 Huawei Device Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#ifndef minizip_minizip_H +#define minizip_minizip_H + +#include "mz.h" +#include "mz_os.h" +#include "mz_strm.h" +#include "mz_strm_buf.h" +#include "mz_strm_split.h" +#include "mz_zip.h" +#include "mz_zip_rw.h" + +#ifdef __cplusplus +extern "C" { +#endif +typedef struct minizip_opt_s { + uint8_t include_path; + int16_t compress_level; + uint8_t compress_method; + uint8_t overwrite; + uint8_t append; + int64_t disk_size; + uint8_t follow_links; + uint8_t store_links; + uint8_t zip_cd; + int32_t encoding; + uint8_t verbose; + uint8_t aes; + const char *cert_path; + const char *cert_pwd; +} minizip_opt; + + +int32_t minizip_add(const char *path, const char *password, minizip_opt *options, int32_t arg_count, const char **args); + +int32_t minizip_extract(const char *path, const char *pattern, const char *destination, const char *password, minizip_opt *options); + +int32_t minizip_erase(const char *src_path, const char *target_path, int32_t arg_count, const char **args); + +int32_t minizip_list(const char *path); + +#ifdef __cplusplus +} +#endif + +#endif //minizip_minizip_H diff --git a/FA/thirdparty/minizip_demo/entry/src/main/cpp/minizipNapi.cpp b/FA/thirdparty/minizip_demo/entry/src/main/cpp/minizipNapi.cpp new file mode 100755 index 0000000000000000000000000000000000000000..fd9db69ce912b87995f97fbc9fd3a0749707be94 --- /dev/null +++ b/FA/thirdparty/minizip_demo/entry/src/main/cpp/minizipNapi.cpp @@ -0,0 +1,450 @@ +/** +* Copyright (c) 2022 Huawei Device Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +#include +#include +#include +#include +#include +#include +#include +#include + +#include "minizipNapi.h" +#include "minizip.h" + +using namespace std; + +enum { + SHOW_LIST = 0, + DECOMPRESS, + ERASE, + COMPRESS, +}; + +typedef enum { + OBJECT = 0, + NUMBER, + STRING, + ARRAY, + +} ValueType; + +napi_ref minizipNapi::sConstructor_ = nullptr; + +static int minizip_getObjectPropetry(napi_env env, napi_value object, string key, int keyType, void *retValue) { + napi_value property = nullptr; + napi_value result = nullptr; + bool flag = false; + int ret = -1; + + if (napi_create_string_utf8(env, key.c_str(), strlen(key.c_str()), &property) != napi_ok) { + return ret; + } + + if (napi_has_property(env, object, property, &flag) != napi_ok) { + return ret; + } + + if (napi_get_property(env, object, property, &result) != napi_ok) { + return ret; + } + + if (keyType == NUMBER) { + int64_t value = 0; + if (napi_get_value_int64(env, result, &value) != napi_ok) { + return ret; + } + *(int *)retValue = value; + ret = 0; + } else if (keyType == STRING) { + size_t s = 0; + char buf[256] = {0}; + if (napi_get_value_string_utf8(env, result, buf, sizeof(buf), &s) != napi_ok) { + return ret; + } + strncpy((char *)retValue, buf, strlen(buf)); + ret = 0; + } + + return ret; +} + +int minizip_parser_params(napi_env env, napi_value object) +{ + int32_t err = MZ_OK; + int cmd = COMPRESS; + char path[256] = {0}; + char password[64] = {0}; + char destination[256] = {0}; + char file_extract[256] = {0}; + char optBuf[256] = {0}; + + minizip_opt opt; + memset(&opt, 0x00, sizeof(minizip_opt)); + + uint32_t argc = 0; + char *argv[128]; + + if (minizip_getObjectPropetry(env, object, "path", STRING, (void *)path) < 0) { + return -1; + } + + minizip_getObjectPropetry(env, object, "password", STRING, (void *)password); + if (minizip_getObjectPropetry(env, object, "operate", STRING, (void *)optBuf) < 0) { + return -1; + } + if (strcmp(optBuf, "decompress") == 0) { + cmd = DECOMPRESS; + } else if (strcmp(optBuf, "erase") == 0) { + cmd = ERASE; + } else if (strcmp(optBuf, "list") == 0) { + cmd = SHOW_LIST; + } + + minizip_getObjectPropetry(env, object, "file_extract", STRING, (void *)file_extract); + minizip_getObjectPropetry(env, object, "directory", STRING, (void *)destination); + + // for options + napi_value option = nullptr; + if (napi_get_named_property(env, object, "option", &option) != napi_ok) { + return -1; + } + minizip_getObjectPropetry(env, option, "include_path", NUMBER, (void *)&opt.include_path); + minizip_getObjectPropetry(env, option, "compress_level", NUMBER, (void *)&opt.compress_level); + minizip_getObjectPropetry(env, option, "compress_method", NUMBER, (void *)&opt.compress_method); + minizip_getObjectPropetry(env, option, "overwrite", NUMBER, (void *)&opt.overwrite); + minizip_getObjectPropetry(env, option, "append", NUMBER, (void *)&opt.append); + minizip_getObjectPropetry(env, option, "disk_size", NUMBER, (void *)&opt.disk_size); + minizip_getObjectPropetry(env, option, "follow_links", NUMBER, (void *)&opt.follow_links); + minizip_getObjectPropetry(env, option, "store_links", NUMBER, (void *)&opt.store_links); + minizip_getObjectPropetry(env, option, "zip_cd", NUMBER, (void *)&opt.zip_cd); + minizip_getObjectPropetry(env, option, "encoding", NUMBER, (void *)&opt.encoding); + minizip_getObjectPropetry(env, option, "verbose", NUMBER, (void *)&opt.verbose); + minizip_getObjectPropetry(env, option, "aes", NUMBER, (void *)&opt.aes); + char cert_path[256] = {0}; + if (minizip_getObjectPropetry(env, option, "cert_path", STRING, (void *)cert_path) == 0) { + opt.cert_path = (const char *)cert_path; + } + char cert_pwd[256] = {0}; + if (minizip_getObjectPropetry(env, option, "cert_pwd", NUMBER, (void *)cert_pwd) == 0) { + opt.cert_pwd = (const char *)cert_pwd; + } + + // file arrays + napi_value files = nullptr; + if (napi_get_named_property(env, object, "files", &files) == napi_ok) { + bool flag = false; + if (napi_is_array(env, files, &flag) == napi_ok && flag == true) { + napi_get_array_length(env, files, &argc); + int pos = 0; + // HILOGI("argc = %{public}d", argc); + for (int i = 0; i < argc; i++) { + napi_value file = nullptr; + char *buf = (char *)malloc(512); + size_t s = 0; + if (napi_get_element(env, files, i, &file) != napi_ok) { + pos++; + free(buf); + continue; + } + if (napi_get_value_string_utf8(env, file, buf, 512, &s) != napi_ok) { + free(buf); + pos++; + } else { + argv[i-pos] = buf; + } + } + + argc -= pos; + argv[argc] = nullptr; + + // HILOGI("argc = %{public}d", argc); + } else { + // HILOGE("files napi_is_array failed!!"); + } + } else { + // HILOGE("napi_get_named_property files failed!!"); + } + + // HILOGI("operate = %{public}s", cmd == SHOW_LIST ? "show list" : (cmd == DECOMPRESS ? "decompress" : (cmd == ERASE ? "erase" : "compress"))); + // HILOGI("path : %{public}s, file_extract : %{public}s, destination : %{public}s, password : %{public}s", path, file_extract, destination, password); + // HILOGI("argc = %{public}d", argc); + for (int i = 0; i < argc; i++) { + // HILOGI("file[%{public}d] : %{public}s", i, argv[i]); + } + + if (cmd == SHOW_LIST) { + err = minizip_list((const char *)path); + } else if (cmd == DECOMPRESS) { + err = minizip_extract((const char *)path, + strlen(file_extract) > 0 ? (const char *)file_extract : nullptr, + strlen(destination) > 0 ? (const char *)destination : nullptr, + strlen(password) > 0 ? (const char *)password : nullptr, &opt); + } else if (cmd == ERASE) { + err = minizip_erase((const char *)path, nullptr, argc, (const char **)argv); + } else if (cmd == COMPRESS) { + err = minizip_add((const char *)path, + strlen(password) > 0 ? (const char *)password : nullptr, &opt, argc, (const char **)argv); + } + + // HILOGI("err=%{public}d", err); + + for (int i = 0; i < argc; i++) { + if (argv[i] != nullptr) { + free(argv[i]); + } + } + + return err; +} + +napi_value minizipNapi::Compress(napi_env env, napi_callback_info info) +{ + // HILOGI("[Minizip] ############ Compress #############"); + napi_value result = nullptr; + napi_get_undefined(env, &result); + napi_value value; + size_t argc = 1; + + if (napi_get_cb_info(env, info, &argc, &value, nullptr, nullptr) != napi_ok) { + return result; + } + + if (minizip_parser_params(env, value) < 0) { + return result; + } + + if (napi_create_int64(env, 0, &result) != napi_ok) { + std::cout << "napi_create_int64" << std::endl; + } + + return result; +} + +napi_value minizipNapi::Decompress(napi_env env, napi_callback_info info) +{ + // HILOGI("[Minizip] ############ Decompress #############"); + napi_value result = nullptr; + napi_get_undefined(env, &result); + napi_value value; + size_t argc = 1; + + if (napi_get_cb_info(env, info, &argc, &value, nullptr, nullptr) != napi_ok) { + return result; + } + + if (minizip_parser_params(env, value) < 0) { + return result; + } + + if (napi_create_int64(env, 0, &result) != napi_ok) { + std::cout << "napi_create_int64" << std::endl; + } + + return result; +} + +napi_value minizipNapi::CompressWithPsd(napi_env env, napi_callback_info info) +{ + napi_value result = nullptr; + napi_get_undefined(env, &result); + napi_value value; + size_t argc = 1; + + if (napi_get_cb_info(env, info, &argc, &value, nullptr, nullptr) != napi_ok) { + return result; + } + + if (minizip_parser_params(env, value) < 0) { + return result; + } + + if (napi_create_int64(env, 0, &result) != napi_ok) { + std::cout << "napi_create_int64" << std::endl; + } + + return result; +} + +napi_value minizipNapi::DecompressWithPsd(napi_env env, napi_callback_info info) +{ + napi_value result = nullptr; + napi_get_undefined(env, &result); + napi_value value; + size_t argc = 1; + + if (napi_get_cb_info(env, info, &argc, &value, nullptr, nullptr) != napi_ok) { + return result; + } + + if (minizip_parser_params(env, value) < 0) { + return result; + } + + if (napi_create_int64(env, 0, &result) != napi_ok) { + std::cout << "napi_create_int64" << std::endl; + } + + return result; +} + +napi_value minizipNapi::CompressWithEncryption(napi_env env, napi_callback_info info) +{ + napi_value result = nullptr; + napi_get_undefined(env, &result); + napi_value value; + size_t argc = 1; + + if (napi_get_cb_info(env, info, &argc, &value, nullptr, nullptr) != napi_ok) { + return result; + } + + if (minizip_parser_params(env, value) < 0) { + return result; + } + + if (napi_create_int64(env, 0, &result) != napi_ok) { + std::cout << "napi_create_int64" << std::endl; + } + + return result; +} + +napi_value minizipNapi::DecompressWithEncryption(napi_env env, napi_callback_info info) +{ + napi_value result = nullptr; + napi_get_undefined(env, &result); + napi_value value; + size_t argc = 1; + + if (napi_get_cb_info(env, info, &argc, &value, nullptr, nullptr) != napi_ok) { + return result; + } + + if (minizip_parser_params(env, value) < 0) { + return result; + } + + if (napi_create_int64(env, 0, &result) != napi_ok) { + std::cout << "napi_create_int64" << std::endl; + } + + return result; +} + +napi_value minizipNapi::Create(napi_env env, napi_callback_info info) { + napi_status status; + napi_value constructor = nullptr, result = nullptr; + + status = napi_get_reference_value(env, sConstructor_, &constructor); + if (status != napi_ok) { + return result; + } + + status = napi_new_instance(env, constructor, 0, nullptr, &result); + if (status != napi_ok) { + return result; + } + + auto mini = new minizipNapi(); + if (napi_wrap(env, result, reinterpret_cast(mini), Destructor, nullptr, &(mini->mRef)) == napi_ok) { + return result; + } + + return nullptr; +} + +napi_value minizipNapi::Constructor(napi_env env, napi_callback_info info) +{ + napi_value undefineVar = nullptr, thisVar = nullptr; + napi_get_undefined(env, &undefineVar); + + if (napi_get_cb_info(env, info, nullptr, nullptr, &thisVar, nullptr) == napi_ok && thisVar != nullptr) { + minizipNapi *reference = new minizipNapi(); + if (napi_wrap(env, thisVar, reinterpret_cast(reference), minizipNapi::Destructor, nullptr, + &(reference->mRef)) == napi_ok) { + return thisVar; + } + + return thisVar; + } + + return undefineVar; +} + +void minizipNapi::Destructor(napi_env env, void *nativeObject, void *finalize) +{ + minizipNapi *mini = reinterpret_cast(nativeObject); + mini->~minizipNapi(); +} + +napi_value minizipNapi::Init(napi_env env, napi_value exports) +{ + napi_property_descriptor desc[] = { + { "compress", nullptr, minizipNapi::Compress, nullptr, nullptr, nullptr, napi_default, nullptr }, + { "decompress", nullptr, minizipNapi::Decompress, nullptr, nullptr, nullptr, napi_default, nullptr }, + { "compressWithPsd", nullptr, minizipNapi::CompressWithPsd, nullptr, nullptr, nullptr, napi_default, nullptr }, + { "decompressWithPsd", nullptr, minizipNapi::DecompressWithPsd, nullptr, nullptr, nullptr, napi_default, nullptr }, + { "compressWithEncryption", nullptr, minizipNapi::CompressWithEncryption, nullptr, nullptr, nullptr, napi_default, nullptr }, + { "decompressWithEncryption", nullptr, minizipNapi::DecompressWithEncryption, nullptr, nullptr, nullptr, napi_default, nullptr } + }; + + napi_value constructor = nullptr; + + if (napi_define_class(env, NAPI_CLASS_NAME, NAPI_AUTO_LENGTH, minizipNapi::Constructor, nullptr, sizeof(desc) / sizeof(desc[0]), + desc, &constructor) != napi_ok) { + return nullptr; + } + + if (napi_create_reference(env, constructor, 1, &sConstructor_) != napi_ok) { + return nullptr; + } + + if (napi_set_named_property(env, exports, NAPI_CLASS_NAME, constructor) != napi_ok) { + return nullptr; + } + + return exports; +} + +EXTERN_C_START +static napi_value Init(napi_env env, napi_value exports) +{ + // HILOGI("[Minizip] ############ start minizip NAPI #############"); + + napi_property_descriptor desc[] = { + { "create", nullptr, minizipNapi::Create, nullptr, nullptr, nullptr, napi_default, nullptr } + }; + + napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); + + return minizipNapi::Init(env, exports); +} +EXTERN_C_END + +static napi_module demoModule = { + .nm_version =1, + .nm_flags = 0, + .nm_filename = nullptr, + .nm_register_func = Init, + .nm_modname = "minizipNapi", + .nm_priv = ((void*)0), + .reserved = { 0 }, +}; + +extern "C" __attribute__((constructor)) void RegisterHelloModule(void) +{ + napi_module_register(&demoModule); +} diff --git a/FA/thirdparty/minizip_demo/entry/src/main/cpp/minizipNapi.h b/FA/thirdparty/minizip_demo/entry/src/main/cpp/minizipNapi.h new file mode 100755 index 0000000000000000000000000000000000000000..b223d4db6e576dfa74bc71362298f01c530c9cac --- /dev/null +++ b/FA/thirdparty/minizip_demo/entry/src/main/cpp/minizipNapi.h @@ -0,0 +1,59 @@ +/** +* Copyright (c) 2022 Huawei Device Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#ifndef __minizip_minizipNapi_H__ +#define __minizip_minizipNapi_H__ + +#include "napi/native_api.h" + +#include "mz.h" +#include "mz_os.h" +#include "mz_strm.h" +#include "mz_strm_buf.h" +#include "mz_strm_split.h" +#include "mz_zip.h" +#include "mz_zip_rw.h" +#include +#include + +#define NAPI_CLASS_NAME "minizipNapiClass" + +class minizipNapi { +public: + minizipNapi(){} + ~minizipNapi(){} + + static napi_value Create(napi_env env, napi_callback_info info); + static napi_value Init(napi_env env, napi_value exports); + +private: + static napi_value Compress(napi_env env, napi_callback_info info); + static napi_value Decompress(napi_env env, napi_callback_info info); + static napi_value CompressWithPsd(napi_env env, napi_callback_info info); + static napi_value DecompressWithPsd(napi_env env, napi_callback_info info); + static napi_value CompressWithEncryption(napi_env env, napi_callback_info info); + static napi_value DecompressWithEncryption(napi_env env, napi_callback_info info); + + static napi_value Constructor(napi_env env, napi_callback_info info); + static void Destructor(napi_env env, void *nativeObject, void *finalize); + + static napi_ref sConstructor_; + + + napi_env mEnv = nullptr; + napi_ref mRef = nullptr; +}; + +#endif //__minizip_minizipNapi_H__ diff --git a/FA/thirdparty/minizip_demo/entry/src/main/cpp/types/libentry/index.d.ts b/FA/thirdparty/minizip_demo/entry/src/main/cpp/types/libentry/index.d.ts new file mode 100755 index 0000000000000000000000000000000000000000..bc2ae49111a29c03e83e05815c31e606436e00e4 --- /dev/null +++ b/FA/thirdparty/minizip_demo/entry/src/main/cpp/types/libentry/index.d.ts @@ -0,0 +1,11 @@ +export const create : () => minizipNapi; + +export class minizipNapi { + compress(data:object):number; + decompress(data:object):number; + compressWithPsd(data:object):number; + decompressWithPsd(data:object):number; + compressWithEncryption(data:object):number; + decompressWithEncryption(data:object):number; +} + diff --git a/FA/thirdparty/minizip_demo/entry/src/main/cpp/types/libentry/package.json b/FA/thirdparty/minizip_demo/entry/src/main/cpp/types/libentry/package.json new file mode 100755 index 0000000000000000000000000000000000000000..395f926a91a01f86098fe39603b1a42d2e1533a8 --- /dev/null +++ b/FA/thirdparty/minizip_demo/entry/src/main/cpp/types/libentry/package.json @@ -0,0 +1,4 @@ +{ + "name": "libentry.so", + "types": "./index.d.ts" +} \ No newline at end of file diff --git a/FA/thirdparty/minizip_demo/entry/src/main/ets/Application/MyAbilityStage.ts b/FA/thirdparty/minizip_demo/entry/src/main/ets/Application/MyAbilityStage.ts new file mode 100755 index 0000000000000000000000000000000000000000..c48a82a0be8f7c7ade8059b5010e612c618b9826 --- /dev/null +++ b/FA/thirdparty/minizip_demo/entry/src/main/ets/Application/MyAbilityStage.ts @@ -0,0 +1,22 @@ +/** +* Copyright (c) 2022 Huawei Device Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +import AbilityStage from "@ohos.application.AbilityStage" + +export default class MyAbilityStage extends AbilityStage { + onCreate() { + console.log("[Demo] MyAbilityStage onCreate") + } +} \ No newline at end of file diff --git a/FA/thirdparty/minizip_demo/entry/src/main/ets/MainAbility/MainAbility.ts b/FA/thirdparty/minizip_demo/entry/src/main/ets/MainAbility/MainAbility.ts new file mode 100755 index 0000000000000000000000000000000000000000..a94312206748f06fe5f9bdcce839f58b7f255ac6 --- /dev/null +++ b/FA/thirdparty/minizip_demo/entry/src/main/ets/MainAbility/MainAbility.ts @@ -0,0 +1,62 @@ +/** +* Copyright (c) 2022 Huawei Device Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +import Ability from '@ohos.application.Ability' + +const PERMISSIONS: Array = [ + 'ohos.permission.READ_MEDIA', + 'ohos.permission.WRITE_MEDIA', + 'ohos.permission.MEDIA_LOCATION'] + +export default class MainAbility extends Ability { + onCreate(want, launchParam) { + console.log("[Demo] MainAbility onCreate") + globalThis.abilityWant = want; + globalThis.abilityContext = this.context +// globalThis.abilityContext.requestPermissionsFromUser(PERMISSIONS) + } + + onDestroy() { + console.log("[Demo] MainAbility onDestroy") + } + + onWindowStageCreate(windowStage) { + // Main window is created, set main page for this ability + console.log("[Demo] MainAbility onWindowStageCreate") + + windowStage.loadContent("pages/index", (err, data) => { + if (err.code) { + console.error('Failed to load the content. Cause:' + JSON.stringify(err)); + return; + } + console.info('Succeeded in loading the content. Data: ' + JSON.stringify(data)) + }); + } + + onWindowStageDestroy() { + // Main window is destroyed, release UI related resources + console.log("[Demo] MainAbility onWindowStageDestroy") + } + + onForeground() { + // Ability has brought to foreground + console.log("[Demo] MainAbility onForeground") + } + + onBackground() { + // Ability has back to background + console.log("[Demo] MainAbility onBackground") + } +}; diff --git a/FA/thirdparty/minizip_demo/entry/src/main/ets/pages/index.ets b/FA/thirdparty/minizip_demo/entry/src/main/ets/pages/index.ets new file mode 100755 index 0000000000000000000000000000000000000000..06e619a838f8af149672a2f160838274f9915ab4 --- /dev/null +++ b/FA/thirdparty/minizip_demo/entry/src/main/ets/pages/index.ets @@ -0,0 +1,243 @@ +/** +* Copyright (c) 2022 Huawei Device Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +import minizip from "libentry.so" +import fileio from '@ohos.fileio'; + +interface miniOptions { + include_path?:number + compress_level?:number + compress_method?:number + overwrite?:number + append?:number + disk_size?:number + follow_links?:number + store_links?:number + zip_cd?:number + encoding?:number + verbose?:number + aes?:number + cert_path?:string + cert_pwd?:string +} + +interface miniProperty { + path:string + password?:string + operate?:string + file_extract?:string + option:miniOptions + directory?:string + files?:Array +} + +@Entry +@Component +struct Index { + @State button0Txt: string = 'compress' + @State button1Txt: string = 'compressPSK' + @State button2Txt: string = 'compressEpty' + @State button3Txt: string = 'CreateFiles' + + button0:number = 0; + button1:number = 0; + button2:number = 0; + + dir:string = ""; + + compressData:miniProperty = {path:"result.zip", operate:"compress", option:{append:1, + compress_level:9}, files:["file1","file2","file3"]} + decompressData:miniProperty = {path:"result.zip", operate:"decompress", option:{overwrite:1, + compress_level:9}, directory:"out"} + compressPwd:miniProperty = {path:"result.zip", password:"test", operate:"compress", option:{overwrite:1, + compress_level:9, include_path:1}, files:["file1","file2","file3"]} + decompressPwd:miniProperty = {path:"result.zip", password:"test", operate:"decompress", option:{overwrite:1, + compress_level:9}, directory:"out"} + compressEncrypt:miniProperty = {path:"result.zip", password:"test", operate:"compress", option:{overwrite:1, + compress_level:9, include_path:1, aes:1, cert_path:"test.p12", cert_pwd:"test"}, files:["file1","file2","file3"]} + decompressEncrypt:miniProperty = {path:"result.zip", password:"test", operate:"decompress", option:{overwrite:1, + compress_level:9, include_path:1, aes:1, cert_path:"test.p12", cert_pwd:"test"}, directory:"out"} + + mzip = minizip.create(); + + build() { + Column() { + Button(this.button0Txt) + .fontSize(50) + .margin({top:30}) + .fontWeight(FontWeight.Normal) + .onClick(() => { + + if (this.button0 == 0) { + this.button0 = 1; + this.button0Txt = "decompress" + if (this.mzip != undefined) { + console.info("[Minizip]start compress!"); + try { + let result = this.mzip.compress({ path: this.dir + "result.zip", operate: "compress", + option: { append: 1, compress_level: 9 }, + files: [this.dir + "file1.txt"] }) + if (result == undefined) { + this.button0 = 0; + this.button0Txt = "compressEpty" + } + console.info("[Minizip]compress result = " + JSON.stringify(result)); + }catch(e) { + console.info("[Minizip] error : " + JSON.stringify(e)); + } + }else { + console.info("[Minizip] mzip is undefined!"); + } + } else { + this.button0 = 0; + this.button0Txt = "compress" + if (this.mzip != undefined) { + console.info("[Minizip]start decompress!"); + let result = this.mzip.decompress({path:this.dir + "result.zip", operate:"decompress", + option:{overwrite:1, compress_level:9}, directory:this.dir + "out"}) + console.info("[Minizip]compress result = " + JSON.stringify(result)); + } else { + console.info("[Minizip] mzip is undefined!"); + } + } + }) + Button(this.button1Txt) + .fontSize(40) + .margin({top:30}) + .fontWeight(FontWeight.Normal) + .onClick(() => { + if (this.button1 == 0) { + this.button1 = 1; + this.button1Txt = "decompressPSK" + if (this.mzip != undefined) { + let result = this.mzip.compressWithPsd({path:this.dir + "result1.zip", password:"test", operate:"compress", + option:{overwrite:1,compress_level:9}, + files:[this.dir + "file1.txt"]}) + if (result == undefined) { + this.button1 = 0; + this.button1Txt = "compressEpty" + } + console.info("[Minizip] compress result:" + JSON.stringify(result)); + }else { + console.info("[Minizip] mzip is undefined!"); + } + } else { + this.button1 = 0; + this.button1Txt = "compressPSK" + if (this.mzip != undefined) { + let result = this.mzip.decompressWithPsd({path:this.dir + "result1.zip", password:"test", operate:"decompress", + option:{overwrite:1, compress_level:9}, directory:this.dir + "out"}) + + console.info("[Minizip] decompress result:" + JSON.stringify(result)); + } + } + }) + Button(this.button2Txt) + .fontSize(40) + .margin({top:30}) + .fontWeight(FontWeight.Normal) + .onClick(() => { + if (this.button2 == 0) { + this.button2 = 1; + this.button2Txt = "decompressEpty" + if (this.mzip != undefined) { + let result = this.mzip.compressWithEncryption({path:this.dir + "result3.zip", password:"test", operate:"compress", + option:{overwrite:1, compress_level:9, include_path:1, + aes:1, cert_path:this.dir + "test.p12", cert_pwd:"test123TEST"}, + files:[this.dir + "file1.txt"]}) + if (result == undefined) { + this.button2 = 0; + this.button2Txt = "compressEpty" + } + console.info("[Minizip] compress result:" + JSON.stringify(result)); + }else { + console.info("[Minizip] mzip is undefined!"); + } + } else { + this.button2 = 0; + this.button2Txt = "compressEpty" + if (this.mzip != undefined) { + let result = this.mzip.decompressWithEncryption({path:this.dir + "result3.zip", password:"test", operate:"decompress", + option:{overwrite:1, compress_level:9, include_path:1, + aes:1, cert_path:this.dir + "test.p12", cert_pwd:"test123TEST"}, directory:this.dir + "out"}) + + console.info("[Minizip] decompress result:" + JSON.stringify(result)); + } + } + }) + Button(this.button3Txt) + .fontSize(50) + .margin({top:30}) + .fontWeight(FontWeight.Normal) + .onClick(() => { +/* + if (this.button2 == 0) { + this.button2 = 1; + this.button2Txt = "decompressEpty" + if (this.mzip != undefined) { + this.mzip.compressWithEncryption({path:this.dir + "result.zip", password:"test", operate:"compress", + option:{overwrite:1, compress_level:9, include_path:1, + aes:1, cert_path:this.dir + "test.p12", cert_pwd:"test"}, + files:[this.dir + "file1", this.dir + "file2", this.dir + "file3"]}) + } + } else { + this.button2 = 0; + this.button2Txt = "compressEpty" + if (this.mzip != undefined) { + this.mzip.decompressWithEncryption({path:this.dir + "out", password:"test", operate:"decompress", + file_extract:this.dir + "result.zip", + option:{overwrite:1, compress_level:9, include_path:1, + aes:1, cert_path:this.dir + "test.p12", cert_pwd:"test"}, directory:this.dir + "out"}) + } + } +*/ +/* + console.info("[Minizip] before openSync"); + let fd = fileio.openSync(this.dir + "file1.txt", 0o100 | 0o02, 0o666); + fileio.write(fd, "hello world").then(function(number){ + console.info("[Minizip] write data to file succeed and size is:" + number); + }).catch(function(err){ + console.info("[Minizip] write data to file failed with error:" + err); + }); + + fileio.close(fd, function (err) { + console.info("[Minizip] close file failed with error:" + err); + }); + + console.info("[Minizip] after close " + this.dir + "file1.txt"); +*/ + console.info("[Minizip] before open : " + this.dir + "file1.txt"); + + fileio.open(this.dir + "file1.txt", 0o100 | 0o02, 0o666).then(function(fd){ + fileio.write(fd, "hello world\r\n").then(function(number){ + console.info("[Minizip] write data to file succeed and size is:" + number); + }).catch(function(err){ + console.info("[Minizip] write data to file failed with error:" + err); + }); + fileio.close(fd, function (err) { + console.info("[Minizip] close file failed with error:" + err); + }); + console.info("[Minizip] after close " + this.dir + "file1.txt"); + }); + }) + }.width('100%') + .height('100%') + } + + aboutToAppear(){ + this.dir = globalThis.abilityContext.filesDir + "/" + console.info("[Minizip] " + this.dir + "file1.txt"); + } +} diff --git a/FA/thirdparty/minizip_demo/entry/src/main/module.json5 b/FA/thirdparty/minizip_demo/entry/src/main/module.json5 new file mode 100755 index 0000000000000000000000000000000000000000..209afc00fbb4dcebb98d2a50437b90299bc93ef1 --- /dev/null +++ b/FA/thirdparty/minizip_demo/entry/src/main/module.json5 @@ -0,0 +1,50 @@ +{ + "module": { + "name": "entry", + "type": "entry", + "srcEntrance": "./ets/Application/MyAbilityStage.ts", + "description": "$string:entry_desc", + "mainElement": "MainAbility", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:main_pages", + "uiSyntax": "ets", + "abilities": [ + { + "name": "MainAbility", + "srcEntrance": "./ets/MainAbility/MainAbility.ts", + "description": "$string:MainAbility_desc", + "icon": "$media:icon", + "label": "$string:MainAbility_label", + "startWindowIcon": "$media:icon", + "startWindowBackground": "$color:white", + "visible": true, + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ] + } + ], + "requestPermissions": [ + { + "name": "ohos.permission.MEDIA_LOCATION" + }, + { + "name": "ohos.permission.WRITE_MEDIA" + }, + { + "name": "ohos.permission.READ_MEDIA" + } + ] + } +} \ No newline at end of file diff --git a/FA/thirdparty/minizip_demo/entry/src/main/resources/base/element/color.json b/FA/thirdparty/minizip_demo/entry/src/main/resources/base/element/color.json new file mode 100755 index 0000000000000000000000000000000000000000..62a137a61b90c14f109ed8c81d9d551ea0a5888a --- /dev/null +++ b/FA/thirdparty/minizip_demo/entry/src/main/resources/base/element/color.json @@ -0,0 +1,8 @@ +{ + "color": [ + { + "name": "white", + "value": "#FFFFFF" + } + ] +} \ No newline at end of file diff --git a/FA/thirdparty/minizip_demo/entry/src/main/resources/base/element/string.json b/FA/thirdparty/minizip_demo/entry/src/main/resources/base/element/string.json new file mode 100755 index 0000000000000000000000000000000000000000..9868c7395cb8da3f49e03757842312748780962f --- /dev/null +++ b/FA/thirdparty/minizip_demo/entry/src/main/resources/base/element/string.json @@ -0,0 +1,16 @@ +{ + "string": [ + { + "name": "entry_desc", + "value": "description" + }, + { + "name": "MainAbility_label", + "value": "label" + }, + { + "name": "MainAbility_desc", + "value": "description" + } + ] +} \ No newline at end of file diff --git a/FA/thirdparty/minizip_demo/entry/src/main/resources/base/media/icon.png b/FA/thirdparty/minizip_demo/entry/src/main/resources/base/media/icon.png new file mode 100755 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/FA/thirdparty/minizip_demo/entry/src/main/resources/base/media/icon.png differ diff --git a/FA/thirdparty/minizip_demo/entry/src/main/resources/base/profile/main_pages.json b/FA/thirdparty/minizip_demo/entry/src/main/resources/base/profile/main_pages.json new file mode 100755 index 0000000000000000000000000000000000000000..feec276e105eeb8d621c20aaf838f318b0a94150 --- /dev/null +++ b/FA/thirdparty/minizip_demo/entry/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,5 @@ +{ + "src": [ + "pages/index" + ] +} diff --git a/FA/thirdparty/minizip_demo/entry/src/ohosTest/ets/Application/TestAbilityStage.ts b/FA/thirdparty/minizip_demo/entry/src/ohosTest/ets/Application/TestAbilityStage.ts new file mode 100755 index 0000000000000000000000000000000000000000..dc8949dd7647a57e1ce2ec5c2d38d14096b448f2 --- /dev/null +++ b/FA/thirdparty/minizip_demo/entry/src/ohosTest/ets/Application/TestAbilityStage.ts @@ -0,0 +1,22 @@ +/** +* Copyright (c) 2022 Huawei Device Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +import AbilityStage from "@ohos.application.AbilityStage" + +export default class TestAbilityStage extends AbilityStage { + onCreate() { + console.log("[Demo] TestAbilityStage onCreate") + } +} \ No newline at end of file diff --git a/FA/thirdparty/minizip_demo/entry/src/ohosTest/ets/TestAbility/TestAbility.ts b/FA/thirdparty/minizip_demo/entry/src/ohosTest/ets/TestAbility/TestAbility.ts new file mode 100755 index 0000000000000000000000000000000000000000..843a1c4cdacb3978544e55c771f993204afd7ba1 --- /dev/null +++ b/FA/thirdparty/minizip_demo/entry/src/ohosTest/ets/TestAbility/TestAbility.ts @@ -0,0 +1,60 @@ +/** +* Copyright (c) 2022 Huawei Device Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +import Ability from '@ohos.application.Ability' +import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry' +import { Hypium } from '@ohos/hypium' +import testsuite from '../test/List.test' + +export default class TestAbility extends Ability { + onCreate(want, launchParam) { + console.log('TestAbility onCreate') + var abilityDelegator: any + abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator() + var abilityDelegatorArguments: any + abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments() + console.info('start run testcase!!!') + Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite) + } + + onDestroy() { + console.log('TestAbility onDestroy') + } + + onWindowStageCreate(windowStage) { + console.log('TestAbility onWindowStageCreate') + windowStage.loadContent("TestAbility/pages/index", (err, data) => { + if (err.code) { + console.error('Failed to load the content. Cause:' + JSON.stringify(err)); + return; + } + console.info('Succeeded in loading the content. Data: ' + JSON.stringify(data)) + }); + + globalThis.abilityContext = this.context; + } + + onWindowStageDestroy() { + console.log('TestAbility onWindowStageDestroy') + } + + onForeground() { + console.log('TestAbility onForeground') + } + + onBackground() { + console.log('TestAbility onBackground') + } +}; \ No newline at end of file diff --git a/FA/thirdparty/minizip_demo/entry/src/ohosTest/ets/TestAbility/pages/index.ets b/FA/thirdparty/minizip_demo/entry/src/ohosTest/ets/TestAbility/pages/index.ets new file mode 100755 index 0000000000000000000000000000000000000000..38df36e5cf42cfc8c25593fdf35ca0019142a7e4 --- /dev/null +++ b/FA/thirdparty/minizip_demo/entry/src/ohosTest/ets/TestAbility/pages/index.ets @@ -0,0 +1,49 @@ +/** +* Copyright (c) 2022 Huawei Device Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +import router from '@ohos.router'; + +@Entry +@Component +struct Index { + aboutToAppear() { + console.info('TestAbility index aboutToAppear') + } + @State message: string = 'Hello World' + build() { + Row() { + Column() { + Text(this.message) + .fontSize(50) + .fontWeight(FontWeight.Bold) + Button() { + Text('next page') + .fontSize(20) + .fontWeight(FontWeight.Bold) + }.type(ButtonType.Capsule) + .margin({ + top: 20 + }) + .backgroundColor('#0D9FFB') + .width('35%') + .height('5%') + .onClick(()=>{ + }) + } + .width('100%') + } + .height('100%') + } + } \ No newline at end of file diff --git a/FA/thirdparty/minizip_demo/entry/src/ohosTest/ets/TestRunner/OpenHarmonyTestRunner.ts b/FA/thirdparty/minizip_demo/entry/src/ohosTest/ets/TestRunner/OpenHarmonyTestRunner.ts new file mode 100755 index 0000000000000000000000000000000000000000..763a0d76b9949199cc4ee80d52c5bdd13771380f --- /dev/null +++ b/FA/thirdparty/minizip_demo/entry/src/ohosTest/ets/TestRunner/OpenHarmonyTestRunner.ts @@ -0,0 +1,79 @@ +/** +* Copyright (c) 2022 Huawei Device Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +import TestRunner from '@ohos.application.testRunner' +import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry' + +var abilityDelegator = undefined +var abilityDelegatorArguments = undefined + +function translateParamsToString(parameters) { + const keySet = new Set([ + '-s class', '-s notClass', '-s suite', '-s it', + '-s level', '-s testType', '-s size', '-s timeout', + '-s dryRun' + ]) + let targetParams = ''; + for (const key in parameters) { + if (keySet.has(key)) { + targetParams = `${targetParams} ${key} ${parameters[key]}` + } + } + return targetParams.trim() +} + +async function onAbilityCreateCallback() { + console.log("onAbilityCreateCallback"); +} + +async function addAbilityMonitorCallback(err: any) { + console.info("addAbilityMonitorCallback : " + JSON.stringify(err)) +} + +export default class OpenHarmonyTestRunner implements TestRunner { + constructor() { + } + + onPrepare() { + console.info("OpenHarmonyTestRunner OnPrepare ") + } + + async onRun() { + console.log('OpenHarmonyTestRunner onRun run') + abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments() + abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator() + var testAbilityName = abilityDelegatorArguments.bundleName + '.TestAbility' + let lMonitor = { + abilityName: testAbilityName, + onAbilityCreate: onAbilityCreateCallback, + }; + abilityDelegator.addAbilityMonitor(lMonitor, addAbilityMonitorCallback) + var cmd = 'aa start -d 0 -a TestAbility' + ' -b ' + abilityDelegatorArguments.bundleName + cmd += ' '+translateParamsToString(abilityDelegatorArguments.parameters) + var debug = abilityDelegatorArguments.parameters["-D"] + if (debug == 'true') + { + cmd += ' -D' + } + console.info('cmd : '+cmd) + abilityDelegator.executeShellCommand(cmd, + (err: any, d: any) => { + console.info('executeShellCommand : err : ' + JSON.stringify(err)); + console.info('executeShellCommand : data : ' + d.stdResult); + console.info('executeShellCommand : data : ' + d.exitCode); + }) + console.info('OpenHarmonyTestRunner onRun end') + } +}; \ No newline at end of file diff --git a/FA/thirdparty/minizip_demo/entry/src/ohosTest/ets/test/Ability.test.ets b/FA/thirdparty/minizip_demo/entry/src/ohosTest/ets/test/Ability.test.ets new file mode 100755 index 0000000000000000000000000000000000000000..e65fb67ccd9cbba297f5478b7ec21754111d2cae --- /dev/null +++ b/FA/thirdparty/minizip_demo/entry/src/ohosTest/ets/test/Ability.test.ets @@ -0,0 +1,28 @@ +/** +* Copyright (c) 2022 Huawei Device Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium' + +export default function abilityTest() { + describe('ActsAbilityTest', function () { + it('assertContain',0, function () { + console.info("it begin") + let a = 'abc' + let b = 'b' + expect(a).assertContain(b) + expect(a).assertEqual(a) + }) + }) +} \ No newline at end of file diff --git a/FA/thirdparty/minizip_demo/entry/src/ohosTest/ets/test/List.test.ets b/FA/thirdparty/minizip_demo/entry/src/ohosTest/ets/test/List.test.ets new file mode 100755 index 0000000000000000000000000000000000000000..214a087287f9f0967a8edb8969c21ad18cc9fc9c --- /dev/null +++ b/FA/thirdparty/minizip_demo/entry/src/ohosTest/ets/test/List.test.ets @@ -0,0 +1,20 @@ +/** +* Copyright (c) 2022 Huawei Device Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +import abilityTest from './Ability.test' + +export default function testsuite() { + abilityTest() +} \ No newline at end of file diff --git a/FA/thirdparty/minizip_demo/entry/src/ohosTest/module.json5 b/FA/thirdparty/minizip_demo/entry/src/ohosTest/module.json5 new file mode 100755 index 0000000000000000000000000000000000000000..ecb467ef1e859495b2789dfe9965c477417d1a33 --- /dev/null +++ b/FA/thirdparty/minizip_demo/entry/src/ohosTest/module.json5 @@ -0,0 +1,39 @@ +{ + "module": { + "name": "entry_test", + "type": "feature", + "srcEntrance": "./ets/Application/TestAbilityStage.ts", + "description": "$string:entry_test_desc", + "mainElement": "TestAbility", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:test_pages", + "uiSyntax": "ets", + "abilities": [ + { + "name": "TestAbility", + "srcEntrance": "./ets/TestAbility/TestAbility.ts", + "description": "$string:TestAbility_desc", + "icon": "$media:icon", + "label": "$string:TestAbility_label", + "visible": true, + "startWindowIcon": "$media:icon", + "startWindowBackground": "$color:white", + "skills": [ + { + "actions": [ + "action.system.home" + ], + "entities": [ + "entity.system.home" + ] + } + ] + } + ] + } +} diff --git a/FA/thirdparty/minizip_demo/entry/src/ohosTest/resources/base/element/color.json b/FA/thirdparty/minizip_demo/entry/src/ohosTest/resources/base/element/color.json new file mode 100755 index 0000000000000000000000000000000000000000..1bbc9aa9617e97c45440e1d3d66afc1154837012 --- /dev/null +++ b/FA/thirdparty/minizip_demo/entry/src/ohosTest/resources/base/element/color.json @@ -0,0 +1,8 @@ +{ + "color": [ + { + "name": "white", + "value": "#FFFFFF" + } + ] +} \ No newline at end of file diff --git a/FA/thirdparty/minizip_demo/entry/src/ohosTest/resources/base/element/string.json b/FA/thirdparty/minizip_demo/entry/src/ohosTest/resources/base/element/string.json new file mode 100755 index 0000000000000000000000000000000000000000..36d4230c53e9f5a07ae343ad8dc9808341975e3b --- /dev/null +++ b/FA/thirdparty/minizip_demo/entry/src/ohosTest/resources/base/element/string.json @@ -0,0 +1,16 @@ +{ + "string": [ + { + "name": "entry_test_desc", + "value": "test ability description" + }, + { + "name": "TestAbility_desc", + "value": "the test ability" + }, + { + "name": "TestAbility_label", + "value": "test label" + } + ] +} \ No newline at end of file diff --git a/FA/thirdparty/minizip_demo/entry/src/ohosTest/resources/base/media/icon.png b/FA/thirdparty/minizip_demo/entry/src/ohosTest/resources/base/media/icon.png new file mode 100755 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/FA/thirdparty/minizip_demo/entry/src/ohosTest/resources/base/media/icon.png differ diff --git a/FA/thirdparty/minizip_demo/entry/src/ohosTest/resources/base/profile/test_pages.json b/FA/thirdparty/minizip_demo/entry/src/ohosTest/resources/base/profile/test_pages.json new file mode 100755 index 0000000000000000000000000000000000000000..fcef82b4dfc18e28106ff9ecd1c8b48ec74d18a4 --- /dev/null +++ b/FA/thirdparty/minizip_demo/entry/src/ohosTest/resources/base/profile/test_pages.json @@ -0,0 +1,5 @@ +{ + "src": [ + "TestAbility/pages/index" + ] +} diff --git a/FA/thirdparty/minizip_demo/hvigorfile.js b/FA/thirdparty/minizip_demo/hvigorfile.js new file mode 100755 index 0000000000000000000000000000000000000000..586ced98461bdcdac2b070f2e041e99c7ac678d9 --- /dev/null +++ b/FA/thirdparty/minizip_demo/hvigorfile.js @@ -0,0 +1,2 @@ +// Script for compiling build behavior. It is built in the build plug-in and cannot be modified currently. +module.exports = require('@ohos/hvigor-ohos-plugin').appTasks \ No newline at end of file diff --git a/FA/thirdparty/minizip_demo/package.json b/FA/thirdparty/minizip_demo/package.json new file mode 100755 index 0000000000000000000000000000000000000000..d22a448919a1533630262dddce15c5dcd3e01a0c --- /dev/null +++ b/FA/thirdparty/minizip_demo/package.json @@ -0,0 +1,18 @@ +{ + "license": "ISC", + "devDependencies": {}, + "name": "minizip", + "ohos": { + "org": "huawei", + "directoryLevel": "project", + "buildTool": "hvigor" + }, + "description": "example description", + "repository": {}, + "version": "1.0.0", + "dependencies": { + "@ohos/hypium": "1.0.2", + "@ohos/hvigor-ohos-plugin": "1.2.2", + "@ohos/hvigor": "1.2.2" + } +}