package com.github.chrisblutz.trinity.utils;

import com.github.chrisblutz.trinity.Trinity;

import java.io.File;
import java.net.URISyntaxException;


/**
 * @author Christopher Lutz
 */
public class FileUtils {
    
    public static String getExtension(File f) {
        
        if (f.getName().contains(".")) {
            
            return f.getName().substring(f.getName().lastIndexOf('.') + 1);
        }
        
        return "";
    }
    
    public static void delete(File file) {
        
        if (file.isDirectory()) {
            
            File[] files = file.listFiles();
            
            if (files != null) {
                
                for (File f : files) {
                    
                    delete(f);
                }
            }
        }
        
        file.delete();
    }
    
    private static File trinityHome = null;
    
    public static File getTrinityHome() {
        
        if (trinityHome == null) {
            
            try {
                
                trinityHome = new File(new File(Trinity.class.getProtectionDomain().getCodeSource().getLocation().toURI()), "../..");
                
            } catch (URISyntaxException e) {
                
                e.printStackTrace();
                Trinity.exit(50);
            }
        }
        
        return trinityHome;
    }
}

@@ -111,44 +111,8 @@
 le;%0A
-import java.net.URISyntaxException;%0A
 %0A%0A/*
@@ -1111,16 +1111,125 @@
 ./..%22);%0A
+                // Resolve '../..' out of path%0A                trinityHome = trinityHome.getCanonicalFile();%0A
         
@@ -1262,17 +1262,8 @@
 ch (
-URISyntax
 Exce

Resolve '../..' out of Trinity home path in FileUtils