diff --git a/BUILD.gn b/BUILD.gn
new file mode 100644
index 0000000000000000000000000000000000000000..e969a8e895cc589465e803f6961cab9027ee118b
--- /dev/null
+++ b/BUILD.gn
@@ -0,0 +1,85 @@
+# 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("//build/ohos.gni")
+import("//build/test.gni")
+ohos_executable("restool") {
+ sources = [
+ "src/xml/key_manager.cpp",
+ "src/xml/solid_xml.cpp",
+ "src/xml/xml_converter.cpp",
+ "src/xml/xml_key_node.cpp",
+ "src/cmd_list.cpp",
+ "src/cmd_parser.cpp",
+ "src/config_parser.cpp",
+ "src/factory_resource_compiler.cpp",
+ "src/file_entry.cpp",
+ "src/file_manager.cpp",
+ "src/generic_compiler.cpp",
+ "src/header.cpp",
+ "src/i_resource_compiler.cpp",
+ "src/id_worker.cpp",
+ "src/increment_index.cpp",
+ "src/increment_list.cpp",
+ "src/increment_manager.cpp",
+ "src/json_compiler.cpp",
+ "src/key_parser.cpp",
+ "src/module_combine.cpp",
+ "src/preview_manager.cpp",
+ "src/reference_parser.cpp",
+ "src/resource_directory.cpp",
+ "src/resource_item.cpp",
+ "src/resource_merge.cpp",
+ "src/resource_module.cpp",
+ "src/resource_module_inc.cpp",
+ "src/resource_pack.cpp",
+ "src/resource_table.cpp",
+ "src/resource_util.cpp",
+ "src/restool.cpp",
+ "src/solid_xml_compiler.cpp",
+ "src/sqlite_database.cpp",
+ "src/task_handle.cpp"
+ ]
+
+ include_dirs = []
+ if (is_mingw) {
+ include_dirs += [
+ "//developtools/global_resource_tool/build/libxml2/win32/include"
+ ]
+ }
+ include_dirs += [
+ "include",
+ "//third_party/libxml2/include",
+ "//third_party/jsoncpp/include",
+ "//third_party/sqlite/include",
+ "//third_party/bounds_checking_function/include"
+ ]
+
+ deps = [
+ "//developtools/global_resource_tool/build/jsoncpp:restool_jsoncpp",
+ "//developtools/global_resource_tool/build/sqlite3:restool_sqlite",
+ "//developtools/global_resource_tool/build/libxml2:restool_libxml2",
+ "//developtools/global_resource_tool/build/bounds_checking_function:restool_bounds_checking_function"
+ ]
+
+ cflags = [ "-std=c++17" ]
+ if (is_mingw) {
+ ldflags = [ "-static", "-lws2_32" ]
+ }
+ subsystem_name = "developtools"
+ part_name = "global_restool"
+}
+
+ohos_unittest_py("restool_test") {
+ sources = [ "test/test.py" ]
+}
\ No newline at end of file
diff --git a/CMakeLists.txt b/CMakeLists.txt
index a1bfca487de9aff676362989ca2cb0cd76fdc941..f32cef81f8493e402cdc9f279c9390da2edd460b 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -22,7 +22,7 @@ set(sqlite3_dir ${CMAKE_SOURCE_DIR}/../../third_party/sqlite)
include_directories(include)
include_directories(${jsoncpp_dir}/include)
include_directories(${bound_checking_function_dir}/include)
-include_directories(${CMAKE_CURRENT_BINARY_DIR}/third_party/libxml2/libxml2/include)
+include_directories(${CMAKE_CURRENT_BINARY_DIR}/build/libxml2/include)
include_directories(${sqlite3_dir}/include)
aux_source_directory(src restool_source)
@@ -31,7 +31,7 @@ aux_source_directory(src/xml restool_source)
add_executable(restool ${restool_source})
target_link_libraries(restool myxml2 jsoncpp securec sqlite3)
-add_subdirectory(third_party/libxml2)
-add_subdirectory(third_party/jsoncpp)
-add_subdirectory(third_party/bounds_checking_function)
-add_subdirectory(third_party/sqlite3)
+add_subdirectory(build/libxml2)
+add_subdirectory(build/jsoncpp)
+add_subdirectory(build/bounds_checking_function)
+add_subdirectory(build/sqlite3)
diff --git a/OTA.xml b/OTA.xml
index 29f7b9fece6e2600a2b74c392391b86fa629d9a6..40ad509154591556bf9d5a99ad17cd3cf08cd5a3 100644
--- a/OTA.xml
+++ b/OTA.xml
@@ -63,11 +63,14 @@
-
+
+
+
+
diff --git a/README.md b/README.md
index b1ec3df85e2d0d787b75d381b5a74baca7202928..c24713ebfb41778dcb79672bfcdd83d8484cee1c 100644
--- a/README.md
+++ b/README.md
@@ -10,22 +10,37 @@ restool(resource tool) is used in computer.In OpenHarmony SDK toolchain.When IDE
|----global_resource_tool
| |----include
| |----src
-| |----third_party dependence third patry lib make script
+| |----test
+| |----build dependence third patry lib make script
| |----CMakeLists.txt
+| |----BUILD.gn
| |----win32.cmake windows cross compile script
```
## Instructions
-### Compile
+### Quickly Build
-1. gcc/g++ version 9.3.0 required
-2. cmake version mini 3.15 required
-3. mkdir build
-4. cd build
-5. cmake ../restool_standard
-6. make
-7. compile result restool binary
+1. ubuntu 18 preinstalled gcc/g++
+2. cmake version mini 3.15 required
+3. mkdir build
+4. cd build
+5. cmake ../global_resource_tool
+6. make
+7. compile result restool binary
+
+### SDK Build
+
+1. ./build.sh --product-name ohos-sdk
+
+SDK build refer to https://gitee.com/openharmony/build/blob/master/README_zh.md
+
+### Test
+
+1.in PC, run python test/test.py param1 param2
+
+param1: restool path
+param2: result path
### Help
diff --git a/README_zh.md b/README_zh.md
index b2997f8b80c250d00cd984e3f12d3e00b96533ff..72cea9ce83b16165c86e53e6d6f39340515127e0 100644
--- a/README_zh.md
+++ b/README_zh.md
@@ -10,22 +10,37 @@
|----global_resource_tool
| |----include
| |----src
-| |----third_party 依赖三方库编译脚本
+| |----test
+| |----build 依赖三方库编译脚本
+| |----BUILD.gn
| |----CMakeLists.txt
| |----win32.cmake windows交叉编译脚本
```
## 使用说明
-### 代码编译命令
+### 快速调试编译
-1. 编译环境gcc/g++ 9.3.0
-2. cmake 版本最低3.15
-3. 与global_resource_tool同级目录新建build
-4. cd build
-5. cmake ../global_resource_tool
-6. make
-7. 编译结果输出restool
+1. ubuntu 18 系统预装 gcc/g++
+2. cmake 版本最低3.15
+3. 与global_resource_tool同级目录新建build
+4. cd build
+5. cmake ../global_resource_tool
+6. make
+7. 编译结果输出restool
+
+### SDK编译命令
+
+1. ./build.sh --product-nane ohos-sdk
+
+SDK 编译参考https://gitee.com/openharmony/build/blob/master/README_zh.md 仓编译sdk说明。
+
+### 测试用例
+
+1.PC 上运行 python test/test.py 参数1 参数2
+
+参数1 restool 命令路径
+参数2 输出结果路径
### 命令帮助
diff --git a/build/bounds_checking_function/BUILD.gn b/build/bounds_checking_function/BUILD.gn
new file mode 100644
index 0000000000000000000000000000000000000000..ce632383a3044c3ab1ab4d8502c5866d6d69f85d
--- /dev/null
+++ b/build/bounds_checking_function/BUILD.gn
@@ -0,0 +1,37 @@
+# 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("//build/ohos.gni")
+import("//third_party/bounds_checking_function/libsec_src.gni")
+ohos_static_library("restool_bounds_checking_function") {
+ sources = libsec_sources
+
+ include_dirs = [
+ "//third_party/bounds_checking_function/include"
+ ]
+
+ cflags_cc = [ "-std=c++17" ]
+ cflags_c =[
+ "-Wno-attributes",
+ "-Wno-inconsistent-dllimport",
+ "-D_INC_STRING_S",
+ "-D_INC_WCHAR_S",
+ "-D_SECIMP=//",
+ "-D_STDIO_S_DEFINED",
+ "-D_INC_STDIO_S",
+ "-D_INC_STDLIB_S",
+ "-D_INC_MEMORY_S"
+ ]
+ subsystem_name = "developtools"
+ part_name = "global_restool"
+}
\ No newline at end of file
diff --git a/third_party/bounds_checking_function/CMakeLists.txt b/build/bounds_checking_function/CMakeLists.txt
similarity index 100%
rename from third_party/bounds_checking_function/CMakeLists.txt
rename to build/bounds_checking_function/CMakeLists.txt
diff --git a/build/jsoncpp/BUILD.gn b/build/jsoncpp/BUILD.gn
new file mode 100644
index 0000000000000000000000000000000000000000..b1bdff1252bcb6dc1a2c8542b4c1ed0fde24bd40
--- /dev/null
+++ b/build/jsoncpp/BUILD.gn
@@ -0,0 +1,30 @@
+# 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("//build/ohos.gni")
+ohos_static_library("restool_jsoncpp") {
+ sources = [
+ "//third_party/jsoncpp/src/lib_json/json_reader.cpp",
+ "//third_party/jsoncpp/src/lib_json/json_value.cpp",
+ "//third_party/jsoncpp/src/lib_json/json_writer.cpp"
+ ]
+
+ include_dirs = [
+ "//third_party/jsoncpp/include"
+ ]
+
+ cflags = [ "-std=c++17" ]
+ use_exceptions = true
+ subsystem_name = "developtools"
+ part_name = "global_restool"
+}
\ No newline at end of file
diff --git a/third_party/jsoncpp/CMakeLists.txt b/build/jsoncpp/CMakeLists.txt
similarity index 100%
rename from third_party/jsoncpp/CMakeLists.txt
rename to build/jsoncpp/CMakeLists.txt
diff --git a/build/libxml2/BUILD.gn b/build/libxml2/BUILD.gn
new file mode 100644
index 0000000000000000000000000000000000000000..be0c3ce6799a57d7743e4c9f9862efb47cb8de7c
--- /dev/null
+++ b/build/libxml2/BUILD.gn
@@ -0,0 +1,143 @@
+# 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("//build/ohos.gni")
+LIBXML_PATH = "//third_party/libxml2"
+
+config("restool_libxml2_config") {
+ include_dirs = []
+ if (is_mingw) {
+ include_dirs += [
+ "//developtools/global_resource_tool/build/libxml2/win32/include"
+ ]
+ defines = [ "LIBXML_STATIC"]
+ } else {
+ include_dirs += [
+ "${LIBXML_PATH}/config"
+ ]
+ }
+
+ include_dirs += [
+ "${LIBXML_PATH}/include"
+ ]
+
+ cflags_cc = [
+ "-std=c++17"
+ ]
+
+ cflags_c = [
+ "-Wno-implicit-fallthrough",
+ "-Wno-implicit-function-declaration",
+ "-Wno-int-conversion"
+ ]
+}
+
+ohos_static_library("restool_libxml2") {
+ sources = [
+ "${LIBXML_PATH}/DOCBparser.c",
+ "${LIBXML_PATH}/HTMLparser.c",
+ "${LIBXML_PATH}/HTMLtree.c",
+ "${LIBXML_PATH}/SAX.c",
+ "${LIBXML_PATH}/SAX2.c",
+ "${LIBXML_PATH}/buf.c",
+ "${LIBXML_PATH}/c14n.c",
+ "${LIBXML_PATH}/catalog.c",
+ "${LIBXML_PATH}/chvalid.c",
+ "${LIBXML_PATH}/debugXML.c",
+ "${LIBXML_PATH}/dict.c",
+ "${LIBXML_PATH}/encoding.c",
+ "${LIBXML_PATH}/entities.c",
+ "${LIBXML_PATH}/error.c",
+ "${LIBXML_PATH}/globals.c",
+ "${LIBXML_PATH}/hash.c",
+ "${LIBXML_PATH}/include/libxml/DOCBparser.h",
+ "${LIBXML_PATH}/include/libxml/HTMLparser.h",
+ "${LIBXML_PATH}/include/libxml/HTMLtree.h",
+ "${LIBXML_PATH}/include/libxml/SAX.h",
+ "${LIBXML_PATH}/include/libxml/SAX2.h",
+ "${LIBXML_PATH}/include/libxml/c14n.h",
+ "${LIBXML_PATH}/include/libxml/catalog.h",
+ "${LIBXML_PATH}/include/libxml/chvalid.h",
+ "${LIBXML_PATH}/include/libxml/debugXML.h",
+ "${LIBXML_PATH}/include/libxml/dict.h",
+ "${LIBXML_PATH}/include/libxml/encoding.h",
+ "${LIBXML_PATH}/include/libxml/entities.h",
+ "${LIBXML_PATH}/include/libxml/globals.h",
+ "${LIBXML_PATH}/include/libxml/hash.h",
+ "${LIBXML_PATH}/include/libxml/list.h",
+ "${LIBXML_PATH}/include/libxml/nanoftp.h",
+ "${LIBXML_PATH}/include/libxml/nanohttp.h",
+ "${LIBXML_PATH}/include/libxml/parser.h",
+ "${LIBXML_PATH}/include/libxml/parserInternals.h",
+ "${LIBXML_PATH}/include/libxml/pattern.h",
+ "${LIBXML_PATH}/include/libxml/relaxng.h",
+ "${LIBXML_PATH}/include/libxml/schemasInternals.h",
+ "${LIBXML_PATH}/include/libxml/schematron.h",
+ "${LIBXML_PATH}/include/libxml/threads.h",
+ "${LIBXML_PATH}/include/libxml/tree.h",
+ "${LIBXML_PATH}/include/libxml/uri.h",
+ "${LIBXML_PATH}/include/libxml/valid.h",
+ "${LIBXML_PATH}/include/libxml/xinclude.h",
+ "${LIBXML_PATH}/include/libxml/xlink.h",
+ "${LIBXML_PATH}/include/libxml/xmlIO.h",
+ "${LIBXML_PATH}/include/libxml/xmlautomata.h",
+ "${LIBXML_PATH}/include/libxml/xmlerror.h",
+ "${LIBXML_PATH}/include/libxml/xmlexports.h",
+ "${LIBXML_PATH}/include/libxml/xmlmemory.h",
+ "${LIBXML_PATH}/include/libxml/xmlmodule.h",
+ "${LIBXML_PATH}/include/libxml/xmlreader.h",
+ "${LIBXML_PATH}/include/libxml/xmlregexp.h",
+ "${LIBXML_PATH}/include/libxml/xmlsave.h",
+ "${LIBXML_PATH}/include/libxml/xmlschemas.h",
+ "${LIBXML_PATH}/include/libxml/xmlschemastypes.h",
+ "${LIBXML_PATH}/include/libxml/xmlstring.h",
+ "${LIBXML_PATH}/include/libxml/xmlunicode.h",
+ "${LIBXML_PATH}/include/libxml/xmlwriter.h",
+ "${LIBXML_PATH}/include/libxml/xpath.h",
+ "${LIBXML_PATH}/include/libxml/xpathInternals.h",
+ "${LIBXML_PATH}/include/libxml/xpointer.h",
+ "${LIBXML_PATH}/legacy.c",
+ "${LIBXML_PATH}/list.c",
+ "${LIBXML_PATH}/nanoftp.c",
+ "${LIBXML_PATH}/nanohttp.c",
+ "${LIBXML_PATH}/parser.c",
+ "${LIBXML_PATH}/parserInternals.c",
+ "${LIBXML_PATH}/pattern.c",
+ "${LIBXML_PATH}/relaxng.c",
+ "${LIBXML_PATH}/schematron.c",
+ "${LIBXML_PATH}/threads.c",
+ "${LIBXML_PATH}/tree.c",
+ "${LIBXML_PATH}/uri.c",
+ "${LIBXML_PATH}/valid.c",
+ "${LIBXML_PATH}/xinclude.c",
+ "${LIBXML_PATH}/xlink.c",
+ "${LIBXML_PATH}/xmlIO.c",
+ "${LIBXML_PATH}/xmlmemory.c",
+ "${LIBXML_PATH}/xmlmodule.c",
+ "${LIBXML_PATH}/xmlreader.c",
+ "${LIBXML_PATH}/xmlregexp.c",
+ "${LIBXML_PATH}/xmlsave.c",
+ "${LIBXML_PATH}/xmlschemas.c",
+ "${LIBXML_PATH}/xmlschemastypes.c",
+ "${LIBXML_PATH}/xmlstring.c",
+ "${LIBXML_PATH}/xmlunicode.c",
+ "${LIBXML_PATH}/xmlwriter.c",
+ "${LIBXML_PATH}/xpath.c",
+ "${LIBXML_PATH}/xpointer.c",
+ "${LIBXML_PATH}/xzlib.c"
+ ]
+
+ public_configs = [ ":restool_libxml2_config" ]
+
+ subsystem_name = "developtools"
+ part_name = "global_restool"
+}
\ No newline at end of file
diff --git a/third_party/libxml2/CMakeLists.txt b/build/libxml2/CMakeLists.txt
similarity index 95%
rename from third_party/libxml2/CMakeLists.txt
rename to build/libxml2/CMakeLists.txt
index fee84689f4df2b1694cc48230b9d21ceecc40b6a..f54e26ef0ccbe5df07d80b9cc4cd42c270191520 100644
--- a/third_party/libxml2/CMakeLists.txt
+++ b/build/libxml2/CMakeLists.txt
@@ -1,9 +1,22 @@
+cmake_minimum_required(VERSION 3.15)
+
+project(myxml2 LANGUAGES C)
+#include(CheckCSourceCompiles)
+#include(CheckIncludeFiles)
+#include(CheckStructHasMember)
+#include(CheckFunctionExists)
+#include(CheckLibraryExists)
+#include(CheckSymbolExists)
+
include(CheckCSourceCompiles)
-include(CheckIncludeFiles)
-include(CheckStructHasMember)
include(CheckFunctionExists)
+include(CheckIncludeFiles)
+include(CheckIncludeFile)
include(CheckLibraryExists)
+include(CheckStructHasMember)
include(CheckSymbolExists)
+include(CMakePackageConfigHelpers)
+include(GNUInstallDirs)
option(BUILD_SHARED_LIBS "Build shared libraries" OFF)
set(LIBXML2_WITH_AUTOMATA ON)
@@ -77,7 +90,7 @@ if(NOT GETHOSTBYNAME_ARG_CAST_CONST)
else()
set(GETHOSTBYNAME_ARG_CAST "/**/")
endif()
-check_include_files(arpa/inet.h HAVE_ARPA_INET_H)
+CHECK_INCLUDE_FILE(arpa/inet.h HAVE_ARPA_INET_H)
check_include_files(arpa/nameser.h HAVE_ARPA_NAMESER_H)
check_struct_has_member("struct sockaddr_storage" ss_family "sys/socket.h;sys/types.h" HAVE_SS_FAMILY)
check_struct_has_member("struct sockaddr_storage" __ss_family "sys/socket.h;sys/types.h" HAVE_BROKEN_SS_FAMILY)
@@ -337,6 +350,8 @@ set(libxml2_original_source
${libxml2_original}/xzlib.c
)
+#set(CMAKE_THREAD_LIBS_INIT "-lpthread")
+#message("pthread " ${CMAKE_THREAD_LIBS_INIT})
find_package(Threads REQUIRED)
add_library(myxml2 STATIC ${libxml2_original_header} ${libxml2_original_other_header} ${libxml2_original_source})
target_link_libraries(myxml2 PRIVATE Threads::Threads)
@@ -345,4 +360,7 @@ if(WIN32)
target_link_libraries(myxml2 PRIVATE ws2_32)
set(WIN32_EXTRA_LIBADD "-lws2_32")
endif()
-configure_file(${libxml2_original}/include/libxml/xmlversion.h.in ${libxml2_original}/include/libxml/xmlversion.h)
\ No newline at end of file
+configure_file(${libxml2_original}/include/libxml/xmlversion.h.in ${libxml2_original}/include/libxml/xmlversion.h)
+
+file(COPY ${libxml2_original_header} DESTINATION ./include/libxml)
+file(COPY ${libxml2_original}/include/libxml/xmlversion.h DESTINATION ./include/libxml)
\ No newline at end of file
diff --git a/third_party/libxml2/config.h.cmake.in b/build/libxml2/config.h.cmake.in
similarity index 100%
rename from third_party/libxml2/config.h.cmake.in
rename to build/libxml2/config.h.cmake.in
diff --git a/build/libxml2/win32/include/config.h b/build/libxml2/win32/include/config.h
new file mode 100644
index 0000000000000000000000000000000000000000..5611fd86ad3afa1e8fe5a41368b1bbf68ba396d9
--- /dev/null
+++ b/build/libxml2/win32/include/config.h
@@ -0,0 +1,288 @@
+/* config.h. Generated from config.h.in by configure. */
+/* config.h.in. Generated from configure.ac by autoheader. */
+
+/* Define if __attribute__((destructor)) is accepted */
+#define ATTRIBUTE_DESTRUCTOR 1
+
+/* Type cast for the gethostbyname() argument */
+#define GETHOSTBYNAME_ARG_CAST (char *)
+
+/* Define to 1 if you have the header file. */
+/* #undef HAVE_ARPA_INET_H */
+
+/* Define to 1 if you have the header file. */
+/* #undef HAVE_ARPA_NAMESER_H */
+
+/* Whether struct sockaddr::__ss_family exists */
+/* #undef HAVE_BROKEN_SS_FAMILY */
+
+/* Define to 1 if you have the header file. */
+#define HAVE_CTYPE_H 1
+
+/* Define to 1 if you have the header file. */
+#define HAVE_DIRENT_H 1
+
+/* Define to 1 if you have the header file. */
+/* #undef HAVE_DLFCN_H */
+
+/* Have dlopen based dso */
+/* #undef HAVE_DLOPEN */
+
+/* Define to 1 if you have the header file. */
+/* #undef HAVE_DL_H */
+
+/* Define to 1 if you have the header file. */
+#define HAVE_ERRNO_H 1
+
+/* Define to 1 if you have the header file. */
+#define HAVE_FCNTL_H 1
+
+/* Define to 1 if you have the header file. */
+#define HAVE_FLOAT_H 1
+
+/* Define to 1 if you have the `fprintf' function. */
+#define HAVE_FPRINTF 1
+
+/* Define to 1 if you have the `ftime' function. */
+#define HAVE_FTIME 1
+
+/* Define if getaddrinfo is there */
+/* #undef HAVE_GETADDRINFO */
+
+/* Define to 1 if you have the `gettimeofday' function. */
+#define HAVE_GETTIMEOFDAY 1
+
+/* Define to 1 if you have the header file. */
+#define HAVE_INTTYPES_H 1
+
+/* Define to 1 if you have the `isascii' function. */
+#define HAVE_ISASCII 1
+
+/* Define if isinf is there */
+/* #undef HAVE_ISINF */
+
+/* Define if isnan is there */
+#define HAVE_ISNAN 1
+
+/* Define if history library is there (-lhistory) */
+/* #undef HAVE_LIBHISTORY */
+
+/* Define if pthread library is there (-lpthread) */
+#define HAVE_LIBPTHREAD 1
+
+/* Define if readline library is there (-lreadline) */
+/* #undef HAVE_LIBREADLINE */
+
+/* Define to 1 if you have the header file. */
+#define HAVE_LIMITS_H 1
+
+/* Define to 1 if you have the `localtime' function. */
+#define HAVE_LOCALTIME 1
+
+/* Define to 1 if you have the header file. */
+/* #undef HAVE_LZMA_H */
+
+/* Define to 1 if you have the header file. */
+#define HAVE_MALLOC_H 1
+
+/* Define to 1 if you have the header file. */
+#define HAVE_MATH_H 1
+
+/* Define to 1 if you have the header file. */
+#define HAVE_MEMORY_H 1
+
+/* Define to 1 if you have the `mmap' function. */
+/* #undef HAVE_MMAP */
+
+/* Define to 1 if you have the `munmap' function. */
+/* #undef HAVE_MUNMAP */
+
+/* mmap() is no good without munmap() */
+#if defined(HAVE_MMAP) && !defined(HAVE_MUNMAP)
+# undef /**/ HAVE_MMAP
+#endif
+
+/* Define to 1 if you have the header file, and it defines `DIR'. */
+/* #undef HAVE_NDIR_H */
+
+/* Define to 1 if you have the header file. */
+/* #undef HAVE_NETDB_H */
+
+/* Define to 1 if you have the header file. */
+/* #undef HAVE_NETINET_IN_H */
+
+/* Define to 1 if you have the header file. */
+/* #undef HAVE_POLL_H */
+
+/* Define to 1 if you have the `printf' function. */
+#define HAVE_PRINTF 1
+
+/* Define if is there */
+#define HAVE_PTHREAD_H 1
+
+/* Define to 1 if you have the `putenv' function. */
+#define HAVE_PUTENV 1
+
+/* Define to 1 if you have the `rand' function. */
+#define HAVE_RAND 1
+
+/* Define to 1 if you have the `rand_r' function. */
+/* #undef HAVE_RAND_R */
+
+/* Define to 1 if you have the header file. */
+/* #undef HAVE_RESOLV_H */
+
+/* Have shl_load based dso */
+/* #undef HAVE_SHLLOAD */
+
+/* Define to 1 if you have the `signal' function. */
+#define HAVE_SIGNAL 1
+
+/* Define to 1 if you have the header file. */
+#define HAVE_SIGNAL_H 1
+
+/* Define to 1 if you have the `snprintf' function. */
+#define HAVE_SNPRINTF 1
+
+/* Define to 1 if you have the `sprintf' function. */
+#define HAVE_SPRINTF 1
+
+/* Define to 1 if you have the `srand' function. */
+#define HAVE_SRAND 1
+
+/* Define to 1 if you have the `sscanf' function. */
+#define HAVE_SSCANF 1
+
+/* Define to 1 if you have the `stat' function. */
+#define HAVE_STAT 1
+
+/* Define to 1 if you have the header file. */
+#define HAVE_STDARG_H 1
+
+/* Define to 1 if you have the header file. */
+#define HAVE_STDINT_H 1
+
+/* Define to 1 if you have the header file. */
+#define HAVE_STDLIB_H 1
+
+/* Define to 1 if you have the `strftime' function. */
+#define HAVE_STRFTIME 1
+
+/* Define to 1 if you have the header file. */
+#define HAVE_STRINGS_H 1
+
+/* Define to 1 if you have the header file. */
+#define HAVE_STRING_H 1
+
+/* Define to 1 if you have the header file, and it defines `DIR'.
+ */
+/* #undef HAVE_SYS_DIR_H */
+
+/* Define to 1 if you have the header file. */
+/* #undef HAVE_SYS_MMAN_H */
+
+/* Define to 1 if you have the header file, and it defines `DIR'.
+ */
+/* #undef HAVE_SYS_NDIR_H */
+
+/* Define to 1 if you have the header file. */
+/* #undef HAVE_SYS_SELECT_H */
+
+/* Define to 1 if you have the header file. */
+/* #undef HAVE_SYS_SOCKET_H */
+
+/* Define to 1 if you have the header file. */
+#define HAVE_SYS_STAT_H 1
+
+/* Define to 1 if you have the header file. */
+#define HAVE_SYS_TIMEB_H 1
+
+/* Define to 1 if you have the header file. */
+#define HAVE_SYS_TIME_H 1
+
+/* Define to 1 if you have the header file. */
+#define HAVE_SYS_TYPES_H 1
+
+/* Define to 1 if you have the `time' function. */
+#define HAVE_TIME 1
+
+/* Define to 1 if you have the header file. */
+#define HAVE_TIME_H 1
+
+/* Define to 1 if you have the header file. */
+#define HAVE_UNISTD_H 1
+
+/* Whether va_copy() is available */
+/* #undef HAVE_VA_COPY */
+
+/* Define to 1 if you have the `vfprintf' function. */
+#define HAVE_VFPRINTF 1
+
+/* Define to 1 if you have the `vsnprintf' function. */
+#define HAVE_VSNPRINTF 1
+
+/* Define to 1 if you have the `vsprintf' function. */
+#define HAVE_VSPRINTF 1
+
+/* Define to 1 if you have the header file. */
+/* #undef HAVE_ZLIB_H */
+
+/* Whether __va_copy() is available */
+/* #undef HAVE___VA_COPY */
+
+/* Define as const if the declaration of iconv() needs const. */
+#define ICONV_CONST const
+
+/* Define to the sub-directory where libtool stores uninstalled libraries. */
+#define LT_OBJDIR ".libs/"
+
+/* Name of package */
+#define PACKAGE ""
+
+/* Define to the address where bug reports for this package should be sent. */
+#define PACKAGE_BUGREPORT ""
+
+/* Define to the full name of this package. */
+#define PACKAGE_NAME ""
+
+/* Define to the full name and version of this package. */
+#define PACKAGE_STRING ""
+
+/* Define to the one symbol short name of this package. */
+#define PACKAGE_TARNAME ""
+
+/* Define to the home page for this package. */
+#define PACKAGE_URL ""
+
+/* Define to the version of this package. */
+#define PACKAGE_VERSION ""
+
+/* Type cast for the send() function 2nd arg */
+#define SEND_ARG2_CAST (char *)
+
+/* Define to 1 if you have the ANSI C header files. */
+#define STDC_HEADERS 1
+
+/* Support for IPv6 */
+/* #undef SUPPORT_IP6 */
+
+/* Define if va_list is an array type */
+/* #undef VA_LIST_IS_ARRAY */
+
+/* Version number of package */
+#define VERSION "2.9.10"
+
+/* Determine what socket length (socklen_t) data type is */
+#define XML_SOCKLEN_T int
+
+/* Define for Solaris 2.5.1 so the uint32_t typedef from ,
+ , or is not used. If the typedef were allowed, the
+ #define below would cause a syntax error. */
+/* #undef _UINT32_T */
+
+/* ss_family is not defined here, use __ss_family instead */
+/* #undef ss_family */
+
+/* Define to the type of an unsigned integer type of width exactly 32 bits if
+ such a type exists and the standard includes do not define it. */
+/* #undef uint32_t */
diff --git a/build/libxml2/win32/include/libxml/xmlversion.h b/build/libxml2/win32/include/libxml/xmlversion.h
new file mode 100644
index 0000000000000000000000000000000000000000..f7991db9c90d06769309a8710780303fe80b38e5
--- /dev/null
+++ b/build/libxml2/win32/include/libxml/xmlversion.h
@@ -0,0 +1,485 @@
+/*
+ * Summary: compile-time version informations
+ * Description: compile-time version informations for the XML library
+ *
+ * Copy: See Copyright for the status of this software.
+ *
+ * Author: Daniel Veillard
+ */
+
+#ifndef __XML_VERSION_H__
+#define __XML_VERSION_H__
+
+#include
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*
+ * use those to be sure nothing nasty will happen if
+ * your library and includes mismatch
+ */
+#ifndef LIBXML2_COMPILING_MSCCDEF
+XMLPUBFUN void XMLCALL xmlCheckVersion(int version);
+#endif /* LIBXML2_COMPILING_MSCCDEF */
+
+/**
+ * LIBXML_DOTTED_VERSION:
+ *
+ * the version string like "1.2.3"
+ */
+#define LIBXML_DOTTED_VERSION "2.9.10"
+
+/**
+ * LIBXML_VERSION:
+ *
+ * the version number: 1.2.3 value is 10203
+ */
+#define LIBXML_VERSION 209010
+
+/**
+ * LIBXML_VERSION_STRING:
+ *
+ * the version number string, 1.2.3 value is "10203"
+ */
+#define LIBXML_VERSION_STRING "209010"
+
+/**
+ * LIBXML_VERSION_EXTRA:
+ *
+ * extra version information, used to show a CVS compilation
+ */
+#define LIBXML_VERSION_EXTRA ""
+
+/**
+ * LIBXML_TEST_VERSION:
+ *
+ * Macro to check that the libxml version in use is compatible with
+ * the version the software has been compiled against
+ */
+#define LIBXML_TEST_VERSION xmlCheckVersion(209010);
+
+#ifndef VMS
+#if 0
+/**
+ * WITH_TRIO:
+ *
+ * defined if the trio support need to be configured in
+ */
+#define WITH_TRIO
+#else
+/**
+ * WITHOUT_TRIO:
+ *
+ * defined if the trio support should not be configured in
+ */
+#define WITHOUT_TRIO
+#endif
+#else /* VMS */
+/**
+ * WITH_TRIO:
+ *
+ * defined if the trio support need to be configured in
+ */
+#define WITH_TRIO 1
+#endif /* VMS */
+
+/**
+ * LIBXML_THREAD_ENABLED:
+ *
+ * Whether the thread support is configured in
+ */
+#if 1
+#define LIBXML_THREAD_ENABLED
+#endif
+
+/**
+ * LIBXML_THREAD_ALLOC_ENABLED:
+ *
+ * Whether the allocation hooks are per-thread
+ */
+#if 0
+#define LIBXML_THREAD_ALLOC_ENABLED
+#endif
+
+/**
+ * LIBXML_TREE_ENABLED:
+ *
+ * Whether the DOM like tree manipulation API support is configured in
+ */
+#if 1
+#define LIBXML_TREE_ENABLED
+#endif
+
+/**
+ * LIBXML_OUTPUT_ENABLED:
+ *
+ * Whether the serialization/saving support is configured in
+ */
+#if 1
+#define LIBXML_OUTPUT_ENABLED
+#endif
+
+/**
+ * LIBXML_PUSH_ENABLED:
+ *
+ * Whether the push parsing interfaces are configured in
+ */
+#if 1
+#define LIBXML_PUSH_ENABLED
+#endif
+
+/**
+ * LIBXML_READER_ENABLED:
+ *
+ * Whether the xmlReader parsing interface is configured in
+ */
+#if 1
+#define LIBXML_READER_ENABLED
+#endif
+
+/**
+ * LIBXML_PATTERN_ENABLED:
+ *
+ * Whether the xmlPattern node selection interface is configured in
+ */
+#if 1
+#define LIBXML_PATTERN_ENABLED
+#endif
+
+/**
+ * LIBXML_WRITER_ENABLED:
+ *
+ * Whether the xmlWriter saving interface is configured in
+ */
+#if 1
+#define LIBXML_WRITER_ENABLED
+#endif
+
+/**
+ * LIBXML_SAX1_ENABLED:
+ *
+ * Whether the older SAX1 interface is configured in
+ */
+#if 1
+#define LIBXML_SAX1_ENABLED
+#endif
+
+/**
+ * LIBXML_FTP_ENABLED:
+ *
+ * Whether the FTP support is configured in
+ */
+#if 1
+#define LIBXML_FTP_ENABLED
+#endif
+
+/**
+ * LIBXML_HTTP_ENABLED:
+ *
+ * Whether the HTTP support is configured in
+ */
+#if 1
+#define LIBXML_HTTP_ENABLED
+#endif
+
+/**
+ * LIBXML_VALID_ENABLED:
+ *
+ * Whether the DTD validation support is configured in
+ */
+#if 1
+#define LIBXML_VALID_ENABLED
+#endif
+
+/**
+ * LIBXML_HTML_ENABLED:
+ *
+ * Whether the HTML support is configured in
+ */
+#if 1
+#define LIBXML_HTML_ENABLED
+#endif
+
+/**
+ * LIBXML_LEGACY_ENABLED:
+ *
+ * Whether the deprecated APIs are compiled in for compatibility
+ */
+#if 1
+#define LIBXML_LEGACY_ENABLED
+#endif
+
+/**
+ * LIBXML_C14N_ENABLED:
+ *
+ * Whether the Canonicalization support is configured in
+ */
+#if 1
+#define LIBXML_C14N_ENABLED
+#endif
+
+/**
+ * LIBXML_CATALOG_ENABLED:
+ *
+ * Whether the Catalog support is configured in
+ */
+#if 1
+#define LIBXML_CATALOG_ENABLED
+#endif
+
+/**
+ * LIBXML_DOCB_ENABLED:
+ *
+ * Whether the SGML Docbook support is configured in
+ */
+#if 1
+#define LIBXML_DOCB_ENABLED
+#endif
+
+/**
+ * LIBXML_XPATH_ENABLED:
+ *
+ * Whether XPath is configured in
+ */
+#if 1
+#define LIBXML_XPATH_ENABLED
+#endif
+
+/**
+ * LIBXML_XPTR_ENABLED:
+ *
+ * Whether XPointer is configured in
+ */
+#if 1
+#define LIBXML_XPTR_ENABLED
+#endif
+
+/**
+ * LIBXML_XINCLUDE_ENABLED:
+ *
+ * Whether XInclude is configured in
+ */
+#if 1
+#define LIBXML_XINCLUDE_ENABLED
+#endif
+
+/**
+ * LIBXML_ICONV_ENABLED:
+ *
+ * Whether iconv support is available
+ */
+#if 0
+#define LIBXML_ICONV_ENABLED
+#endif
+
+/**
+ * LIBXML_ICU_ENABLED:
+ *
+ * Whether icu support is available
+ */
+#if 0
+#define LIBXML_ICU_ENABLED
+#endif
+
+/**
+ * LIBXML_ISO8859X_ENABLED:
+ *
+ * Whether ISO-8859-* support is made available in case iconv is not
+ */
+#if 1
+#define LIBXML_ISO8859X_ENABLED
+#endif
+
+/**
+ * LIBXML_DEBUG_ENABLED:
+ *
+ * Whether Debugging module is configured in
+ */
+#if 1
+#define LIBXML_DEBUG_ENABLED
+#endif
+
+/**
+ * DEBUG_MEMORY_LOCATION:
+ *
+ * Whether the memory debugging is configured in
+ */
+#if 0
+#define DEBUG_MEMORY_LOCATION
+#endif
+
+/**
+ * LIBXML_DEBUG_RUNTIME:
+ *
+ * Whether the runtime debugging is configured in
+ */
+#if 0
+#define LIBXML_DEBUG_RUNTIME
+#endif
+
+/**
+ * LIBXML_UNICODE_ENABLED:
+ *
+ * Whether the Unicode related interfaces are compiled in
+ */
+#if 1
+#define LIBXML_UNICODE_ENABLED
+#endif
+
+/**
+ * LIBXML_REGEXP_ENABLED:
+ *
+ * Whether the regular expressions interfaces are compiled in
+ */
+#if 1
+#define LIBXML_REGEXP_ENABLED
+#endif
+
+/**
+ * LIBXML_AUTOMATA_ENABLED:
+ *
+ * Whether the automata interfaces are compiled in
+ */
+#if 1
+#define LIBXML_AUTOMATA_ENABLED
+#endif
+
+/**
+ * LIBXML_EXPR_ENABLED:
+ *
+ * Whether the formal expressions interfaces are compiled in
+ *
+ * This code is unused and disabled unconditionally for now.
+ */
+#if 0
+#define LIBXML_EXPR_ENABLED
+#endif
+
+/**
+ * LIBXML_SCHEMAS_ENABLED:
+ *
+ * Whether the Schemas validation interfaces are compiled in
+ */
+#if 1
+#define LIBXML_SCHEMAS_ENABLED
+#endif
+
+/**
+ * LIBXML_SCHEMATRON_ENABLED:
+ *
+ * Whether the Schematron validation interfaces are compiled in
+ */
+#if 1
+#define LIBXML_SCHEMATRON_ENABLED
+#endif
+
+/**
+ * LIBXML_MODULES_ENABLED:
+ *
+ * Whether the module interfaces are compiled in
+ */
+#if 1
+#define LIBXML_MODULES_ENABLED
+/**
+ * LIBXML_MODULE_EXTENSION:
+ *
+ * the string suffix used by dynamic modules (usually shared libraries)
+ */
+#define LIBXML_MODULE_EXTENSION ""
+#endif
+
+/**
+ * LIBXML_ZLIB_ENABLED:
+ *
+ * Whether the Zlib support is compiled in
+ */
+#if 0
+#define LIBXML_ZLIB_ENABLED
+#endif
+
+/**
+ * LIBXML_LZMA_ENABLED:
+ *
+ * Whether the Lzma support is compiled in
+ */
+#if 0
+#define LIBXML_LZMA_ENABLED
+#endif
+
+#ifdef __GNUC__
+
+/**
+ * ATTRIBUTE_UNUSED:
+ *
+ * Macro used to signal to GCC unused function parameters
+ */
+
+#ifndef ATTRIBUTE_UNUSED
+# if ((__GNUC__ > 2) || ((__GNUC__ == 2) && (__GNUC_MINOR__ >= 7)))
+# define ATTRIBUTE_UNUSED __attribute__((unused))
+# else
+# define ATTRIBUTE_UNUSED
+# endif
+#endif
+
+/**
+ * LIBXML_ATTR_ALLOC_SIZE:
+ *
+ * Macro used to indicate to GCC this is an allocator function
+ */
+
+#ifndef LIBXML_ATTR_ALLOC_SIZE
+# if (!defined(__clang__) && ((__GNUC__ > 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 3))))
+# define LIBXML_ATTR_ALLOC_SIZE(x) __attribute__((alloc_size(x)))
+# else
+# define LIBXML_ATTR_ALLOC_SIZE(x)
+# endif
+#else
+# define LIBXML_ATTR_ALLOC_SIZE(x)
+#endif
+
+/**
+ * LIBXML_ATTR_FORMAT:
+ *
+ * Macro used to indicate to GCC the parameter are printf like
+ */
+
+#ifndef LIBXML_ATTR_FORMAT
+# if ((__GNUC__ > 3) || ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 3)))
+# define LIBXML_ATTR_FORMAT(fmt,args) __attribute__((__format__(__printf__,fmt,args)))
+# else
+# define LIBXML_ATTR_FORMAT(fmt,args)
+# endif
+#else
+# define LIBXML_ATTR_FORMAT(fmt,args)
+#endif
+
+#else /* ! __GNUC__ */
+/**
+ * ATTRIBUTE_UNUSED:
+ *
+ * Macro used to signal to GCC unused function parameters
+ */
+#define ATTRIBUTE_UNUSED
+/**
+ * LIBXML_ATTR_ALLOC_SIZE:
+ *
+ * Macro used to indicate to GCC this is an allocator function
+ */
+#define LIBXML_ATTR_ALLOC_SIZE(x)
+/**
+ * LIBXML_ATTR_FORMAT:
+ *
+ * Macro used to indicate to GCC the parameter are printf like
+ */
+#define LIBXML_ATTR_FORMAT(fmt,args)
+#endif /* __GNUC__ */
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+#endif
+
+
diff --git a/build/sqlite3/BUILD.gn b/build/sqlite3/BUILD.gn
new file mode 100644
index 0000000000000000000000000000000000000000..fdb8aca0adadc1a411d2483158c59001a761efff
--- /dev/null
+++ b/build/sqlite3/BUILD.gn
@@ -0,0 +1,26 @@
+# 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("//build/ohos.gni")
+ohos_static_library("restool_sqlite") {
+ sources = [
+ "//third_party/sqlite/src/sqlite3.c"
+ ]
+
+ include_dirs = [
+ "//third_party/sqlite/include"
+ ]
+
+ subsystem_name = "developtools"
+ part_name = "global_restool"
+}
\ No newline at end of file
diff --git a/third_party/sqlite3/CMakeLists.txt b/build/sqlite3/CMakeLists.txt
similarity index 100%
rename from third_party/sqlite3/CMakeLists.txt
rename to build/sqlite3/CMakeLists.txt
diff --git a/bundle.json b/bundle.json
new file mode 100644
index 0000000000000000000000000000000000000000..44c574a5b72ad58037a04fce6bebebcd244ff41d
--- /dev/null
+++ b/bundle.json
@@ -0,0 +1,34 @@
+{
+ "name": "@ohos/restool",
+ "description": "OpenHarmony resource compile.",
+ "version": "3.1",
+ "license": "Apache License 2.0",
+ "pubiishAs": "code-segment",
+ "segment": {
+ "destPath": "developtools/global_resource_tool"
+ },
+ "dirs": {},
+ "scripts": {},
+ "component": {
+ "name": "restool",
+ "subsystem": "developtools",
+ "syscap": [],
+ "feature": [],
+ "adapted_system_type": ["mini", "small", "standard" ],
+ "deps": {
+ "components": [],
+ "third_party": [
+ "bounds_checking_function",
+ "libxml2",
+ "jsoncpp",
+ "sqlite"
+ ]
+ },
+ "build": {
+ "sub_component": [ "//developtools/global_resource_tool:restool" ],
+ "inner_kits": [],
+ "test": []
+ }
+ }
+ }
+
\ No newline at end of file
diff --git a/include/file_entry.h b/include/file_entry.h
new file mode 100644
index 0000000000000000000000000000000000000000..3d75161461bcab68a0088473625f49a3553e4be5
--- /dev/null
+++ b/include/file_entry.h
@@ -0,0 +1,71 @@
+/*
+ * 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 OHOS_RESTOOL_FILE_ENTRY_H
+#define OHOS_RESTOOL_FILE_ENTRY_H
+
+#include
+#include
+#include
+
+namespace OHOS {
+namespace Global {
+namespace Restool {
+class FileEntry {
+public:
+ class FilePath {
+ public:
+ FilePath(const std::string &path);
+ virtual ~FilePath();
+ FilePath Append(const std::string &path);
+ FilePath ReplaceExtension(const std::string &extension);
+ FilePath GetParent();
+ const std::string &GetPath() const;
+ const std::string &GetFilename() const;
+ const std::string &GetExtension() const;
+ const std::vector GetSegments() const;
+ private:
+ void Init();
+ void Format();
+ std::string filePath_;
+ std::string filename_;
+ std::string parent_;
+ std::string extension_;
+ };
+
+ FileEntry(const std::string &path);
+ virtual ~FileEntry();
+ bool Init();
+ const std::vector> GetChilds() const;
+ bool IsFile() const;
+ const FilePath &GetFilePath() const;
+ static bool Exist(const std::string &path);
+ static bool RemoveAllDir(const std::string &path);
+ static bool CreateDirs(const std::string &path);
+ static bool CopyFile(const std::string &src, const std::string &dst);
+ static bool IsDirectory(const std::string &path);
+
+private:
+ bool IsIgnore(const std::string &filename) const;
+ static bool RemoveAllDirInner(const FileEntry &entry);
+ static bool CreateDirsInner(const std::string &path, std::string::size_type offset);
+ FilePath filePath_;
+ bool isFile_;
+ static const std::string SEPARATE;
+};
+}
+}
+}
+#endif
\ No newline at end of file
diff --git a/include/resource_item.h b/include/resource_item.h
index bf7a84235579e5565a5d42783bb3053443dd40b2..835199faeab84b7a150aebac80d0fe7d40d8158e 100644
--- a/include/resource_item.h
+++ b/include/resource_item.h
@@ -35,7 +35,7 @@ public:
void SetLimitKey(const std::string &limitKey);
const int8_t *GetData() const;
- const uint32_t GetDataLength() const;
+ uint32_t GetDataLength() const;
const std::string &GetName() const;
const ResType &GetResType() const;
const std::vector &GetKeyParam() const;
diff --git a/include/resource_util.h b/include/resource_util.h
index 73e775cfca7b18fabf975a0f8502b7fe3df41ca8..8a17b7f725c20f53d4cd95e47c3d7bbdea6153a2 100644
--- a/include/resource_util.h
+++ b/include/resource_util.h
@@ -16,7 +16,6 @@
#ifndef OHOS_RESTOOL_RESOURCE_UTIL_H
#define OHOS_RESTOOL_RESOURCE_UTIL_H
-#include
#include
#include "resource_data.h"
#include "json/json.h"
@@ -126,9 +125,10 @@ public:
/**
* @brief ignore file or directory
* @param filename: file or directory name
+ * @param isFile: ture if is file, other false
* @return true if ignore, other false
*/
- static bool IsIgnoreFile(const std::string &filename, std::filesystem::file_type type);
+ static bool IsIgnoreFile(const std::string &filename, bool isFile);
/**
* @brief need convert to solid xml
diff --git a/src/cmd_parser.cpp b/src/cmd_parser.cpp
index 9cc94d490922c9356bebfaa4c5659e27fc593f31..e39dd30df71168a2b0e2ad226e022c10c3413679 100644
--- a/src/cmd_parser.cpp
+++ b/src/cmd_parser.cpp
@@ -153,7 +153,6 @@ uint32_t PackageParser::ForceWrite()
uint32_t PackageParser::PrintVersion()
{
cout << "Info: Restool version= " << RESTOOL_VERSION << endl;
- cout << "time = (" << __DATE__ << " " << __TIME__ << ")" << endl;
exit(RESTOOL_SUCCESS);
return RESTOOL_SUCCESS;
}
diff --git a/src/file_entry.cpp b/src/file_entry.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..f301c0b1dd1489938db32a84dc14c9ff25269bb7
--- /dev/null
+++ b/src/file_entry.cpp
@@ -0,0 +1,271 @@
+/*
+ * 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 "file_entry.h"
+#include
+#include
+#include "dirent.h"
+#include "sys/stat.h"
+#include "unistd.h"
+
+namespace OHOS {
+namespace Global {
+namespace Restool {
+#ifdef _WIN32
+const std::string FileEntry::SEPARATE = "\\";
+#else
+const std::string FileEntry::SEPARATE = "/";
+#endif
+
+using namespace std;
+FileEntry::FileEntry(const string &path)
+ : filePath_(path), isFile_(false)
+{
+}
+
+FileEntry::~FileEntry()
+{
+}
+
+bool FileEntry::Init()
+{
+ string filePath = filePath_.GetPath();
+ if (!Exist(filePath)) {
+ cerr << "Error: '" << filePath << "' not exists." << endl;
+ return false;
+ }
+
+ isFile_ = !IsDirectory(filePath);
+ return true;
+}
+
+const vector> FileEntry::GetChilds() const
+{
+ vector> children;
+ struct dirent *entry;
+ string filePath = filePath_.GetPath();
+ DIR *handle = opendir(filePath.c_str());
+ while ((entry = readdir(handle)) != nullptr) {
+ string filename(entry->d_name);
+ if (IsIgnore(filename)) {
+ continue;
+ }
+
+ filePath = filePath_.GetPath() + SEPARATE + filename;
+ unique_ptr f = make_unique(filePath);
+ cout << filePath << endl;
+ f->Init();
+ children.push_back(move(f));
+ }
+ closedir(handle);
+ return children;
+}
+
+bool FileEntry::IsFile() const
+{
+ return isFile_;
+}
+
+const FileEntry::FilePath &FileEntry::GetFilePath() const
+{
+ return filePath_;
+}
+
+bool FileEntry::Exist(const string &path)
+{
+ struct stat s;
+ if (stat(path.c_str(), &s) != 0) {
+ return false;
+ }
+ return true;
+}
+
+bool FileEntry::RemoveAllDir(const string &path)
+{
+ FileEntry f(path);
+ if (!f.Init()) {
+ return false;
+ }
+
+ if (f.IsFile()) {
+ cerr << "Error: RemoveAllDir '" << path << "' not directory." << endl;
+ return false;
+ }
+ return RemoveAllDirInner(f);
+}
+
+bool FileEntry::CreateDirs(const string &path)
+{
+ return CreateDirsInner(path, 0);
+}
+
+bool FileEntry::CopyFile(const string &src, const string &dst)
+{
+ ifstream in(src, ios::binary);
+ ofstream out(dst, ios::binary);
+ if (!in || !out) {
+ cerr << "Error: CopyFile '" << src << "' or '" << dst << "' open fail." << endl;
+ return false;
+ }
+ out << in.rdbuf();
+ return true;
+}
+
+bool FileEntry::IsDirectory(const string &path)
+{
+ struct stat s;
+ stat(path.c_str(), &s);
+ return S_ISDIR(s.st_mode);
+}
+
+FileEntry::FilePath::FilePath(const string &path) : filePath_(path)
+{
+ Format();
+ Init();
+}
+
+FileEntry::FilePath::~FilePath()
+{
+}
+
+FileEntry::FilePath FileEntry::FilePath::Append(const string &path)
+{
+ Format();
+ string filePath = filePath_ + SEPARATE + path;
+ return FilePath(filePath);
+}
+
+FileEntry::FilePath FileEntry::FilePath::ReplaceExtension(const string &extension)
+{
+ string filePath;
+ if (!parent_.empty()) {
+ filePath += parent_ + SEPARATE;
+ }
+
+ filePath += filename_.substr(0, filename_.length() - extension_.length()) + extension;
+ return FilePath(filePath);
+}
+
+FileEntry::FilePath FileEntry::FilePath::GetParent()
+{
+ return FilePath(parent_);
+}
+
+const string &FileEntry::FilePath::GetPath() const
+{
+ return filePath_;
+}
+
+const string &FileEntry::FilePath::GetFilename() const
+{
+ return filename_;
+}
+
+const string &FileEntry::FilePath::GetExtension() const
+{
+ return extension_;
+}
+
+const vector FileEntry::FilePath::GetSegments() const
+{
+ vector segments;
+ string::size_type offset = 0;
+ string::size_type pos = filePath_.find_first_of(SEPARATE.front(), offset);
+ while (pos != string::npos) {
+ segments.push_back(filePath_.substr(offset, pos - offset));
+ offset = pos + 1;
+ pos = filePath_.find_first_of(SEPARATE.front(), offset);
+ }
+
+ if (offset < filePath_.length()) {
+ segments.push_back(filePath_.substr(offset));
+ }
+ return segments;
+}
+
+// below private
+bool FileEntry::IsIgnore(const string &filename) const
+{
+ if (filename == "." || filename == "..") {
+ return true;
+ }
+ return false;
+}
+
+bool FileEntry::RemoveAllDirInner(const FileEntry &entry)
+{
+ if (entry.IsFile()) {
+ return remove(entry.GetFilePath().GetPath().c_str()) == 0;
+ }
+
+ for (const auto &iter : entry.GetChilds()) {
+ if (!RemoveAllDirInner(*iter)) {
+ return false;
+ }
+ }
+ return rmdir(entry.GetFilePath().GetPath().c_str()) == 0;
+}
+
+bool FileEntry::CreateDirsInner(const string &path, string::size_type offset)
+{
+ string::size_type pos = path.find_first_of(SEPARATE.front(), offset);
+ if (pos == string::npos) {
+#if _WIN32
+ return mkdir(path.c_str());
+ #else
+ return mkdir(path.c_str(), S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH) == 0;
+#endif
+ }
+
+ string subPath = path.substr(0, pos);
+ if (!Exist(subPath)) {
+#if _WIN32
+ if (mkdir(subPath.c_str()) != 0) {
+#else
+ if (mkdir(subPath.c_str(), S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH) != 0) {
+#endif
+ return false;
+ }
+ }
+ return CreateDirsInner(path, pos + 1);
+}
+
+void FileEntry::FilePath::Format()
+{
+ if (filePath_.back() != SEPARATE.front()) {
+ return;
+ }
+ filePath_.pop_back();
+}
+
+void FileEntry::FilePath::Init()
+{
+ filename_ = filePath_;
+ string::size_type pos = filePath_.find_last_of(SEPARATE.front());
+ if (pos != string::npos) {
+ parent_ = filePath_.substr(0, pos);
+ if (pos + 1 < filePath_.length()) {
+ filename_ = filePath_.substr(pos + 1);
+ }
+ }
+
+ pos = filename_.find_last_of('.');
+ if (pos != string::npos && pos + 1 < filename_.length()) {
+ extension_ = filename_.substr(pos);
+ }
+}
+}
+}
+}
\ No newline at end of file
diff --git a/src/file_manager.cpp b/src/file_manager.cpp
index c8f0fbf454a2790a048bdcf9c0efadd614b04693..8ed66e1fd5a1ba1dabbf717cf0ca9cefba380a9a 100644
--- a/src/file_manager.cpp
+++ b/src/file_manager.cpp
@@ -15,9 +15,9 @@
#include "file_manager.h"
#include
-#include
#include
#include "factory_resource_compiler.h"
+#include "file_entry.h"
#include "key_parser.h"
#include "reference_parser.h"
#include "resource_directory.h"
@@ -97,8 +97,8 @@ void FileManager::FilterRefSolidXml(const string &output, vector &output
continue;
}
for (const auto &resourceDir : iter.second) {
- string outputPath = filesystem::path(output).append(RESOURCES_DIR).append(resourceDir.limitKey)
- .append(resourceDir.fileCluster).string();
+ string outputPath = FileEntry::FilePath(output).Append(RESOURCES_DIR).Append(resourceDir.limitKey)
+ .Append(resourceDir.fileCluster).GetPath();
if (find(outputPaths.begin(), outputPaths.end(), outputPath) == outputPaths.end()) {
outputPaths.push_back(outputPath);
}
diff --git a/src/generic_compiler.cpp b/src/generic_compiler.cpp
index 96f1646dc3b4732e720b9924e6d912eb710eef76..3dd5e26603da1d6f2396a3849d00ed63da172e4e 100644
--- a/src/generic_compiler.cpp
+++ b/src/generic_compiler.cpp
@@ -14,8 +14,8 @@
*/
#include "generic_compiler.h"
-#include
#include
+#include "file_entry.h"
#include "resource_util.h"
#include "restool_errors.h"
@@ -55,7 +55,7 @@ bool GenericCompiler::PostFile(const FileInfo &fileInfo)
string data = fileInfo.filename;
if (IsConvertToSolidXml(fileInfo)) {
- data = filesystem::path(data).replace_extension(".sxml").string();
+ data = FileEntry::FilePath(data).ReplaceExtension(".sxml").GetPath();
}
data = moduleName_ + SEPARATOR + RESOURCES_DIR + SEPARATOR + \
fileInfo.limitKey + SEPARATOR + fileInfo.fileCluster + SEPARATOR + data;
@@ -69,7 +69,7 @@ bool GenericCompiler::PostFile(const FileInfo &fileInfo)
string GenericCompiler::GetOutputFilePath(const FileInfo &fileInfo) const
{
string outputFolder = GetOutputFolder(fileInfo);
- string outputFilePath = filesystem::path(outputFolder).append(fileInfo.filename).string();
+ string outputFilePath = FileEntry::FilePath(outputFolder).Append(fileInfo.filename).GetPath();
return outputFilePath;
}
diff --git a/src/i_resource_compiler.cpp b/src/i_resource_compiler.cpp
index 2956486dd4bc875d2b0a4860128d56b9a159c7f4..09b0edcba3b4ac1f4f5b29ab124d6d9e28dc4aef 100644
--- a/src/i_resource_compiler.cpp
+++ b/src/i_resource_compiler.cpp
@@ -14,8 +14,9 @@
*/
#include "i_resource_compiler.h"
-#include
+#include
#include
+#include "file_entry.h"
#include "id_worker.h"
#include "resource_util.h"
#include "restool_errors.h"
@@ -43,17 +44,21 @@ uint32_t IResourceCompiler::Compile(const vector &directoryInfos)
map> setsByDirectory;
for (const auto &directoryInfo : directoryInfos) {
string outputFolder = GetOutputFolder(directoryInfo);
- for (const auto &it : filesystem::directory_iterator(directoryInfo.dirPath)) {
- if (ResourceUtil::IsIgnoreFile(it.path().filename().string(), it.status().type())) {
+ FileEntry f(directoryInfo.dirPath);
+ if (!f.Init()) {
+ return RESTOOL_ERROR;
+ }
+ for (const auto &it : f.GetChilds()) {
+ if (ResourceUtil::IsIgnoreFile(it->GetFilePath().GetFilename(), it->IsFile())) {
continue;
}
- if (it.is_directory()) {
- cout << "Error: '" << it.path().string() << "' not regular." << endl;
+ if (!it->IsFile()) {
+ cout << "Error: '" << it->GetFilePath().GetPath() << "' not regular." << endl;
return RESTOOL_ERROR;
}
- FileInfo fileInfo = { directoryInfo, it.path().string(), it.path().filename().string() };
+ FileInfo fileInfo = { directoryInfo, it->GetFilePath().GetPath(), it->GetFilePath().GetFilename() };
fileInfos.push_back(fileInfo);
setsByDirectory[outputFolder].push_back(fileInfo);
}
@@ -63,6 +68,7 @@ uint32_t IResourceCompiler::Compile(const vector &directoryInfos)
return a.filePath < b.filePath;
});
for (const auto &fileInfo : fileInfos) {
+ cout << "compile " << fileInfo.filePath << endl;
if (CompileSingleFile(fileInfo) != RESTOOL_SUCCESS) {
return RESTOOL_ERROR;
}
@@ -93,8 +99,8 @@ uint32_t IResourceCompiler::Compile(const FileInfo &fileInfo)
}
map> setsByDirectory;
if (NeedIfConvertToSolidXml()) {
- string outputFolder = filesystem::path(output_).append(RESOURCES_DIR)
- .append(fileInfo.limitKey).append(fileInfo.fileCluster).string();
+ string outputFolder = FileEntry::FilePath(output_).Append(RESOURCES_DIR)
+ .Append(fileInfo.limitKey).Append(fileInfo.fileCluster).GetPath();
setsByDirectory[outputFolder].push_back(fileInfo);
}
@@ -201,7 +207,7 @@ void IResourceCompiler::ListXmlFile(const vector &fileInfos, vector
#include
#include
#include "cmd_parser.h"
+#include "file_entry.h"
namespace OHOS {
namespace Global {
@@ -173,8 +173,8 @@ uint32_t IdWorker::InitIdDefined()
string idDefinedPath;
if (type_ == ResourceIdCluster::RES_ID_SYS) {
for (const auto &inputPath : packageParser.GetInputs()) {
- idDefinedPath = filesystem::path(inputPath).append(RESOURCES_DIR)
- .append("base").append("element").append(ID_DEFINED_FILE).string();
+ idDefinedPath = FileEntry::FilePath(inputPath).Append(RESOURCES_DIR)
+ .Append("base").Append("element").Append(ID_DEFINED_FILE).GetPath();
if (InitIdDefined(idDefinedPath) != RESTOOL_SUCCESS) {
return RESTOOL_ERROR;
}
@@ -182,7 +182,7 @@ uint32_t IdWorker::InitIdDefined()
return RESTOOL_SUCCESS;
}
- idDefinedPath = filesystem::path(packageParser.GetRestoolPath()).parent_path().append(ID_DEFINED_FILE).string();
+ idDefinedPath = FileEntry::FilePath(packageParser.GetRestoolPath()).GetParent().Append(ID_DEFINED_FILE).GetPath();
if (InitIdDefined(idDefinedPath) != RESTOOL_SUCCESS) {
return RESTOOL_ERROR;
}
diff --git a/src/increment_list.cpp b/src/increment_list.cpp
index 1f9c65927b8e122792c3ef075ffd4daa9687bba2..9c4dd4ffcef291a6fa76272a4aad00885f331885 100644
--- a/src/increment_list.cpp
+++ b/src/increment_list.cpp
@@ -15,8 +15,8 @@
#include "increment_list.h"
#include
-#include
#include
+#include "file_entry.h"
#include "key_parser.h"
namespace OHOS {
@@ -52,14 +52,14 @@ bool IncrementList::GetFromPath(const string &filePath, FileIncrement &info) con
return false;
}
info.rootPath = folder_[priority];
- string rootPath = filesystem::path(info.rootPath).append("").string();
+ string rootPath = FileEntry::FilePath(info.rootPath).Append("").GetPath();
info.relativePath = filePath.substr(rootPath.length());
vector segments;
if (!ParseSegment(info.relativePath, segments)) {
return false;
}
- info.dirPath = filesystem::path(filePath).parent_path().string();
+ info.dirPath = FileEntry::FilePath(filePath).GetParent().GetPath();
info.filePath = filePath;
info.limitKey = segments[SEG_LIMIT_KEY];
if (info.limitKey == RAW_FILE_DIR) {
@@ -84,7 +84,7 @@ bool IncrementList::GetFromPath(const string &filePath, FileIncrement &info) con
int32_t IncrementList::GetPriority(const string &filePath) const
{
auto result = find_if(folder_.begin(), folder_.end(), [&filePath](auto &iter) {
- string rootPath = filesystem::path(iter).append("").string();
+ string rootPath = FileEntry::FilePath(iter).Append("").GetPath();
if (filePath.length() <= rootPath.length()) {
return false;
}
@@ -101,8 +101,8 @@ int32_t IncrementList::GetPriority(const string &filePath) const
bool IncrementList::ParseSegment(const string &filePath, vector &segments) const
{
- for (const auto &it : filesystem::path(filePath)) {
- segments.push_back(it.string());
+ for (const auto &it : FileEntry::FilePath(filePath).GetSegments()) {
+ segments.push_back(it);
}
if (segments.size() >= (SEG_RESOURCE + 1) && segments[SEG_RESOURCE] != RESOURCES_DIR) {
diff --git a/src/increment_manager.cpp b/src/increment_manager.cpp
index 625f7d559d1d3294819197e3e06b61adfc5a9f78..c834a2538a218e6eb2f1058f9d10cad5943c944c 100644
--- a/src/increment_manager.cpp
+++ b/src/increment_manager.cpp
@@ -16,14 +16,14 @@
#include "increment_manager.h"
#include
#include
+#include "file_entry.h"
#include "id_worker.h"
#include "key_parser.h"
+#include "module_combine.h"
+#include "resource_module_inc.h"
#include "restool_errors.h"
#include "xml_key_node.h"
-#include "resource_module_inc.h"
-#include "module_combine.h"
-
namespace OHOS {
namespace Global {
namespace Restool {
@@ -65,7 +65,7 @@ uint32_t IncrementManager::Init(const string &cachePath, const vector &d
for (auto &iter : moduleInfos) {
string pathHash = ResourceUtil::GenerateHash(iter.rootPath);
- string moduleCachePath = filesystem::path(cachePath_).append(pathHash).string();
+ string moduleCachePath = FileEntry::FilePath(cachePath_).Append(pathHash).GetPath();
ResourceModuleInc resourceModuleInc(iter.rootPath, moduleCachePath, moduleName_, folder_);
if (FirstIncrement()) {
if (resourceModuleInc.ResourceModule::ScanResource() != RESTOOL_SUCCESS) {
@@ -125,7 +125,7 @@ bool IncrementManager::ScanModules(const vector &d
bool IncrementManager::InitList(vector &dels) const
{
- string listPath = filesystem::path(cachePath_).append(IncrementList::RESTOOL_LIST_FILE).string();
+ string listPath = FileEntry::FilePath(cachePath_).Append(IncrementList::RESTOOL_LIST_FILE).GetPath();
if (!ResourceUtil::FileExist(listPath)) {
return true;
}
@@ -158,7 +158,7 @@ bool IncrementManager::SaveIdJson() const
root[to_string(iter.first)] = node;
}
- string idJsonPath = filesystem::path(cachePath_).append(ID_JSON_FILE).string();
+ string idJsonPath = FileEntry::FilePath(cachePath_).Append(ID_JSON_FILE).GetPath();
if (!ResourceUtil::SaveToJsonFile(idJsonPath, root)) {
return false;
}
@@ -168,7 +168,7 @@ bool IncrementManager::SaveIdJson() const
bool IncrementManager::LoadIdJson()
{
Json::Value root;
- string idJsonPath = filesystem::path(cachePath_).append(ID_JSON_FILE).string();
+ string idJsonPath = FileEntry::FilePath(cachePath_).Append(ID_JSON_FILE).GetPath();
if (!ResourceUtil::OpenJsonFile(idJsonPath, root)) {
return false;
}
@@ -229,15 +229,15 @@ void IncrementManager::DeleteRawFile(vector &dels)
it++;
continue;
}
- string rawFilePath = filesystem::path(outputPath_).append(it->relativePath).string();
- filesystem::remove(rawFilePath);
+ string rawFilePath = FileEntry::FilePath(outputPath_).Append(it->relativePath).GetPath();
+ remove(rawFilePath.c_str());
it = dels.erase(it);
}
}
bool IncrementManager::ClearSolidXml() const
{
- string resourceDir = filesystem::path(outputPath_).append(RESOURCES_DIR).string();
+ string resourceDir = FileEntry::FilePath(outputPath_).Append(RESOURCES_DIR).GetPath();
if (!ResourceUtil::FileExist(resourceDir)) {
return true;
}
@@ -248,19 +248,24 @@ bool IncrementManager::ClearSolidXml() const
return true;
}
- for (const auto &entry : filesystem::directory_iterator(info.dirPath)) {
- if (entry.is_directory()) {
- cerr << "Error: '" << entry.path().string() << "' is directroy." << endl;
+ FileEntry f(info.dirPath);
+ if (!f.Init()) {
+ return false;
+ }
+
+ for (const auto &entry : f.GetChilds()) {
+ if (!entry->IsFile()) {
+ cerr << "Error: '" << entry->GetFilePath().GetPath() << "' is directroy." << endl;
return false;
}
- string extension = entry.path().extension().string();
+ string extension = entry->GetFilePath().GetExtension();
if (extension != ".sxml" && extension != ".key" && extension != ".json") {
continue;
}
- if (!filesystem::remove(entry.path().string())) {
- cerr << "Error: remove '" << entry.path().string() << "' fail." << endl;
+ if (remove(entry->GetFilePath().GetPath().c_str()) != 0) {
+ cerr << "Error: remove '" << entry->GetFilePath().GetPath() << "' fail." << endl;
return false;
}
}
@@ -270,39 +275,6 @@ bool IncrementManager::ClearSolidXml() const
}
return true;
}
-/*
-{
- "0x01000000":
- {
- "name":"xxxxx",
- "type":"string"
- }
-}
-{
- "header":{
- "folder":["xxxx", "xxxx", "xxxx", "xxxx"]
- },
- "index":{
- "0x01000000":{
- "filepath":{
- "data":"xxxx",
- "name":"xxxx",
- "type":"xxxx",
- "limitkey":"xxxx"
- }
- },
- }
-}
-
-{
- "del":[
- "xx/xx/xx/xxx"
- ],
- "fix":[
- "xxx/xxx/xx"
- ]
-}
-*/
}
}
}
\ No newline at end of file
diff --git a/src/module_combine.cpp b/src/module_combine.cpp
index 5cfaa9bf2fc93b8e44fd3d5637b66cefc8c6654d..81ae75a23d0931f78720aeaebf5bdae3efc088b4 100644
--- a/src/module_combine.cpp
+++ b/src/module_combine.cpp
@@ -15,8 +15,8 @@
#include "module_combine.h"
#include
-#include
#include
+#include "file_entry.h"
#include "key_manager.h"
#include "resource_util.h"
#include "solid_xml.h"
@@ -32,7 +32,7 @@ ModuleCombine::ModuleCombine(const string &modulePath, const string &outputPath)
bool ModuleCombine::Combine()
{
- string resourceDir = filesystem::path(modulePath_).append(RESOURCES_DIR).string();
+ string resourceDir = FileEntry::FilePath(modulePath_).Append(RESOURCES_DIR).GetPath();
ResourceDirectory resourceDirectory;
if (!resourceDirectory.ScanResources(resourceDir, [this](const DirectoryInfo &info) -> bool {
return CombineDirectory(info);
@@ -45,27 +45,31 @@ bool ModuleCombine::Combine()
// below private
bool ModuleCombine::CombineDirectory(const DirectoryInfo &directoryInfo)
{
- string outputFolder = filesystem::path(outputPath_).append(RESOURCES_DIR)
- .append(directoryInfo.limitKey).append(directoryInfo.fileCluster).string();
+ string outputFolder = FileEntry::FilePath(outputPath_).Append(RESOURCES_DIR)
+ .Append(directoryInfo.limitKey).Append(directoryInfo.fileCluster).GetPath();
if (!ResourceUtil::CreateDirs(outputFolder)) {
return false;
}
map sxmlPaths;
- for (const auto &entry : filesystem::directory_iterator(directoryInfo.dirPath)) {
- string src = entry.path().string();
- if (entry.is_directory()) {
+ FileEntry f(directoryInfo.dirPath);
+ if (!f.Init()) {
+ return false;
+ }
+ for (const auto &entry : f.GetChilds()) {
+ string src = entry->GetFilePath().GetPath();
+ if (!entry->IsFile()) {
cerr << "Error: " << src << " is directory." << endl;
return false;
}
- string filename = entry.path().filename().string();
- string dst = filesystem::path(outputFolder).append(filename).string();
+ string filename = entry->GetFilePath().GetFilename();
+ string dst = FileEntry::FilePath(outputFolder).Append(filename).GetPath();
if (ResourceUtil::FileExist(dst)) {
continue;
}
- if (entry.path().extension().string() == ".sxml") {
+ if (entry->GetFilePath().GetExtension() == ".sxml") {
sxmlPaths.emplace(src, dst);
continue;
}
diff --git a/src/preview_manager.cpp b/src/preview_manager.cpp
index 099265e7f62908305c371a09aaedd8382d15a90a..5814855a2983a19045b722501b7793fe7b9f10ea 100644
--- a/src/preview_manager.cpp
+++ b/src/preview_manager.cpp
@@ -14,9 +14,9 @@
*/
#include "preview_manager.h"
-#include
#include
#include "factory_resource_compiler.h"
+#include "file_entry.h"
#include "key_parser.h"
#include "resource_module.h"
#include "resource_util.h"
@@ -36,7 +36,7 @@ uint32_t PreviewManager::ScanModules(const vector &modulePaths, const st
{
SqliteDatabase &database = SqliteDatabase::GetInstance();
- string dbPath = filesystem::path(output).append("resources.db").string();
+ string dbPath = FileEntry::FilePath(output).Append("resources.db").GetPath();
database.Init(dbPath);
if(!database.OpenDatabase()) {
return RESTOOL_ERROR;
@@ -48,7 +48,7 @@ uint32_t PreviewManager::ScanModules(const vector &modulePaths, const st
}
for (const auto &iter : modulePaths) {
- if (filesystem::is_directory(iter)) {
+ if (FileEntry::IsDirectory(iter)) {
ResourceModule resourceMoudle(iter, output, "");
resourceMoudle.SetPreviewMode(true);
database.SetPriority(priority);
@@ -74,10 +74,10 @@ bool PreviewManager::ScanFile(const string &filePath, int32_t priority)
}
FileInfo fileInfo;
fileInfo.filePath = filePath;
- fileInfo.filename = filesystem::path(filePath).filename().string();
- fileInfo.dirPath = filesystem::path(filePath).parent_path().string();
- fileInfo.fileCluster = filesystem::path(fileInfo.dirPath).filename().string();
- fileInfo.limitKey = filesystem::path(fileInfo.dirPath).parent_path().filename().string();
+ fileInfo.filename = FileEntry::FilePath(filePath).GetFilename();
+ fileInfo.dirPath = FileEntry::FilePath(filePath).GetParent().GetPath();
+ fileInfo.fileCluster = FileEntry::FilePath(fileInfo.dirPath).GetFilename();
+ fileInfo.limitKey = FileEntry::FilePath(fileInfo.dirPath).GetParent().GetFilename();
fileInfo.dirType = ResourceUtil::GetResTypeByDir(fileInfo.fileCluster);
if (fileInfo.dirType == ResType::INVALID_RES_TYPE) {
diff --git a/src/reference_parser.cpp b/src/reference_parser.cpp
index 3c005328a82d3320f8c7ad05c51470f0db5bc7ad..abc55b3a25efb80f8748a2b425de339074d844de 100644
--- a/src/reference_parser.cpp
+++ b/src/reference_parser.cpp
@@ -16,6 +16,7 @@
#include "reference_parser.h"
#include
#include
+#include "file_entry.h"
#include "restool_errors.h"
#include "xml_key_node.h"
@@ -66,8 +67,8 @@ ReferenceParser::~ReferenceParser()
uint32_t ReferenceParser::ParseRefInSolidXml(const vector &solidXmlFolders) const
{
for (const auto &solidXmlFolder : solidXmlFolders) {
- string filePath = filesystem::path(solidXmlFolder)
- .append(XmlKeyNode::KEY_TO_FILE_NAME.at(XmlKeyNode::KeyType::CONSTANT)).string();
+ string filePath = FileEntry::FilePath(solidXmlFolder)
+ .Append(XmlKeyNode::KEY_TO_FILE_NAME.at(XmlKeyNode::KeyType::CONSTANT)).GetPath();
if (!ResourceUtil::FileExist(filePath)) {
continue;
}
@@ -111,22 +112,23 @@ uint32_t ReferenceParser::ParseRefInString(string &value, bool &update) const
uint32_t ReferenceParser::ParseRefInProfile(const string &output) const
{
- string profileFolder = filesystem::path(output).append(RESOURCES_DIR).append("base").append("profile").string();
+ string profileFolder = FileEntry::FilePath(output).Append(RESOURCES_DIR).Append("base").Append("profile").GetPath();
if (!ResourceUtil::FileExist(profileFolder)) {
return RESTOOL_SUCCESS;
}
- for (const auto &entry : filesystem::directory_iterator(profileFolder)) {
- if (entry.is_directory()) {
- cerr << "Error: '" << entry.path().string() << "' is directory." << endl;
+ FileEntry f(profileFolder);
+ for (const auto &entry : f.GetChilds()) {
+ if (!entry->IsFile()) {
+ cerr << "Error: '" << entry->GetFilePath().GetPath() << "' is directory." << endl;
return false;
}
- if (entry.path().extension() != ".json" ) {
+ if (entry->GetFilePath().GetExtension() != ".json" ) {
continue;
}
- if (ParseRefInJson(entry.path().string()) != RESTOOL_SUCCESS) {
+ if (ParseRefInJson(entry->GetFilePath().GetPath()) != RESTOOL_SUCCESS) {
return RESTOOL_ERROR;
}
}
diff --git a/src/resource_directory.cpp b/src/resource_directory.cpp
index a92b3f9051b752a95c2d29c5e8d1cb752d7fb44d..c9a37ab702f8a7541b9b955d713cbe9a5f05b3e9 100644
--- a/src/resource_directory.cpp
+++ b/src/resource_directory.cpp
@@ -15,6 +15,7 @@
#include "resource_directory.h"
#include
+#include "file_entry.h"
#include "resource_util.h"
namespace OHOS {
@@ -23,14 +24,19 @@ namespace Restool {
using namespace std;
bool ResourceDirectory::ScanResources(const string &resourcesDir, function callback) const
{
- for (auto &it : filesystem::directory_iterator(resourcesDir)) {
- string limitKey = it.path().filename().string();
- if (ResourceUtil::IsIgnoreFile(limitKey, it.status().type())) {
+ FileEntry f(resourcesDir);
+ if (!f.Init()) {
+ return false;
+ }
+
+ for (const auto &it : f.GetChilds()) {
+ string limitKey = it->GetFilePath().GetFilename();
+ if (ResourceUtil::IsIgnoreFile(limitKey, it->IsFile())) {
continue;
}
- if (!it.is_directory()) {
- cerr << "Error: '" << it.path().string() << "' not directory." << endl;
+ if (it->IsFile()) {
+ cerr << "Error: '" << it->GetFilePath().GetPath() << "' not directory." << endl;
return false;
}
@@ -38,7 +44,7 @@ bool ResourceDirectory::ScanResources(const string &resourcesDir, functionGetFilePath().GetPath(), limitKey, callback)) {
return false;
}
}
@@ -55,14 +61,18 @@ bool ResourceDirectory::ScanResourceLimitKeyDir(const string &resourceTypeDir, c
return false;
}
- for (auto &it : filesystem::directory_iterator(resourceTypeDir)) {
- string dirPath = it.path().string();
- string fileCluster = it.path().filename().string();
- if (ResourceUtil::IsIgnoreFile(fileCluster, it.status().type())) {
+ FileEntry f(resourceTypeDir);
+ if (!f.Init()) {
+ return false;
+ }
+ for (const auto &it : f.GetChilds()) {
+ string dirPath = it->GetFilePath().GetPath();
+ string fileCluster = it->GetFilePath().GetFilename();
+ if (ResourceUtil::IsIgnoreFile(fileCluster, it->IsFile())) {
continue;
}
- if (!it.is_directory()) {
+ if (it->IsFile()) {
cerr << "Error: '" << dirPath << "' not directory." << endl;
return false;
}
diff --git a/src/resource_item.cpp b/src/resource_item.cpp
index c84a5f9890cb12f3317c1e62a849fd1ef665ead5..6db4b367d5f25ac1c218f15ef6cc8687bf249088 100644
--- a/src/resource_item.cpp
+++ b/src/resource_item.cpp
@@ -79,7 +79,7 @@ const int8_t *ResourceItem::GetData() const
return data_;
}
-const uint32_t ResourceItem::GetDataLength() const
+uint32_t ResourceItem::GetDataLength() const
{
return dataLen_;
}
diff --git a/src/resource_merge.cpp b/src/resource_merge.cpp
index ac62b0980908eab656fd61ffaf35738f22da80fd..80a12c91e1eda99c48755a82a08b63d3c680bdac 100644
--- a/src/resource_merge.cpp
+++ b/src/resource_merge.cpp
@@ -15,6 +15,7 @@
#include "resource_merge.h"
#include "cmd_parser.h"
+#include "file_entry.h"
namespace OHOS {
namespace Global {
@@ -46,8 +47,8 @@ uint32_t ResourceMerge::Init()
map> inputTypes;
for (auto it = inputs.crbegin(); it != inputs.crend(); it++) {
- string filePath = filesystem::path(*it).append(ConfigParser::GetConfigName()).string();
- string resourceDir = filesystem::path(*it).append(RESOURCES_DIR).string();
+ string filePath = FileEntry::FilePath(*it).Append(ConfigParser::GetConfigName()).GetPath();
+ string resourceDir = FileEntry::FilePath(*it).Append(RESOURCES_DIR).GetPath();
ConfigParser::ModuleType moduleType = ConfigParser::ModuleType::NONE;
if (!ResourceUtil::FileExist(filePath)) {
inputTypes[moduleType].push_back(resourceDir);
diff --git a/src/resource_module.cpp b/src/resource_module.cpp
index f21322c23e7c5ee0bb7af0e63d7fa609e98e53da..d01832148e30e6884269675aecb84acd15d202ef 100644
--- a/src/resource_module.cpp
+++ b/src/resource_module.cpp
@@ -14,7 +14,7 @@
*/
#include "resource_module.h"
-#include
+#include
#include
#include "factory_resource_compiler.h"
#include "restool_errors.h"
diff --git a/src/resource_module_inc.cpp b/src/resource_module_inc.cpp
index c1b503852a0f6338910553a694dd70386f89d1af..bd2451403d61ff3a2b539ada7f9644e02b668d18 100644
--- a/src/resource_module_inc.cpp
+++ b/src/resource_module_inc.cpp
@@ -14,9 +14,9 @@
*/
#include "resource_module_inc.h"
-#include
#include
#include "factory_resource_compiler.h"
+#include "file_entry.h"
#include "increment_index.h"
#include "restool_errors.h"
@@ -38,19 +38,19 @@ uint32_t ResourceModuleInc::ScanResource(const vector
-#include
+#include
+#include "file_entry.h"
#include "file_manager.h"
#include "header.h"
#include "increment_manager.h"
@@ -141,14 +142,14 @@ void ResourcePack::InitHeaderCreater()
uint32_t ResourcePack::InitOutput() const
{
string cachePath = packageParser_.GetCachePath();
- string indexPath = filesystem::path(cachePath).append(IncrementManager::ID_JSON_FILE).string();
+ string indexPath = FileEntry::FilePath(cachePath).Append(IncrementManager::ID_JSON_FILE).GetPath();
if (!cachePath.empty() && ResourceUtil::FileExist(indexPath)) {
return RESTOOL_SUCCESS;
}
bool forceWrite = packageParser_.GetForceWrite();
string output = packageParser_.GetOutput();
- string resourcesPath = filesystem::path(output).append(RESOURCES_DIR).string();
+ string resourcesPath = FileEntry::FilePath(output).Append(RESOURCES_DIR).GetPath();
if (ResourceUtil::FileExist(resourcesPath)) {
if (!forceWrite) {
cerr << "Error: output path '" << resourcesPath << "' exists." << endl;
@@ -165,10 +166,10 @@ uint32_t ResourcePack::InitOutput() const
uint32_t ResourcePack::GenerateHeader() const
{
auto headerPaths = packageParser_.GetResourceHeaders();
- string textPath = filesystem::path(packageParser_.GetOutput()).append("ResourceTable.txt").string();
+ string textPath = FileEntry::FilePath(packageParser_.GetOutput()).Append("ResourceTable.txt").GetPath();
headerPaths.push_back(textPath);
for (const auto &headerPath : headerPaths) {
- string extension = filesystem::path(headerPath).extension().string();
+ string extension = FileEntry::FilePath(headerPath).GetExtension();
auto it = headerCreaters_.find(extension);
if (it == headerCreaters_.end()) {
cout << "Warning: don't support header file format '" << headerPath << "'" << endl;
@@ -189,13 +190,13 @@ uint32_t ResourcePack::InitConfigJson()
cerr << "Error: more input path, -j config.json empty" << endl;
return RESTOOL_ERROR;
}
- config = filesystem::path(packageParser_.GetInputs()[0]).append(CONFIG_JSON).string();
+ config = FileEntry::FilePath(packageParser_.GetInputs()[0]).Append(CONFIG_JSON).GetPath();
if (!ResourceUtil::FileExist(config)) {
- config = filesystem::path(packageParser_.GetInputs()[0]).append(MODULE_JSON).string();
+ config = FileEntry::FilePath(packageParser_.GetInputs()[0]).Append(MODULE_JSON).GetPath();
}
}
- if (filesystem::path(config).filename().string() == MODULE_JSON) {
+ if (FileEntry::FilePath(config).GetFilename() == MODULE_JSON) {
ConfigParser::SetUseModule();
}
configJson_ = ConfigParser(config);
@@ -274,17 +275,18 @@ uint32_t ResourcePack::GenerateJsHeader(const std::string &headerPath) const
uint32_t ResourcePack::CopyRawFile(const vector &inputs) const
{
for (const auto &input : inputs) {
- string rawfilePath = filesystem::path(input).append(RAW_FILE_DIR).string();
+ string rawfilePath = FileEntry::FilePath(input).Append(RAW_FILE_DIR).GetPath();
if (!ResourceUtil::FileExist(rawfilePath)) {
continue;
}
- if (!filesystem::is_directory(rawfilePath)) {
+ if (!FileEntry::IsDirectory(rawfilePath)) {
cerr << "Error: '" << rawfilePath << "' not directory." << endl;
return RESTOOL_ERROR;
}
- string dst = filesystem::path(packageParser_.GetOutput()).append(RESOURCES_DIR).append(RAW_FILE_DIR).string();
+ string dst = FileEntry::FilePath(packageParser_.GetOutput())
+ .Append(RESOURCES_DIR).Append(RAW_FILE_DIR).GetPath();
if (CopyRawFileImpl(rawfilePath, dst) != RESTOOL_SUCCESS) {
return RESTOOL_ERROR;
}
@@ -297,22 +299,27 @@ uint32_t ResourcePack::CopyRawFileImpl(const string &src, const string &dst) con
if (!ResourceUtil::CreateDirs(dst)) {
return RESTOOL_ERROR;
}
- for (const auto &entry : filesystem::directory_iterator(src)) {
- string filename = entry.path().filename().string();
- if (ResourceUtil::IsIgnoreFile(filename, entry.status().type())) {
+
+ FileEntry f(src);
+ if (!f.Init()) {
+ return RESTOOL_ERROR;
+ }
+ for (const auto &entry : f.GetChilds()) {
+ string filename = entry->GetFilePath().GetFilename();
+ if (ResourceUtil::IsIgnoreFile(filename, entry->IsFile())) {
continue;
}
- string subPath = filesystem::path(dst).append(filename).string();
- if (entry.is_directory()) {
- if (CopyRawFileImpl(entry.path().string(), subPath) != RESTOOL_SUCCESS) {
+ string subPath = FileEntry::FilePath(dst).Append(filename).GetPath();
+ if (!entry->IsFile()) {
+ if (CopyRawFileImpl(entry->GetFilePath().GetPath(), subPath) != RESTOOL_SUCCESS) {
return RESTOOL_ERROR;
}
} else {
if (ResourceUtil::FileExist(subPath)) {
continue;
}
- if (!ResourceUtil::CopyFleInner(entry.path().string(), subPath)) {
+ if (!ResourceUtil::CopyFleInner(entry->GetFilePath().GetPath(), subPath)) {
return RESTOOL_ERROR;
}
}
@@ -325,7 +332,8 @@ uint32_t ResourcePack::GenerateConfigJson()
if (configJson_.ParseRefence() != RESTOOL_SUCCESS) {
return RESTOOL_ERROR;
}
- string outputPath = filesystem::path(packageParser_.GetOutput()).append(ConfigParser::GetConfigName()).string();
+ string outputPath = FileEntry::FilePath(packageParser_.GetOutput())
+ .Append(ConfigParser::GetConfigName()).GetPath();
return configJson_.Save(outputPath);
}
diff --git a/src/resource_table.cpp b/src/resource_table.cpp
index 813ee8c879b1e0a5c664d8ab3a7cc8b0663a1269..4a2fcbc8f9889c1f383945fd28a7aefdd946313c 100644
--- a/src/resource_table.cpp
+++ b/src/resource_table.cpp
@@ -14,8 +14,8 @@
*/
#include "resource_table.h"
-#include
#include "cmd_parser.h"
+#include "file_entry.h"
#include "file_manager.h"
#include "resource_util.h"
#include "securec.h"
@@ -28,7 +28,7 @@ ResourceTable::ResourceTable()
{
auto &parser =CmdParser::GetInstance();
auto &packageParser = parser.GetCmdParser();
- indexFilePath_ = filesystem::path(packageParser.GetOutput()).append(RESOURCE_INDEX_FILE).string();
+ indexFilePath_ = FileEntry::FilePath(packageParser.GetOutput()).Append(RESOURCE_INDEX_FILE).GetPath();
}
ResourceTable::~ResourceTable()
diff --git a/src/resource_util.cpp b/src/resource_util.cpp
index 81f3cb40c1390a70324bb825117c65caeb79ad06..51a699c1d8d6d1f347fb8575e6c9fe2a939534cc 100644
--- a/src/resource_util.cpp
+++ b/src/resource_util.cpp
@@ -18,6 +18,7 @@
#include
#include
#include
+#include "file_entry.h"
#ifdef __WIN32
#include "windows.h"
#endif
@@ -62,18 +63,12 @@ void ResourceUtil::Split(const string &str, vector &out, const string &s
bool ResourceUtil::FileExist(const string &path)
{
- return filesystem::exists(path);
+ return FileEntry::Exist(path);
}
bool ResourceUtil::RmoveAllDir(const string &path)
{
- error_code err;
- filesystem::remove_all(path, err);
- if (err) {
- cerr << "Error: remove all " << path << " failed, msg :=" << err.message() << endl;
- return false;
- }
- return true;
+ return FileEntry::RemoveAllDir(path);
}
bool ResourceUtil::OpenJsonFile(const string &path, Json::Value &root)
@@ -225,12 +220,8 @@ bool ResourceUtil::CopyFleInner(const string &src, const string &dst)
return false;
}
#else
- error_code err;
- filesystem::path from(src);
- filesystem::path to(dst);
- if (!filesystem::copy_file(from, to, filesystem::copy_options::overwrite_existing, err)) {
+ if (!FileEntry::CopyFile(src, dst)) {
cerr << "Error: copy file fail from '" << src << "' to '" << dst << "'" << endl;
- cerr << err.message() << endl;
return false;
}
#endif
@@ -242,22 +233,20 @@ bool ResourceUtil::CreateDirs(const string &filePath)
if (FileExist(filePath)) {
return true;
}
-
- error_code err;
- if (!filesystem::create_directories(filePath, err)) {
- cerr << "Error: create directory fail '" << filePath << "'" << endl;
- return false;
+
+ if (!FileEntry::CreateDirs(filePath)) {
+ cerr << "Error: create dir fail '" << filePath << "'" << endl;
}
return true;
}
-bool ResourceUtil::IsIgnoreFile(const string &filename, filesystem::file_type type)
+bool ResourceUtil::IsIgnoreFile(const string &filename, bool isFile)
{
string key = filename;
transform(key.begin(), key.end(), key.begin(), ::tolower);
for (const auto &iter : IGNORE_FILE_REGEX) {
- if ((iter.second == IgnoreType::IGNORE_FILE && type != filesystem::file_type::regular) ||
- (iter.second == IgnoreType::IGNORE_DIR && type != filesystem::file_type::directory)) {
+ if ((iter.second == IgnoreType::IGNORE_FILE && !isFile) ||
+ (iter.second == IgnoreType::IGNORE_DIR && isFile)) {
continue;
}
if (regex_match(key, regex(iter.first))) {
diff --git a/src/solid_xml_compiler.cpp b/src/solid_xml_compiler.cpp
index fd2c2d8462b3523b35e0a9f57ff22e582240f2ec..fa4d893d76f1cd62cb6663350dc56b28b6123628 100644
--- a/src/solid_xml_compiler.cpp
+++ b/src/solid_xml_compiler.cpp
@@ -14,7 +14,6 @@
*/
#include "solid_xml_compiler.h"
-#include
#include
#include
#include "resource_util.h"
diff --git a/src/xml/key_manager.cpp b/src/xml/key_manager.cpp
index c3c6c5cb74819d1ab2ecc2e9b06c8dea7c7d46d3..85363573d5ed42d5015be38b3a3f8eb08df9783d 100644
--- a/src/xml/key_manager.cpp
+++ b/src/xml/key_manager.cpp
@@ -14,7 +14,7 @@
*/
#include "key_manager.h"
-#include
+#include "file_entry.h"
#include "resource_util.h"
namespace OHOS {
@@ -32,7 +32,7 @@ KeyManager::KeyManager()
bool KeyManager::LoadKey(const string &keysPath)
{
for (auto &key : keys_) {
- string keyPath = filesystem::path(keysPath).append(XmlKeyNode::KEY_TO_FILE_NAME.at(key.first)).string();
+ string keyPath = FileEntry::FilePath(keysPath).Append(XmlKeyNode::KEY_TO_FILE_NAME.at(key.first)).GetPath();
if (!ResourceUtil::FileExist(keyPath)) {
continue;
}
@@ -46,7 +46,7 @@ bool KeyManager::LoadKey(const string &keysPath)
bool KeyManager::SaveKey(const string &keysPath)
{
for (const auto &iter : keys_) {
- string keyPath = filesystem::path(keysPath).append(XmlKeyNode::KEY_TO_FILE_NAME.at(iter.first)).string();
+ string keyPath = FileEntry::FilePath(keysPath).Append(XmlKeyNode::KEY_TO_FILE_NAME.at(iter.first)).GetPath();
if (!iter.second->SaveToFile(keyPath)) {
return false;
}
diff --git a/src/xml/xml_converter.cpp b/src/xml/xml_converter.cpp
index 0bd983fe5f22736691bbc567070481733c24354c..826a4a1a2cf7aea3a0a80283027d7bd65b833aa5 100644
--- a/src/xml/xml_converter.cpp
+++ b/src/xml/xml_converter.cpp
@@ -14,7 +14,7 @@
*/
#include "xml_converter.h"
-#include
+#include "file_entry.h"
#include "resource_util.h"
#include "solid_xml.h"
@@ -38,8 +38,8 @@ bool XmlConverter::GenerateSolidXml()
}
for (const auto &xmlPath : xmlPaths_) {
SolidXml solidXml(xmlPath, keyManager.GetKeys());
- string filename = filesystem::path(xmlPath).filename().string();
- string filePath = filesystem::path(outputPath_).append(filename).replace_extension(".sxml").string();
+ string filename = FileEntry::FilePath(xmlPath).GetFilename();
+ string filePath = FileEntry::FilePath(outputPath_).Append(filename).ReplaceExtension(".sxml").GetPath();
if (!solidXml.GenerateSolidXml(filePath)) {
return false;
}
diff --git a/test/config.json b/test/config.json
new file mode 100644
index 0000000000000000000000000000000000000000..390d25badcd1a38e21a27243425ef4e31a61f293
--- /dev/null
+++ b/test/config.json
@@ -0,0 +1,60 @@
+{
+ "app": {
+ "bundleName": "com.example.myapplication",
+ "vendor": "example",
+ "version": {
+ "code": 1,
+ "name": "1.0"
+ },
+ "apiVersion": {
+ "compatible": 4,
+ "target": 5
+ }
+ },
+ "deviceConfig": {},
+ "module": {
+ "package": "com.example.myapplication",
+ "name": ".MyApplication",
+ "deviceType": [
+ "phone"
+ ],
+ "distro": {
+ "deliveryWithInstall": true,
+ "moduleName": "entry",
+ "moduleType": "entry"
+ },
+ "abilities": [
+ {
+ "visible": true,
+ "skills": [
+ {
+ "entities": [
+ "entity.system.home"
+ ],
+ "actions": [
+ "action.system.home"
+ ]
+ }
+ ],
+ "name": "com.example.myapplication.MainAbility",
+ "icon": "$media:icon",
+ "description": "$string:mainability_description",
+ "label": "MyApplication",
+ "type": "page",
+ "launchType": "standard"
+ }
+ ],
+ "js": [
+ {
+ "pages": [
+ "pages/index/index"
+ ],
+ "name": "default",
+ "window": {
+ "designWidth": 720,
+ "autoDesignWidth": false
+ }
+ }
+ ]
+ }
+}
\ No newline at end of file
diff --git a/test/resources/base/element/strings.json b/test/resources/base/element/strings.json
new file mode 100644
index 0000000000000000000000000000000000000000..acef8b4f62af2178b54110a67318c2351000b25a
--- /dev/null
+++ b/test/resources/base/element/strings.json
@@ -0,0 +1,5 @@
+{
+ "string":[
+ { "name":"mainability_description", "value":"my testing application"}
+ ]
+}
\ No newline at end of file
diff --git a/test/resources/base/media/icon.png b/test/resources/base/media/icon.png
new file mode 100644
index 0000000000000000000000000000000000000000..ef70bd6b5d33d5eab52f56e7f163bce440e37522
Binary files /dev/null and b/test/resources/base/media/icon.png differ
diff --git a/test/test.py b/test/test.py
new file mode 100644
index 0000000000000000000000000000000000000000..fe57518932afd4f09ad631e4a1460a2050d1a301
--- /dev/null
+++ b/test/test.py
@@ -0,0 +1,27 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+# 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.
+
+import os
+import sys
+
+restool_cmd = sys.argv[1]
+output_path = sys.argv[2]
+
+run_cmd = restool_cmd
+run_cmd = run_cmd + " -i " + os.path.join(".")
+run_cmd = run_cmd + " -o " + output_path
+run_cmd = run_cmd + " -r " + os.path.join(output_path, "ResourceTable.h")
+run_cmd = run_cmd + " -p com.example.myapplication"
+os.system(run_cmd)
\ No newline at end of file