From 9d3a7fb762adacf22ba7d31c1d9d8b9001348c43 Mon Sep 17 00:00:00 2001 From: zhaogan Date: Tue, 26 Sep 2023 18:35:09 +0800 Subject: [PATCH 1/2] =?UTF-8?q?fixed=20995e47a=20from=20https://gitee.com/?= =?UTF-8?q?zhrenqiang/developtools=5Fpacking=5Ftool/pulls/633=20Issue:=20#?= =?UTF-8?q?I84KU8=20Description:=E6=89=93=E5=8C=85res=E6=A8=A1=E5=BC=8F?= =?UTF-8?q?=E8=A7=84=E5=88=99=E8=B0=83=E6=95=B4=20Sig:=20SIG=5FApplicaiton?= =?UTF-8?q?Framework=20Feature=20or=20Bugfix:=20Feature=20Binary=20Source:?= =?UTF-8?q?=20No?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zhaogan --- adapter/ohos/Compressor.java | 47 ++++++++++++++++++++++++++++++------ 1 file changed, 39 insertions(+), 8 deletions(-) diff --git a/adapter/ohos/Compressor.java b/adapter/ohos/Compressor.java index 52eccbc8..44ddf16a 100644 --- a/adapter/ohos/Compressor.java +++ b/adapter/ohos/Compressor.java @@ -1345,13 +1345,6 @@ public class Compressor { + temp.length + "."); continue; } - String moduleName = temp[temp.length - 4]; - if (!isModelName(moduleName)) { - String errMessage = "Compressor::compressProcess compress pack.res failed, " + - "please check the related configurations in module " + moduleName + "."; - LOG.error(errMessage); - throw new BundleException(errMessage); - } String fileLanguageCountryName = temp[temp.length - 3]; if (!isThirdLevelDirectoryNameValid(fileLanguageCountryName)) { LOG.error("Compressor::compressProcess compress failed third level directory name: " @@ -1373,7 +1366,7 @@ public class Compressor { + " PNG format is found."); } } - pathToFile(utility, utility.getEntryCardPath(), ENTRYCARD_NAME, false); + pathToFileResMode(utility, utility.getEntryCardPath(), ENTRYCARD_NAME, false); } } @@ -1664,6 +1657,44 @@ public class Compressor { } } + /** + * compress file or directory, res mode + * + * @param utility common data + * @param path create new file by path + * @param baseDir base path for file + * @param isCompression if need compression + * @throws BundleException FileNotFoundException|IOException. + */ + private void pathToFileResMode(Utility utility, String path, String baseDir, boolean isCompression) + throws BundleException { + if (path.isEmpty()) { + return; + } + File fileItem = new File(path); + if (fileItem.isDirectory()) { + File[] files = fileItem.listFiles(); + if (files == null) { + return; + } + for (File file : files) { + if (!list.contains(file.getName())) { + //moduleName not in pack.info + continue; + } + if (file.isDirectory()) { + compressDirectory(utility, file, baseDir, isCompression); + } else if (isCompression) { + compressFile(utility, file, baseDir, isCompression); + } else { + compressFile(utility, file, baseDir, isCompression); + } + } + } else { + compressFile(utility, fileItem, baseDir, isCompression); + } + } + /** * compress file directory. * -- Gitee From 0424448c7f10203b700461c9ec8fe14002a6e072 Mon Sep 17 00:00:00 2001 From: zhrenqiang Date: Wed, 13 Dec 2023 06:30:24 +0000 Subject: [PATCH 2/2] update adapter/ohos/Compressor.java. Signed-off-by: zhrenqiang --- adapter/ohos/Compressor.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/adapter/ohos/Compressor.java b/adapter/ohos/Compressor.java index 44ddf16a..83921c02 100644 --- a/adapter/ohos/Compressor.java +++ b/adapter/ohos/Compressor.java @@ -1679,7 +1679,7 @@ public class Compressor { } for (File file : files) { if (!list.contains(file.getName())) { - //moduleName not in pack.info + // moduleName not in pack.info continue; } if (file.isDirectory()) { -- Gitee