// Path: src/main/java/com/excelsiorjet/api/platform/Host.java
// public class Host {
// 
//     private static final OS hostOS;
// 
//     static {
//         //detect Host OS
//         String osName = System.getProperty("os.name");
//         if (osName.contains("Windows")) {
//             hostOS = OS.WINDOWS;
//         } else if (osName.contains("Linux")) {
//             hostOS = OS.LINUX;
//         } else if (osName.contains("OS X")) {
//             hostOS = OS.OSX;
//         } else {
//             throw new AssertionError("Unknown OS: " + osName);
//         }
//     }
// 
//     public static boolean isWindows() {
//         return hostOS.isWindows();
//     }
// 
//     public static boolean isLinux() {
//         return hostOS.isLinux();
//     }
// 
//     public static boolean isOSX() {
//         return hostOS.isOSX();
//     }
// 
//     public static boolean isUnix() {
//         return hostOS.isUnix();
//     }
// 
//     public static String mangleExeName(String exe) {
//         return hostOS.mangleExeName(exe);
//     }
// 
//     public static OS getOS() {
//         return hostOS;
//     }
// }
// 
// Path: src/main/java/com/excelsiorjet/api/tasks/JetTaskFailureException.java
// public class JetTaskFailureException extends Exception {
// 
//     public JetTaskFailureException(String msg, Throwable throwable) {
//         super(msg, throwable);
//     }
// 
//     public JetTaskFailureException(String msg) {
//         super(msg);
//     }
// }
// 
// Path: src/main/java/com/excelsiorjet/api/log/Log.java
// public static Log logger;
// 
// Path: src/main/java/com/excelsiorjet/api/util/Txt.java
// public static String s(String id, Object... params) {
//     String str = null;
//     if (altMessages != null) {
//         str = altMessages.format(id, params);
//     }
//     if (str == null) {
//         str = messages.format(id, params);
//     }
//     if (str != null) {
//         return str;
//     } else {
//         if (log != null) {
//             log.error("JET message file broken: key = " + id);
//         } else {
//             throw new IllegalStateException("No log to issue error. JET message file broken: key = " + id);
//         }
//         return id;
//     }
// }


import com.excelsiorjet.api.platform.Host;
import com.excelsiorjet.api.tasks.JetTaskFailureException;
import org.apache.commons.compress.archivers.ArchiveEntry;
import org.apache.commons.compress.archivers.ArchiveOutputStream;
import org.apache.commons.compress.archivers.tar.TarArchiveEntry;
import org.apache.commons.compress.archivers.tar.TarArchiveOutputStream;
import org.apache.commons.compress.archivers.zip.ZipArchiveEntry;
import org.apache.commons.compress.archivers.zip.ZipArchiveOutputStream;
import org.apache.commons.compress.compressors.gzip.GzipCompressorOutputStream;
import java.io.*;
import java.nio.file.*;
import java.nio.file.attribute.BasicFileAttributes;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import static com.excelsiorjet.api.log.Log.logger;
import static com.excelsiorjet.api.util.Txt.s;
/*
 * Copyright (c) 2015-2017, Excelsior LLC.
 *
 *  This file is part of Excelsior JET API.
 *
 *  Excelsior JET API is free software:
 *  you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  Excelsior JET API is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with Excelsior JET API.
 *  If not, see <http://www.gnu.org/licenses/>.
 *
 */
package com.excelsiorjet.api.util;




public class Utils {

    public static void cleanDirectory(File f) throws IOException {
        Files.walkFileTree(f.toPath(), new FileVisitor<Path>() {
            @Override
            public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs) throws IOException {
                return FileVisitResult.CONTINUE;
            }

            private void deleteFile(File f) throws IOException {
                if (!f.delete()) {
                    if (f.exists()) {
// Path: src/main/java/com/excelsiorjet/api/platform/Host.java
// public class Host {
// 
//     private static final OS hostOS;
// 
//     static {
//         //detect Host OS
//         String osName = System.getProperty("os.name");
//         if (osName.contains("Windows")) {
//             hostOS = OS.WINDOWS;
//         } else if (osName.contains("Linux")) {
//             hostOS = OS.LINUX;
//         } else if (osName.contains("OS X")) {
//             hostOS = OS.OSX;
//         } else {
//             throw new AssertionError("Unknown OS: " + osName);
//         }
//     }
// 
//     public static boolean isWindows() {
//         return hostOS.isWindows();
//     }
// 
//     public static boolean isLinux() {
//         return hostOS.isLinux();
//     }
// 
//     public static boolean isOSX() {
//         return hostOS.isOSX();
//     }
// 
//     public static boolean isUnix() {
//         return hostOS.isUnix();
//     }
// 
//     public static String mangleExeName(String exe) {
//         return hostOS.mangleExeName(exe);
//     }
// 
//     public static OS getOS() {
//         return hostOS;
//     }
// }
// 
// Path: src/main/java/com/excelsiorjet/api/tasks/JetTaskFailureException.java
// public class JetTaskFailureException extends Exception {
// 
//     public JetTaskFailureException(String msg, Throwable throwable) {
//         super(msg, throwable);
//     }
// 
//     public JetTaskFailureException(String msg) {
//         super(msg);
//     }
// }
// 
// Path: src/main/java/com/excelsiorjet/api/log/Log.java
// public static Log logger;
// 
// Path: src/main/java/com/excelsiorjet/api/util/Txt.java
// public static String s(String id, Object... params) {
//     String str = null;
//     if (altMessages != null) {
//         str = altMessages.format(id, params);
//     }
//     if (str == null) {
//         str = messages.format(id, params);
//     }
//     if (str != null) {
//         return str;
//     } else {
//         if (log != null) {
//             log.error("JET message file broken: key = " + id);
//         } else {
//             throw new IllegalStateException("No log to issue error. JET message file broken: key = " + id);
//         }
//         return id;
//     }
// }


// Path: src/main/java/com/excelsiorjet/api/util/Utils.java
import com.excelsiorjet.api.platform.Host;
import com.excelsiorjet.api.tasks.JetTaskFailureException;
import org.apache.commons.compress.archivers.ArchiveEntry;
import org.apache.commons.compress.archivers.ArchiveOutputStream;
import org.apache.commons.compress.archivers.tar.TarArchiveEntry;
import org.apache.commons.compress.archivers.tar.TarArchiveOutputStream;
import org.apache.commons.compress.archivers.zip.ZipArchiveEntry;
import org.apache.commons.compress.archivers.zip.ZipArchiveOutputStream;
import org.apache.commons.compress.compressors.gzip.GzipCompressorOutputStream;
import java.io.*;
import java.nio.file.*;
import java.nio.file.attribute.BasicFileAttributes;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import static com.excelsiorjet.api.log.Log.logger;
import static com.excelsiorjet.api.util.Txt.s;

/*
 * Copyright (c) 2015-2017, Excelsior LLC.
 *
 *  This file is part of Excelsior JET API.
 *
 *  Excelsior JET API is free software:
 *  you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  Excelsior JET API is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with Excelsior JET API.
 *  If not, see <http://www.gnu.org/licenses/>.
 *
 */
package com.excelsiorjet.api.util;




public class Utils {

    public static void cleanDirectory(File f) throws IOException {
        Files.walkFileTree(f.toPath(), new FileVisitor<Path>() {
            @Override
            public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs) throws IOException {
                return FileVisitResult.CONTINUE;
            }

            private void deleteFile(File f) throws IOException {
                if (!f.delete()) {
                    if (f.exists()) {
                        throw new IOException(Txt.s("JetApi.UnableToDelete.Error", f.getAbsolutePath()));