// Path: src/java/main/br/ufpe/cin/groundhog/GroundhogException.java
// public class GroundhogException extends RuntimeException {
// 	private static final long serialVersionUID = -3563928567447310893L;
// 
// 	public GroundhogException() {
// 		super();
// 	}
// 
// 	public GroundhogException(String msg) {
// 		super(msg);
// 	}
// 
// 	public GroundhogException(Throwable cause) {
// 		super(cause);
// 	}
// 
// 	public GroundhogException(String msg, Throwable cause) {
// 		super(msg, cause);
// 	}
// }


import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.RandomAccessFile;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
import org.apache.commons.io.FileUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import br.ufpe.cin.groundhog.GroundhogException;
import com.google.common.io.Files;
package br.ufpe.cin.groundhog.util;





/**
 * General utilities class for file operations
 * 
 * @author fjsj, gustavopinto, Rodrigo Alves
 */
public class FileUtil {

	private static Logger logger = LoggerFactory.getLogger(FileUtil.class);
	
	
	private static FileUtil instance;
	private List<File> createdTempDirs;

	public static FileUtil getInstance() {
		if (instance == null) {
			instance = new FileUtil();
		}
		return instance;
	}

	private FileUtil() {
		this.createdTempDirs = new ArrayList<File>();
	}

	/**
	 * 
	 * @return A File object representing the created temporary directory
	 */
	public synchronized File createTempDir() {
		try {
			File tempDir = Files.createTempDir();
			this.createdTempDirs.add(tempDir);
			return tempDir;
		} catch (Exception e) {
			e.printStackTrace();
			String error = "Unable to create temporary directory. Are you running groundhog with admin privileges?";
			logger.error(error);
// Path: src/java/main/br/ufpe/cin/groundhog/GroundhogException.java
// public class GroundhogException extends RuntimeException {
// 	private static final long serialVersionUID = -3563928567447310893L;
// 
// 	public GroundhogException() {
// 		super();
// 	}
// 
// 	public GroundhogException(String msg) {
// 		super(msg);
// 	}
// 
// 	public GroundhogException(Throwable cause) {
// 		super(cause);
// 	}
// 
// 	public GroundhogException(String msg, Throwable cause) {
// 		super(msg, cause);
// 	}
// }


// Path: src/java/main/br/ufpe/cin/groundhog/util/FileUtil.java
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.RandomAccessFile;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
import org.apache.commons.io.FileUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import br.ufpe.cin.groundhog.GroundhogException;
import com.google.common.io.Files;

package br.ufpe.cin.groundhog.util;





/**
 * General utilities class for file operations
 * 
 * @author fjsj, gustavopinto, Rodrigo Alves
 */
public class FileUtil {

	private static Logger logger = LoggerFactory.getLogger(FileUtil.class);
	
	
	private static FileUtil instance;
	private List<File> createdTempDirs;

	public static FileUtil getInstance() {
		if (instance == null) {
			instance = new FileUtil();
		}
		return instance;
	}

	private FileUtil() {
		this.createdTempDirs = new ArrayList<File>();
	}

	/**
	 * 
	 * @return A File object representing the created temporary directory
	 */
	public synchronized File createTempDir() {
		try {
			File tempDir = Files.createTempDir();
			this.createdTempDirs.add(tempDir);
			return tempDir;
		} catch (Exception e) {
			e.printStackTrace();
			String error = "Unable to create temporary directory. Are you running groundhog with admin privileges?";
			logger.error(error);
			throw new GroundhogException(error);