package com.csc.library.utilities;

import java.io.File;

import com.csc.library.session.InitialEnvironment;

public class GenFolder {

	boolean check = false;
	String Path, folder;
	InitialEnvironment env;
	private UProfile upf=null;

	public GenFolder(UProfile upf, String nameFolder) {
		try {
			this.initEnv();
			this.built(env.getValue("uploadpath-path"), nameFolder);
		} catch (Exception ex) {
			MyLog.error(this, this.upf, ex);
		}
	}

	//public GenFolder(String path, String  nameFolder){}

	private void built(String path, String nameFolder) {
		String outPath;
		if (path.lastIndexOf("/") == path.length())
			outPath = path;
		else
			outPath = path + "/";
		this.Path = outPath;
		this.folder = nameFolder;
		try {
			File testFile = new File(outPath + nameFolder);
			check = testFile.mkdir();
		} catch (Exception ex) {
			MyLog.error(this, this.upf, ex);
		}
	}

	public boolean checkBuilt() {
		return this.check;
	}

	public String getPath() {
		return this.Path;
	}
	public String getFolder() {
		return this.folder;
	}

	private void initEnv() {
		env = new InitialEnvironment("GLOBAL");
	}

}