diff --git a/adapter/ohos/Compressor.java b/adapter/ohos/Compressor.java index 52eccbc8e70ff07b354ea87fff130623e12f0d4e..83921c026f8ef3e40ab5ac379b3c4c1a9cd245d3 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. *