jbackup/src/main/java/org/jbundle/jbackup/destination/ZipDestination.java
public long addNextFile(SourceFile source)
	{
		String strPath = source.getFilePath();
		long lStreamLength = source.getStreamLength();

        InputStream inStream = source.makeInStream();
		long lLength = 0;
		try	{
			if (m_lMaxZipFileSize > 0)
//?				if (lLength != File.OL)
			{	// Check to make sure this file will fit
				if (m_lCurrentLength + lStreamLength > m_lMaxZipFileSize)
				{	// Writing this file would push me past the file length limit
					try	{
						m_outZip.flush();
						m_outZip.close();

						m_lCurrentLength = 0;
						m_iFileNumber++;
						int iPosDot = m_strZipFilename.lastIndexOf('.');
						if (iPosDot == -1)
							iPosDot = m_strZipFilename.length();
						String strZipFilename = m_strZipFilename.substring(0, iPosDot);
						strZipFilename += Integer.toString(m_iFileNumber);
						if (iPosDot != m_strZipFilename.length())
							strZipFilename += m_strZipFilename.substring(iPosDot);
						FileOutputStream outStream = new FileOutputStream(strZipFilename);
						m_outZip = new ZipOutputStream(outStream);
					} catch (FileNotFoundException ex)	{
						ex.printStackTrace();
					} catch (IOException ex)	{
						ex.printStackTrace();
					}
				}
			}
			ZipEntry zipEntry = new ZipEntry(strPath);
			if (DEBUG)
				System.out.println(strPath);
			m_outZip.putNextEntry(zipEntry);
			lLength = Util.copyStream(inStream, m_outZip);
			m_lCurrentLength += lLength;
		} catch (IOException ex)	{
			ex.printStackTrace();
		}
		return lLength;
	}
public long addNextFile(SourceFile source)
	{
		String strPath = source.getFilePath();
		long lStreamLength = source.getStreamLength();

        InputStream inStream = source.makeInStream();
		long lLength = 0;
		try	{
			if (m_lMaxZipFileSize > 0)
//?				if (lLength != File.OL)
			{	// Check to make sure this file will fit
				if (m_lCurrentLength + lStreamLength > m_lMaxZipFileSize)
				{	// Writing this file would push me past the file length limit
					try	{
						m_outZip.flush();
						m_outZip.close();

						m_lCurrentLength = 0;
						m_iFileNumber++;
						int iPosDot = m_strZipFilename.lastIndexOf('.');
						if (iPosDot == -1)
							iPosDot = m_strZipFilename.length();
						String strZipFilename = m_strZipFilename.substring(0, iPosDot);
						strZipFilename += Integer.toString(m_iFileNumber);
						if (iPosDot != m_strZipFilename.length())
							strZipFilename += m_strZipFilename.substring(iPosDot);
						FileOutputStream outStream = new FileOutputStream(strZipFilename);
						m_outZip = new ZipOutputStream(outStream);
					} catch (FileNotFoundException ex)	{
						ex.printStackTrace();
					} catch (IOException ex)	{
						ex.printStackTrace();
					}
				}
			}
			ZipEntry zipEntry = new ZipEntry(strPath);
			if (DEBUG)
				System.out.println(strPath);
			m_outZip.putNextEntry(zipEntry);
			lLength = Util.copyStream(inStream, m_outZip);
			m_lCurrentLength += lLength;
		} catch (IOException ex)	{
			ex.printStackTrace();
		}
		return lLength;
	}
public long addNextFile ( SourceFile source ) { String strPath = source . getFilePath ( ) ; long lStreamLength = source . getStreamLength ( ) ; InputStream inStream = source . makeInStream ( ) ; long lLength = 0 ; try { if ( m_lMaxZipFileSize > 0 ) //?				if (lLength != File.OL) { // Check to make sure this file will fit if ( m_lCurrentLength + lStreamLength > m_lMaxZipFileSize ) { // Writing this file would push me past the file length limit try { m_outZip . flush ( ) ; m_outZip . close ( ) ; m_lCurrentLength = 0 ; m_iFileNumber ++ ; int iPosDot = m_strZipFilename . lastIndexOf ( ' ' ) ; if ( iPosDot == - 1 ) iPosDot = m_strZipFilename . length ( ) ; String strZipFilename = m_strZipFilename . substring ( 0 , iPosDot ) ; strZipFilename += Integer . toString ( m_iFileNumber ) ; if ( iPosDot != m_strZipFilename . length ( ) ) strZipFilename += m_strZipFilename . substring ( iPosDot ) ; FileOutputStream outStream = new FileOutputStream ( strZipFilename ) ; m_outZip = new ZipOutputStream ( outStream ) ; } catch ( FileNotFoundException ex ) { ex . printStackTrace ( ) ; } catch ( IOException ex ) { ex . printStackTrace ( ) ; } } } ZipEntry zipEntry = new ZipEntry ( strPath ) ; if ( DEBUG ) System . out . println ( strPath ) ; m_outZip . putNextEntry ( zipEntry ) ; lLength = Util . copyStream ( inStream , m_outZip ) ; m_lCurrentLength += lLength ; } catch ( IOException ex ) { ex . printStackTrace ( ) ; } return lLength ; }
/*
Add this file to the destination.
Note: Only supply the file or the stream, not both. Supply the object that is easier, given
the source. This dual option is given to allow destinations that require File objects from
(such as FTP or HTTP) Having to write the inStream to a physical file before processing it.
@param file Source file.
@param inStream Source stream.
@param strpath Full path of the source file (including the filename).
@param strFilename Filename.
@param lStreamLength Length of the stream (-1 if unknown).
/ * Add this file to the destination . Note : Only supply the file or the stream not both . Supply the object that is easier given the source . This dual option is given to allow destinations that require File objects from ( such as FTP or HTTP ) Having to write the inStream to a physical file before processing it .