com.tuneology.avm
Class ISOFsImg

java.lang.Object
  |
  +--com.tuneology.avm.ISOFsImg

public class ISOFsImg
extends java.lang.Object

Used to generate an ISO image file.

Version:
$Id: ISOFsImg.java,v 1.12 2003/06/10 08:39:06 xnarf Exp $
Author:
Fran Taylor

Constructor Summary
ISOFsImg()
           
 
Method Summary
 void addExclude(java.lang.String glob)
          Exclude glob from being written to CDROM.
 void addFile(java.lang.String f)
          Adds a file to the archive.
 void addFile(java.lang.String f, java.lang.String path)
          Adds a file to the archive at the specified graft point.
 void addHiddenGlob(java.lang.String glob)
          Add the hidden (existence) ISO9660 directory attribute for glob.
 void addHideGlob(java.lang.String glob)
          Hide glob from being seen on the ISO9660 or Rock Ridge directory.
 void addHideJoliet(java.lang.String glob)
          Hide glob from being seen on the Joliet directory.
 java.lang.String getErrorOutput()
           
 java.io.InputStream getImage()
          Runs mkisofs and starts streaming its output.
 java.io.InputStream getImage(ProgressListener pl)
          Runs mkisofs and starts streaming its output.
static java.lang.String getVersions()
           
 boolean isFinished()
           
 boolean isSuccess()
          Call this after reading the file image to see if the operation is successful.
static java.lang.String[] listJolietCharsets()
          Returns an array containing the possible values for setJolietCharset.
 void setAbstract(java.lang.String txt)
           
 void setAllow31Filenames(boolean b)
          Allow full 31 character filenames.
 void setAllow37Filenames(boolean b)
          Allow 37 chars in ISO9660 filenames.
 void setAllowLeadingPeriod(boolean b)
          Allow ISO9660 filenames to begin with a period.
 void setAllowLowerCase(boolean b)
          This options allows lower case characters to appear in ISO9660 filenames.
 void setAllowMultidot(boolean b)
          This options allows more than one dot to appear in ISO9660 filenames.
 void setApplicationId(java.lang.String txt)
          Specifies a text string that will be written into the volume header.
 void setBibliographic(java.lang.String txt)
           
 void setBootCatalogPath(java.lang.String path)
          Specifies the path and filename of the boot catalog to be used when making an "El Torito" bootable CD.
 void setCompressed(boolean b)
          Generate special RRIP records for transparently compressed files.
 void setCompressLevel(int n)
          Select compression level (1-9, default is 9) for compressed filesystems.
 void setCopyright(java.lang.String str)
           
 void setDirectory(java.lang.String dir)
          Sets the base directory, from which relative paths are resolved.
 void setEltoritoBootImage(java.lang.String path)
          Specifies the path and filename of the boot image to be used when making an "El Torito" bootable CD.
 void setExcludeBackupFiles(boolean b)
          Do not include backup files files on the ISO9660 filesystem.
 void setFollowSymlinks(boolean b)
          Follow symbolic links when generating the filesystem.
 void setGenerateTransTable(boolean b)
          Generate a file TRANS.TBL in each directory on the CDROM, which can be used on non-Rock Ridge capable systems to help establish the correct file names.
 void setGenericBootImage(java.lang.String path)
          Specifies the path and filename of the generic boot image to be used when making a generic bootable CD.
 void setIsoLevel(int l)
          Set the iso9660 conformance level.
 void setJolietCharset(java.lang.String charset)
          Local charset that should be used for translating local file names into Joliet Unicode directory records.
 void setJolietUnicodeLevel(int n)
          Set Unicode conformance level in the Joliet SVD.
 void setMergeDevice(CDRDrive dev)
          Specifies device with previous iso image to be merged.
 void setMergePath(java.lang.String path, java.lang.String msInfo)
          Specifies path to existing ISO9660 image to be merged.
static void setMkisofsCmd(java.lang.String str)
           
