zip4j
zip4j copied to clipboard
file permissions are not preserved while unzipping zip file on linux machine
Hi,
We are using zip4j(version 2.10.0) to zip file(containing folders) and unzip file for our application. while unzipping the created zip file, we found that folder and file permissions are not preserved on CentOS Linux 8 machine. In below snippet, we are creating zipexample1.zip using zipexample folder and we are extracting zipexample1.zip file into temp directory. Both zipexample and temp folders are having different permissions [root@localhost zip_permissionTest]# ls -l /usr drwxr-xr-x 3 root root 19 Jul 28 08:26 temp drwxrwx--- 3 root root 19 Jul 28 08:11 zipexample -rw-r--r-- 1 root root 232 Jul 28 08:26 zipexample1.zip
Below is the test code written for creating and extracting zip file: ZipParameters zipParameters = new ZipParameters(); zipParameters.setReadHiddenFiles(false); zipParameters.setIncludeRootFolder(false); zipParameters.setUnixMode(true); String filePath = File.separatorChar+"usr"+File.separatorChar+ "zipexample"; Path p = Paths.get(filePath); try { ZipFile zipFile = new ZipFile(filePath+"1.zip"); zipFile.addFolder(new File(filePath), zipParameters); String targetPath = File.separatorChar+"usr"+File.separatorChar+"temp"; Files.createDirectories(Paths.get(targetPath)); ZipFile extractZipFile = new ZipFile(filePath+"1.zip"); extractZipFile.extractAll(targetPath); } catch (ZipException ze) { ze.printStackTrace(); } catch (IOException e) { e.printStackTrace(); }
Could you please help?
Thanks