Added check for exists when parsing directory

This commit is contained in:
nathan 2016-03-14 01:00:57 +01:00
parent c3831bd63f
commit 2e1a44536e

View File

@ -37,7 +37,6 @@ import java.util.zip.ZipInputStream;
* Peter Donald, Jeff Turner, Matthew Hawthorne, Martin Cooper, * Peter Donald, Jeff Turner, Matthew Hawthorne, Martin Cooper,
* Jeremias Maerki, Stephen Colebourne * Jeremias Maerki, Stephen Colebourne
*/ */
@SuppressWarnings("unused")
public public
class FileUtil { class FileUtil {
private static final Logger logger = LoggerFactory.getLogger(FileUtil.class); private static final Logger logger = LoggerFactory.getLogger(FileUtil.class);
@ -255,7 +254,6 @@ class FileUtil {
/** /**
* Copies the contents of file two onto the END of file one. * Copies the contents of file two onto the END of file one.
*/ */
@SuppressWarnings("resource")
public static public static
File concatFiles(File one, File two) { File concatFiles(File one, File two) {
if (one == null) { if (one == null) {
@ -357,7 +355,6 @@ class FileUtil {
/** /**
* Copies a directory from one location to another * Copies a directory from one location to another
*/ */
@SuppressWarnings("Duplicates")
public static public static
void copyDirectory(File src_, File dest_, String... fileNamesToIgnore) throws IOException { void copyDirectory(File src_, File dest_, String... fileNamesToIgnore) throws IOException {
File src = FileUtil.normalize(src_); File src = FileUtil.normalize(src_);
@ -412,7 +409,6 @@ class FileUtil {
/** /**
* Safely moves a directory from one location to another (by copying it first, then deleting the original). * Safely moves a directory from one location to another (by copying it first, then deleting the original).
*/ */
@SuppressWarnings("Duplicates")
public static public static
void moveDirectory(File src, File dest, String... fileNamesToIgnore) throws IOException { void moveDirectory(File src, File dest, String... fileNamesToIgnore) throws IOException {
if (fileNamesToIgnore.length > 0) { if (fileNamesToIgnore.length > 0) {
@ -648,7 +644,6 @@ class FileUtil {
try { try {
in.mark(ZIP_HEADER.length); in.mark(ZIP_HEADER.length);
for (int i = 0; i < ZIP_HEADER.length; i++) { for (int i = 0; i < ZIP_HEADER.length; i++) {
//noinspection NumericCastThatLosesPrecision
if (ZIP_HEADER[i] != (byte) in.read()) { if (ZIP_HEADER[i] != (byte) in.read()) {
isZip = false; isZip = false;
break; break;
@ -677,7 +672,6 @@ class FileUtil {
/** /**
* @return true if the file is a zip/jar file * @return true if the file is a zip/jar file
*/ */
@SuppressWarnings("Duplicates")
public static public static
boolean isZipFile(File file) { boolean isZipFile(File file) {
boolean isZip = true; boolean isZip = true;
@ -888,6 +882,10 @@ class FileUtil {
rootDirectory = FileUtil.normalize(rootDirectory.getAbsoluteFile()); rootDirectory = FileUtil.normalize(rootDirectory.getAbsoluteFile());
if (!rootDirectory.exists()) {
throw new IOException("Location does not exist: " + rootDirectory.getAbsolutePath());
}
if (rootDirectory.isDirectory()) { if (rootDirectory.isDirectory()) {
directories.add(rootDirectory); directories.add(rootDirectory);