*
* @param source the base directory
* @param destination the output filename
- * @param absolute store absolute filepath (from directory) or only filename
* @return True if OK
*/
- fun compress(source: File, destination: File, absolute: Boolean): Boolean {
+ fun compress(source: File, destination: File): Boolean {
try {
+ if(!destination.parentFile.exists()) {
+ destination.parentFile.mkdirs()
+ }
destination.createNewFile()
- ZipArchiveOutputStream(destination).use {
- recurseFiles(source, source, it, absolute)
+ val ignoreZipFiles = Predicate<Path> { path -> !path.endsWith(".zip") && !path.endsWith(".ZIP") }
+ FileOutputStream(destination).use { out ->
+ compressFolder(source.toPath(), out, pathFilter = ignoreZipFiles)
}
} catch (e: Exception) {
log.error("Fail to compress folder($source) to path(${destination.path})", e)