package com.axis.innovators.box.tools;

import java.io.File;

/**
 * 在当前jar下创建文件夹
 * @author tzdwindows 7
 */
public class FolderCreator {

    public static final String LIBRARY_NAME = "library";

    public static String getLibraryFolder() {
        String folder = createFolder(LIBRARY_NAME);
        if (folder == null) {
            System.out.println("Library folder creation failure");
            return null;
        }
        return folder;
    }

    /**
     * 创建文件夹
     * @param folderName folder name
     * @return folder path
     */
    private static String createFolder(String folderName) {
        String jarDir = System.getProperty("user.dir");
        File folder = new File(jarDir, folderName);
        if (!folder.exists()) {
            if (!folder.mkdir()) {
                System.out.println("Folder creation failure");
                return null;
            }
        }
        return folder.getAbsolutePath();
    }
}
