com.ptc.windchill.upgrade.util
Class ZipUtil

java.lang.Object
  extended bycom.ptc.windchill.upgrade.util.ZipUtil

public class ZipUtil
extends Object

Utilities for dealing with ZipFiles in Java 1.1.


Constructor Summary
ZipUtil()
           
 
Method Summary
static void addFilesToZipFile(File[] files_to_add_update, File target_zip_file)
          Add each of file_to_add to the target_zip_file creating the zip file if necessary.
static void addFilesToZipFile(File reference_directory, File[] files_to_add_update, File target_zip_file)
          Add each of file_to_add to the target_zip_file, but in the jar, locate it in a subdirectory relative to the reference_directory.
static void addFileToZipFile(File file_to_add, File target_zip_file)
          Add the file_to_add to the target_zip_file creating the zip file if necessary.
static void addFileToZipFile(File reference_directory, File file_to_add, File target_zip_file)
          Add the file_to_add to the target_zip_file, but in the jar, locate it in a subdirectory relative to the reference_directory.
private static void bufferInputStreamToOutputStream(InputStream input_stream, OutputStream output_stream)
          Move the contents of input_stream to output_stream.
private static File createTempFileFor(File file)
          Create a temp file based on the specified file's path and name.
static String getRelativePathAndTrailingDelimiter(File reference_directory, File file_to_add)
          Determines the relative path and the correct delimiter for the platform needed to add this file to the UpgradeManagerOutputs.jar.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ZipUtil

public ZipUtil()
Method Detail

addFileToZipFile

public static void addFileToZipFile(File file_to_add,
                                    File target_zip_file)
                             throws IOException
Add the file_to_add to the target_zip_file creating the zip file if necessary.

This method works by re-writing each entry of the existing zip file into a new temp file and then appending the file to add.

WARNING: This method does not check if the files being added are already in the zip file.

Throws:
IOException - if any errors occur reading the existing file or file to add, or if an error occurs writing the new zip file

addFileToZipFile

public static void addFileToZipFile(File reference_directory,
                                    File file_to_add,
                                    File target_zip_file)
                             throws IOException
Add the file_to_add to the target_zip_file, but in the jar, locate it in a subdirectory relative to the reference_directory. Create the zip file if necessary.

This method works by re-writing each entry of the existing zip file into a new temp file and then appending the file to add.

WARNING: This method does not check if the files being added are already in the zip file.

Throws:
IOException - if any errors occur reading the existing file or file to add, or if an error occurs writing the new zip file

addFilesToZipFile

public static void addFilesToZipFile(File[] files_to_add_update,
                                     File target_zip_file)
                              throws IOException
Add each of file_to_add to the target_zip_file creating the zip file if necessary.

This method works by re-writing each entry of the existing zip file into a new temp file and then appending the file to add.

WARNING: This method does not check if the files being added are already in the zip file.

Throws:
IOException - if any errors occur reading the existing file or file to add, or if an error occurs writing the new zip file

addFilesToZipFile

public static void addFilesToZipFile(File reference_directory,
                                     File[] files_to_add_update,
                                     File target_zip_file)
                              throws IOException
Add each of file_to_add to the target_zip_file, but in the jar, locate it in a subdirectory relative to the reference_directory. Create the zip file if necessary.

This method works by re-writing each entry of the existing zip file into a new temp file and then appending the file to add.

WARNING: This method does not check if the files being added are already in the zip file.

Throws:
IOException - if any errors occur reading the existing file or file to add, or if an error occurs writing the new zip file

bufferInputStreamToOutputStream

private static void bufferInputStreamToOutputStream(InputStream input_stream,
                                                    OutputStream output_stream)
                                             throws IOException
Move the contents of input_stream to output_stream.

Throws:
IOException

createTempFileFor

private static File createTempFileFor(File file)
Create a temp file based on the specified file's path and name.


getRelativePathAndTrailingDelimiter

public static String getRelativePathAndTrailingDelimiter(File reference_directory,
                                                         File file_to_add)
                                                  throws FileNotFoundException
Determines the relative path and the correct delimiter for the platform needed to add this file to the UpgradeManagerOutputs.jar.

Parameters:
reference_directory - File reference_directory is the directory that contains all the sub-directories the file_to_add could be.
file_to_add - File file_to_add is the file that is to be added to the jar file. It contains its full path.
Returns:
The relative path of this file, so when the jar is extracted the reports will go into the correct sub-directory.
Throws:
FileNotFoundException