static void setMkzftreeCmd(java.lang.String str)
           
 void setNoDeepRelocation(boolean b)
          Do not use deep directory relocation, and instead just pack them in the way we see them.
 void setNoIsoTranslate(boolean b)
          Do not translate the characters '#' and '~' which are invalid for ISO9660 filenames.
 void setOmitTrailingPeriod(boolean b)
          Omit trailing period from files that do not have a period.
 void setOmitVersionNumbers(boolean b)
          Omit version numbers from ISO9660 file names.
 void setPad(boolean b)
          Pad the end of the ISO9660 by 16 sectors (32kB).
 void setPreparerId(java.lang.String str)
          Specifies a text string that will be written into the volume header.
 void setPublisherId(java.lang.String str)
          Specifies a text string that will be written into the volume header.
 void setSloppy(boolean b)
          For compressed filesystems only: Treat file modes, times and ownership data as less than precious information and don't abort if they cannot be set.
 void setSparcBootImages(java.lang.String paths)
          Specifies a comma separated list of boot images that are needed to make a bootable CD for sparc systems.
 void setSystemId(java.lang.String str)
          Specifies the system ID.
 void setUseExtendedRockRidge(boolean b)
          This is like setUseRockRidge, but file ownership and modes are set to more useful values.
 void setUseFileVersions(boolean b)
          Use file version numbers from the filesystem.
 void setUseJoliet(boolean b)
          Generate Joliet directory records in addition to regular ISO9660 file names.
 void setUseRelaxedFilenames(boolean b)
          Allows ISO9660 filenames to include digits, uppercase characters and all other 7 bit ASCII characters (resp.
 void setUseRockRidge(boolean b)
          Generate SUSP and RR records using the Rock Ridge protocol to further describe the files on the ISO9660 filesystem.
 void setUseUntranslatedNames(boolean b)
          Allows "Untranslated" filenames, violating the ISO9660 standards.
 void setVolsetId(java.lang.String str)
          Specifies the volset ID.
 void setVolsetSeqNum(int n)
          Sets the volume set sequence number.
 void setVolsetSize(int n)
          Sets the volume set size.
 void setVolumeId(java.lang.String str)
          Specifies the volume ID (volume name or label) to be written into the master block.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ISOFsImg

public ISOFsImg()
Method Detail

setAbstract

public void setAbstract(java.lang.String txt)
Parameters:
txt -  

setCompressed

public void setCompressed(boolean b)
Generate special RRIP records for transparently compressed files. This is only of use and interest for hosts that support transparent decompression, such as Linux 2.4.14 or later. Note that transparent compression is a nonstandard Rock Ridge extension. The resulting disks are only transparently readable if used on Linux. On other operating systems you will need to call mkzftree by hand to decompress the files.

mkzftree is in the zisofs-tools package, available from: http://www.kernel.org/pub/linux/utils/fs/zisofs/

If you call setCompressed(true):

- You must call addFile(String) exactly once, with the argument equal to the path to a directory.
- Do not call addFile(String,String)


setCompressLevel

public void setCompressLevel(int n)
Select compression level (1-9, default is 9) for compressed filesystems. Lower compression levels are faster, but typically result in larger output.

setSloppy

public void setSloppy(boolean b)
For compressed filesystems only: Treat file modes, times and ownership data as less than precious information and don't abort if they cannot be set. This may be useful on an input tree you do not own.

addHideGlob

public void addHideGlob(java.lang.String glob)
Hide glob from being seen on the ISO9660 or Rock Ridge directory. glob is a shell wild-card-style pattern that must match any part of the filename or path. Multiple globs may be hidden. If glob matches a directory, then the contents of that directory will be hidden. All the hidden files will still be written to the output CD image file. Should be used with addHideJoliet.
Parameters:
glob -  

addHiddenGlob

public void addHiddenGlob(java.lang.String glob)
Add the hidden (existence) ISO9660 directory attribute for glob. This attribute will prevent glob from being listed on DOS based systems if the /A flag is not used for the listing. glob is a shell wild-card-style pattern that must match any part of the filename or path. Multiple globs may be hidden.
Parameters:
glob -  

addExclude

public void addExclude(java.lang.String glob)
Exclude glob from being written to CDROM. glob is a shell wild-card-style pattern that matches the path of files to be excluded.
Parameters:
glob -  

setExcludeBackupFiles

public void setExcludeBackupFiles(boolean b)
Do not include backup files files on the ISO9660 filesystem. Files that contain the characters '~' or '#' or end in '.bak' will not be included (these are typically backup files for editors under unix).
Parameters:
b -  

setDirectory

public void setDirectory(java.lang.String dir)
Sets the base directory, from which relative paths are resolved.
Parameters:
dir -  

addFile

public void addFile(java.lang.String f)
Adds a file to the archive.
Parameters:
f -  

addFile

public void addFile(java.lang.String f,
                    java.lang.String path)
Adds a file to the archive at the specified graft point.
Parameters:
f -  
path -  

setMergePath

public void setMergePath(java.lang.String path,
                         java.lang.String msInfo)
Specifies path to existing ISO9660 image to be merged.
Parameters:
path -  
msInfo -  

setMergeDevice

public void setMergeDevice(CDRDrive dev)
Specifies device with previous iso image to be merged.
Parameters:
dev -  

setApplicationId

public void setApplicationId(java.lang.String txt)
Specifies a text string that will be written into the volume header. This should describe the application that will be on the disc. There is space on the disc for 128 characters of information.
Parameters:
txt -  

setBibliographic

public void setBibliographic(java.lang.String txt)
Parameters:
txt -  

setCopyright

public void setCopyright(java.lang.String str)
Parameters:
str -  

setPublisherId

public void setPublisherId(java.lang.String str)
Specifies a text string that will be written into the volume header. This should describe the publisher of the CDROM, usually with a mailing address and phone number. There is space on the disc for 128 characters of information.
Parameters:
str -  

setPreparerId

public void setPreparerId(java.lang.String str)
Specifies a text string that will be written into the volume header. This should describe the preparer of the CDROM, usually with a mailing address and phone number. There is space on the disc for 128 characters of information.
Parameters:
str -  

setSystemId

public void setSystemId(java.lang.String str)
Specifies the system ID.
Parameters:
str -  

setVolumeId

public void setVolumeId(java.lang.String str)
Specifies the volume ID (volume name or label) to be written into the master block. Note that if you assign a volume ID, this is the name that will be used as the mount point used by the Solaris volume management system and the name that is assigned to the disc on a Windows or Mac platform.
Parameters:
str -  

setVolsetId

public void setVolsetId(java.lang.String str)
Specifies the volset ID.
Parameters:
str -  

setVolsetSize

public void setVolsetSize(int n)
Sets the volume set size. The volume set size is the number of CDs that are in a CD set.
Parameters:
n -  

setVolsetSeqNum

public void setVolsetSeqNum(int n)
Sets the volume set sequence number. The volume set sequence number is the index number of the current CD in a CD set.
Parameters:
n -  

setIsoLevel

public void setIsoLevel(int l)
Set the iso9660 conformance level. Valid numbers are 1..4.

With level 1, files may only consist of one section and filenames are restricted to 8.3 characters.

With level 2, files may only consist of one section.

With level 3, no restrictions apply.

With level 4, 207 chars are allowed in filenames, 197 with Rock Ridge.

With all iso9660 levels all filenames are restricted to upper case letters, numbers and the underscore (_). The maximum filename length is restricted to 31 characters (for levels 1-3), the directory nesting level is restricted to 8 and the maximum path length is limited to 255 characters.

Parameters:
l -  

setUseRockRidge

public void setUseRockRidge(boolean b)
Generate SUSP and RR records using the Rock Ridge protocol to further describe the files on the ISO9660 filesystem.
Parameters:
b -  

setUseExtendedRockRidge

public void setUseExtendedRockRidge(boolean b)
This is like setUseRockRidge, but file ownership and modes are set to more useful values. The uid and gid are set to zero, because they are usually only useful on the author's system, and not useful to the client. All the file read bits are set true, so that files and directories are globally readable on the client. If any execute bit is set for a file, set all of the execute bits, so that executa- bles are globally executable on the client. If any search bit is set for a directory, set all of the search bits, so that directories are globally searchable on the client. All write bits are cleared, because the CD-Rom will be mounted read- only in any case. If any of the special mode bits are set, clear them, because file locks are not useful on a read-only file system, and set-id bits are not desirable for uid 0 or gid 0. When used on Win32, the execute bit is set on all files. This is a result of the lack of file permissions on Win32 and the Cygwin POSIX emulation layer.
Parameters:
b -  

setUseJoliet

public void setUseJoliet(boolean b)
Generate Joliet directory records in addition to regular ISO9660 file names. This is primarily useful when the discs are to be used on Windows-NT or Windows-95 machines. The Joliet filenames are specified in Unicode and each path component can be up to 64 Unicode characters long.
Parameters:
b -  

listJolietCharsets

public static java.lang.String[] listJolietCharsets()
Returns an array containing the possible values for setJolietCharset.
Returns:
array containg Joliet charset names.

setJolietCharset

public void setJolietCharset(java.lang.String charset)
Local charset that should be used for translating local file names into Joliet Unicode directory records. To get a 1:1 mapping, you may use default as charset name. The default initial values are cp437 on DOS based systems and iso8859-1 on all other systems.
Parameters:
charset -  

setJolietUnicodeLevel

public void setJolietUnicodeLevel(int n)
Set Unicode conformance level in the Joliet SVD. The default level is 3. It may be set to 1..3 using this option.
Parameters:
n -  

addHideJoliet

public void addHideJoliet(java.lang.String glob)
Hide glob from being seen on the Joliet directory. glob is a shell wild-card-style pattern that must match any part of the filename or path. Multiple globs may be hidden. If glob matches a directory, then the contents of that directory will be hidden. All the hidden files will still be written to the output CD image file. Should be used with the addHideGlob option.
Parameters:
glob -  

setAllowLowerCase

public void setAllowLowerCase(boolean b)
This options allows lower case characters to appear in ISO9660 filenames. This violates the ISO9660 standard, but it happens to work on some systems. Use with caution.
Parameters:
b -  

setAllowMultidot

public void setAllowMultidot(boolean b)
This options allows more than one dot to appear in ISO9660 filenames. A leading dot is not affected by this option, it may be allowed separately using the allowLeadingPeriod option. This violates the ISO9660 standard, but it happens to work on many systems. Use with caution.
Parameters:
b -  

setOmitTrailingPeriod

public void setOmitTrailingPeriod(boolean b)
Omit trailing period from files that do not have a period. This violates the ISO9660 standard, but it happens to work on many systems. Use with caution.
Parameters:
b -  

setNoDeepRelocation

public void setNoDeepRelocation(boolean b)
Do not use deep directory relocation, and instead just pack them in the way we see them. This violates the ISO9660 standard, but it happens to work on many systems. Use with caution.
Parameters:
b -  

setFollowSymlinks

public void setFollowSymlinks(boolean b)
Follow symbolic links when generating the filesystem. When this option is not in use, symbolic links will be entered using Rock Ridge if enabled, otherwise the file will be ignored.
Parameters:
b -  

setAllow31Filenames

public void setAllow31Filenames(boolean b)
Allow full 31 character filenames. Normally the ISO9660 filename will be in an 8.3 format which is compatible with MS-DOS, even though the ISO9660 standard allows filenames of up to 31 characters. If you use this option, the disc may be difficult to use on a MS-DOS system, but this comes in handy on some other systems (such as the Amiga). Use with caution.
Parameters:
b -  

setAllowLeadingPeriod

public void setAllowLeadingPeriod(boolean b)
Allow ISO9660 filenames to begin with a period. Usually, a leading dot is replaced with an under- score in order to maintain MS-DOS compatibility. This violates the ISO9660 standard, but it happens to work on many systems. Use with caution.
Parameters:
b -  

setAllow37Filenames

public void setAllow37Filenames(boolean b)
Allow 37 chars in ISO9660 filenames. This option forces the omitVersionNumbers option as the extra name space is taken from the space reserved for ISO9660 version numbers. This violates the ISO9660 standard, but it happens to work on many systems. Although a conforming application needs to provide a buffer space of at least 37 characters, disks created with this option may cause a buffer overflow in the reading operating system. Use with extreme care.
Parameters:
b -  

setOmitVersionNumbers

public void setOmitVersionNumbers(boolean b)
Omit version numbers from ISO9660 file names. This violates the ISO9660 standard, but no one really uses the version numbers anyway. Use with caution.
Parameters:
b -  

setUseRelaxedFilenames

public void setUseRelaxedFilenames(boolean b)
Allows ISO9660 filenames to include digits, uppercase characters and all other 7 bit ASCII characters (resp. anything except lowercase characters). This violates the ISO9660 standard, but it happens to work on many systems. Use with caution.
Parameters:
b -  

setGenerateTransTable

public void setGenerateTransTable(boolean b)
Generate a file TRANS.TBL in each directory on the CDROM, which can be used on non-Rock Ridge capable systems to help establish the correct file names. There is also information present in the file that indicates the major and minor numbers for block and character devices, and each symlink has the name of the link file given.
Parameters:
b -  

setUseFileVersions

public void setUseFileVersions(boolean b)
Use file version numbers from the filesystem. If the option is not specified, mkisofs creates a version of 1 for all files. File versions are strings in the range ;1 to ;32767.
Parameters:
b -  

setUseUntranslatedNames

public void setUseUntranslatedNames(boolean b)
Allows "Untranslated" filenames, violating the ISO9660 standards. Forces on the omitTrailingPeriod, allow31Filenames, allowLeadingPeriod, omitVersionNumbers, useRelaxedFilenames, allowLowerCase, allowMultidot and noIsoTranslate flags. It allows more than one '.' character in the filename, as well as mixed case filenames. This is useful on HP-UX systems, where the built-in CDFS filesystem does not recognize ANY extensions. Use with extreme caution.
Parameters:
b -  

setNoIsoTranslate

public void setNoIsoTranslate(boolean b)
Do not translate the characters '#' and '~' which are invalid for ISO9660 filenames. These charac- ters are though invalid often used by Microsoft systems. This violates the ISO9660 standard, but it happens to work on many systems. Use with caution.
Parameters:
b -  

setEltoritoBootImage

public void setEltoritoBootImage(java.lang.String path)
Specifies the path and filename of the boot image to be used when making an "El Torito" bootable CD. The pathname must be relative to the source path specified to mkisofs. This option is required to make an "El Torito" bootable CD. The boot image must be exactly the size of either a 1.2, 1.44, or a 2.88 meg floppy, and mkisofs will use this size when creating the output ISO9660 filesystem. It is assumed that the first 512 byte sector should be read from the boot image (it is essentially emulating a normal floppy drive). This will work, for example, if the boot image is a LILO based boot floppy.
Parameters:
b -  

setSparcBootImages

public void setSparcBootImages(java.lang.String paths)
Specifies a comma separated list of boot images that are needed to make a bootable CD for sparc systems. There may be empty fields in the comma separated list. This option is required to make a bootable CD for Sun sparc systems. If this option has been specified, the first sector of the resulting image will contain a Sun disk label. This disk label specifies slice 0 for the ISO9660 image and slice 1 ... slice 7 for the boot images that have been specified with this option. Byte offset 512 ... 8191 within each of the additional boot images must contain a primary boot that works for the appropriate sparc architecture. The rest of each of the images usually contains an ufs filesystem that is used primary kernel boot stage. The implemented boot method is the boot method found with SunOS 4.x and SunOS 5.x. However, it does not depend on SunOS internals but only on properties of the Open Boot prom. For this reason, it should be usable for any OS that boots off a sparc system. If the special filename ... is used, the actual and all following boot partitions are mapped to the previous partition. If used with setGenericBootImage(image); setSparcBootImages("..."); all boot partitions are mapped to the partition that contains the ISO9660 filesystem image and the generic boot image that is located in the first 16 sectors of the disk is used for all architectures.
Parameters:
paths -  

setGenericBootImage

public void setGenericBootImage(java.lang.String path)
Specifies the path and filename of the generic boot image to be used when making a generic bootable CD. The generic_boot_image will be placed on the first 16 sectors of the CD. The first 16 sectors are the sectors that are located before the ISO9660 primary volume descriptor. If this option is used together with setSparcBootImages, the Sun disk label will overlay the first 512 bytes of the generic boot image.
Parameters:
path -  

setBootCatalogPath

public void setBootCatalogPath(java.lang.String path)
Specifies the path and filename of the boot catalog to be used when making an "El Torito" bootable CD. The pathname must be relative to the path specified in setDirectory(). This option is required to make a bootable CD. This file will be inserted into the output tree and not created in the source filesystem, so be sure the specified filename does not conflict with an existing file, as it will be excluded. Usually a name like "boot.catalog" is chosen.
Parameters:
path -  

setPad

public void setPad(boolean b)
Pad the end of the ISO9660 by 16 sectors (32kB). If the total size then is not a multiple of 16 sectors, the needed number of sectors is added. If the option setSparcBootImages is used, then there is a second padding at the end of the boot partitions. The padding is needed as many operating systems (e.g. Linux) implement read ahead bugs in their filesystem I/O. These bugs result in read errors on one or more files that are located at the end of a track. They are usually present when the CD is written in Track at Once mode or when the disk is written as mixed mode CD where an audio track follows the data track.
Parameters:
b -  

getImage

public java.io.InputStream getImage()
                             throws java.lang.Exception
Runs mkisofs and starts streaming its output.
Returns:
the output stream containing the ISO image.
Throws:
java.lang.Exception -  

getImage

public java.io.InputStream getImage(ProgressListener pl)
                             throws java.lang.Exception
Runs mkisofs and starts streaming its output.
Parameters:
pl - the progress listener callback.
Returns:
the output stream containing the ISO image.
Throws:
java.lang.Exception -  

isFinished

public boolean isFinished()

getErrorOutput

public java.lang.String getErrorOutput()
Returns:
the error output from mkisofs.

setMkisofsCmd

public static void setMkisofsCmd(java.lang.String str)
                          throws java.lang.Exception
Parameters:
str -  
Throws:
java.lang.Exception -  

setMkzftreeCmd

public static void setMkzftreeCmd(java.lang.String str)
                           throws java.lang.Exception
Parameters:
str -  
Throws:
java.lang.Exception -  

getVersions

public static java.lang.String getVersions()

isSuccess

public boolean isSuccess()
                  throws java.lang.Exception
Call this after reading the file image to see if the operation is successful.
Throws:
java.lang.Exception -