Package totalcross.util.zip
Class TCZ
- java.lang.Object
-
- totalcross.util.zip.TCZ
-
public class TCZ extends java.lang.ObjectA tcz (TotalCross Zip) file has the following format:- version (2 bytes)
- attributes (2 bytes)
- base offset (header size + 4)
- header
- compressed data chunks
- length (4 bytes)
- offsets array (length+1) - offset[i+1]-offset[i] gives the compressed size
- uncompressed sizes array (length)
- names array (length)
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classTCZ.EntryAn entry of the TCZ file.
-
Field Summary
Fields Modifier and Type Field Description intattrThe attributes.static shortATTR_HAS_MAINCLASSDefines that the tcz file has a MainClass at the first record.static shortATTR_HAS_MAINWINDOWDefines that the tcz file has a MainWindow at the first record.static shortATTR_LIBRARYDefines that the tcz file is a library-only module.static shortATTR_RESIZABLE_WINDOWDefines that the application has resizable window.static shortATTR_WINDOWFONT_DEFAULTDefines that the application uses the default font.static shortATTR_WINDOWSIZE_320X480Defines that the application uses the given window size.static shortATTR_WINDOWSIZE_480X640Defines that the application uses the given window size.static shortATTR_WINDOWSIZE_600X800Defines that the application uses the given window size.java.lang.ObjectbagBag that can be used to store anything that the user wants.static java.lang.StringmainClassNameSet this to be the main class name.java.lang.String[]namesThe names of the files.intnumberOfChunksThe number of chunks.int[]offsetsOffsets to the compressed data chunksintsizeStores the total size when a TCZ file is created.static shortTCZ_VERSIONint[]uncompressedSizesSizes of the data chunks when they are uncompressed.intversionVersion of the tcz file.
-
Constructor Summary
Constructors Constructor Description TCZ(Stream fin)Reads a TCZ file and fill the public members available in this class: version, attr, baseOffset, offsets, uncompressedSizes, names, chunks, numberOfChunks.TCZ(Vector vout, java.lang.String outName, short attr)Create a TCZ file with the given vector of Entry(s).
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intfindNamePosition(java.lang.String name)Finds the position of the given name in this tcz.intgetNextChunkSize()Returns the size of the next available chunkvoidreadNextChunk(Stream out)Fills the given stream with the next available chunk.
-
-
-
Field Detail
-
mainClassName
public static java.lang.String mainClassName
Set this to be the main class name. It is stored in record #0.
-
TCZ_VERSION
public static final short TCZ_VERSION
- See Also:
- Constant Field Values
-
ATTR_HAS_MAINCLASS
public static final short ATTR_HAS_MAINCLASS
Defines that the tcz file has a MainClass at the first record. If false, it is a library-only module- See Also:
- Constant Field Values
-
ATTR_HAS_MAINWINDOW
public static final short ATTR_HAS_MAINWINDOW
Defines that the tcz file has a MainWindow at the first record.- See Also:
- Constant Field Values
-
ATTR_LIBRARY
public static final short ATTR_LIBRARY
Defines that the tcz file is a library-only module.- See Also:
- Constant Field Values
-
ATTR_RESIZABLE_WINDOW
public static final short ATTR_RESIZABLE_WINDOW
Defines that the application has resizable window.- See Also:
- Constant Field Values
-
ATTR_WINDOWFONT_DEFAULT
public static final short ATTR_WINDOWFONT_DEFAULT
Defines that the application uses the default font.- See Also:
- Constant Field Values
-
ATTR_WINDOWSIZE_320X480
public static final short ATTR_WINDOWSIZE_320X480
Defines that the application uses the given window size.- See Also:
- Constant Field Values
-
ATTR_WINDOWSIZE_480X640
public static final short ATTR_WINDOWSIZE_480X640
Defines that the application uses the given window size.- See Also:
- Constant Field Values
-
ATTR_WINDOWSIZE_600X800
public static final short ATTR_WINDOWSIZE_600X800
Defines that the application uses the given window size.- See Also:
- Constant Field Values
-
names
public java.lang.String[] names
The names of the files.
-
attr
public int attr
The attributes.
-
version
public int version
Version of the tcz file.- See Also:
TCZ_VERSION
-
offsets
public int[] offsets
Offsets to the compressed data chunks
-
uncompressedSizes
public int[] uncompressedSizes
Sizes of the data chunks when they are uncompressed.
-
numberOfChunks
public int numberOfChunks
The number of chunks.
-
size
public int size
Stores the total size when a TCZ file is created.
-
bag
public java.lang.Object bag
Bag that can be used to store anything that the user wants.
-
-
Constructor Detail
-
TCZ
public TCZ(Vector vout, java.lang.String outName, short attr) throws IOException, ZipException
Create a TCZ file with the given vector of Entry(s).- Throws:
IOExceptionZipException
-
TCZ
public TCZ(Stream fin) throws IOException
Reads a TCZ file and fill the public members available in this class: version, attr, baseOffset, offsets, uncompressedSizes, names, chunks, numberOfChunks. To preserve memory, you must request each chunk using readNextChunk right after you call this constructor.- Throws:
IOException
-
-
Method Detail
-
getNextChunkSize
public int getNextChunkSize()
Returns the size of the next available chunk
-
readNextChunk
public void readNextChunk(Stream out) throws IOException
Fills the given stream with the next available chunk. The size of the chunk can be retrieved with getNextChunkSize. If out is a ByteArrayStream, don't forget to call reset before starting to read from it!- Throws:
IOException
-
findNamePosition
public int findNamePosition(java.lang.String name)
Finds the position of the given name in this tcz.
-
-