mirror of
https://github.com/ysoftdevs/DependencyCheck.git
synced 2026-03-20 08:14:44 +01:00
checkstyle corrections
Former-commit-id: 982cd5df66cc4b41e73deddd7e1ae749a2cb955e
This commit is contained in:
@@ -42,6 +42,7 @@ import org.owasp.dependencycheck.analyzer.exception.AnalysisException;
|
|||||||
import org.owasp.dependencycheck.analyzer.exception.ArchiveExtractionException;
|
import org.owasp.dependencycheck.analyzer.exception.ArchiveExtractionException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Set of utilities to extract files from archives.
|
||||||
*
|
*
|
||||||
* @author Jeremy Long
|
* @author Jeremy Long
|
||||||
*/
|
*/
|
||||||
@@ -74,9 +75,8 @@ public final class ExtractionUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Extracts the contents of an archive into the specified directory. The files are only extracted if they are
|
* Extracts the contents of an archive into the specified directory. The files are only extracted if they are supported by the
|
||||||
* supported by the analyzers loaded into the specified engine. If the engine is specified as null then all files
|
* analyzers loaded into the specified engine. If the engine is specified as null then all files are extracted.
|
||||||
* are extracted.
|
|
||||||
*
|
*
|
||||||
* @param archive an archive file such as a WAR or EAR
|
* @param archive an archive file such as a WAR or EAR
|
||||||
* @param extractTo a directory to extract the contents to
|
* @param extractTo a directory to extract the contents to
|
||||||
@@ -143,14 +143,10 @@ public final class ExtractionUtil {
|
|||||||
/**
|
/**
|
||||||
* Extracts the contents of an archive into the specified directory.
|
* Extracts the contents of an archive into the specified directory.
|
||||||
*
|
*
|
||||||
* @param archive
|
* @param archive an archive file such as a WAR or EAR
|
||||||
* an archive file such as a WAR or EAR
|
* @param destination a directory to extract the contents to
|
||||||
* @param destination
|
* @param filter determines which files get extracted
|
||||||
* a directory to extract the contents to
|
* @throws ExtractionException thrown if the archive is not found
|
||||||
* @param filter
|
|
||||||
* determines which files get extracted
|
|
||||||
* @throws ExtractionException
|
|
||||||
* thrown if the archive is not found
|
|
||||||
*/
|
*/
|
||||||
public static void extractFilesUsingFilter(File archive, File destination,
|
public static void extractFilesUsingFilter(File archive, File destination,
|
||||||
FilenameFilter filter) throws ExtractionException {
|
FilenameFilter filter) throws ExtractionException {
|
||||||
@@ -185,15 +181,10 @@ public final class ExtractionUtil {
|
|||||||
/**
|
/**
|
||||||
* Extracts files from an archive.
|
* Extracts files from an archive.
|
||||||
*
|
*
|
||||||
* @param input
|
* @param input the archive to extract files from
|
||||||
* the archive to extract files from
|
* @param destination the location to write the files too
|
||||||
* @param destination
|
* @param filter determines which files get extracted
|
||||||
* the location to write the files too
|
* @throws ArchiveExtractionException thrown if there is an exception extracting files from the archive
|
||||||
* @param filter
|
|
||||||
* determines which files get extracted
|
|
||||||
* @throws ArchiveExtractionException
|
|
||||||
* thrown if there is an exception extracting files from the
|
|
||||||
* archive
|
|
||||||
*/
|
*/
|
||||||
private static void extractArchive(ArchiveInputStream input,
|
private static void extractArchive(ArchiveInputStream input,
|
||||||
File destination, FilenameFilter filter)
|
File destination, FilenameFilter filter)
|
||||||
@@ -224,6 +215,15 @@ public final class ExtractionUtil {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Extracts a file from an archive (input stream) and correctly builds the directory structure.
|
||||||
|
*
|
||||||
|
* @param input the archive input stream
|
||||||
|
* @param destination where to write the file
|
||||||
|
* @param filter the file filter to apply to the files being extracted
|
||||||
|
* @param entry the entry from the archive to extract
|
||||||
|
* @throws ExtractionException thrown if there is an error reading from the archive stream
|
||||||
|
*/
|
||||||
private static void extractFile(ArchiveInputStream input, File destination,
|
private static void extractFile(ArchiveInputStream input, File destination,
|
||||||
FilenameFilter filter, ArchiveEntry entry) throws ExtractionException {
|
FilenameFilter filter, ArchiveEntry entry) throws ExtractionException {
|
||||||
final File file = new File(destination, entry.getName());
|
final File file = new File(destination, entry.getName());
|
||||||
@@ -256,6 +256,13 @@ public final class ExtractionUtil {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Transfers data from one stream to another using a buffer.
|
||||||
|
*
|
||||||
|
* @param input the input stream
|
||||||
|
* @param bos the output stream
|
||||||
|
* @throws IOException thrown if there is an error reading/writing to the streams
|
||||||
|
*/
|
||||||
private static void transferUsingBuffer(InputStream input,
|
private static void transferUsingBuffer(InputStream input,
|
||||||
BufferedOutputStream bos) throws IOException {
|
BufferedOutputStream bos) throws IOException {
|
||||||
int count;
|
int count;
|
||||||
@@ -266,6 +273,11 @@ public final class ExtractionUtil {
|
|||||||
bos.flush();
|
bos.flush();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Closes the stream.
|
||||||
|
*
|
||||||
|
* @param stream the stream to close
|
||||||
|
*/
|
||||||
private static void closeStream(Closeable stream) {
|
private static void closeStream(Closeable stream) {
|
||||||
if (stream != null) {
|
if (stream != null) {
|
||||||
try {
|
try {
|
||||||
@@ -276,6 +288,12 @@ public final class ExtractionUtil {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Ensures the parent path is correctly created on disk so that the file can be extracted to the correct location.
|
||||||
|
*
|
||||||
|
* @param file the file path
|
||||||
|
* @throws ExtractionException thrown if the parent paths could not be created
|
||||||
|
*/
|
||||||
private static void createParentFile(final File file)
|
private static void createParentFile(final File file)
|
||||||
throws ExtractionException {
|
throws ExtractionException {
|
||||||
final File parent = file.getParentFile();
|
final File parent = file.getParentFile();
|
||||||
|
|||||||
Reference in New Issue
Block a user