|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.kde.koala.KArchive
org.kde.koala.KZip
public class KZip
This class implements a kioslave to access zip files from KDE. You can use it in IO_ReadOnly or in IO_WriteOnly mode, and it behaves just as expected. It can also be used in IO_ReadWrite mode, in this case one can append files to an existing zip archive. When you append new files, which are not yet in the zip, it works as expected, i.e. the files are appended at the end. When you append a file, which is already in the file, the reference to the old file is dropped and the new one is added to the zip - but the old data from the file itself is not deleted, it is still in the zipfile. so when you want to have a small and garbage-free zipfile, just read the contents of the appended zip file and write it to a new one in IO_WriteOnly mode. This is especially important when you don't want to leak information of how intermediate versions of files in the zip were looking. For more information on the zip fileformat go to http://www.pkware.com/products/enterprise/white_papers/appnote.html
Field Summary | |
---|---|
static int |
DefaultExtraField
|
static int |
DeflateCompression
|
static int |
ModificationTime
|
static int |
NoCompression
Describes the compression type for a given file in the Zip archive. |
static int |
NoExtraField
Describes the contents of the "extra field" for a given file in the Zip archive. |
Fields inherited from class org.kde.koala.KArchive |
---|
VIRTUAL_PREPARE_WRITING, VIRTUAL_WRITE_DATA, VIRTUAL_WRITE_DIR, VIRTUAL_WRITE_FILE, VIRTUAL_WRITE_SYMLINK |
Constructor Summary | |
---|---|
protected |
KZip(java.lang.Class dummy)
|
|
KZip(org.kde.qt.QIODeviceInterface dev)
Creates an instance that operates on the given device. |
|
KZip(java.lang.String filename)
Creates an instance that operates on the given filename. |
Method Summary | |
---|---|
protected boolean |
closeArchive()
|
int |
compression()
The current compression mode that will be used for new files. |
void |
dispose()
Delete the wrapped C++ instance ahead of finalize() |
boolean |
doneWriting(int size)
Write data to a file that has been created using prepareWriting(). |
int |
extraField()
The current type of "extra field" that will be used for new files. |
java.lang.String |
fileName()
The name of the zip file, as passed to the constructor. |
protected void |
finalize()
Deletes the wrapped C++ instance |
boolean |
isDisposed()
Has the wrapped C++ instance been deleted? |
protected boolean |
openArchive(int mode)
Opens the archive for reading. |
protected boolean |
prepareWriting_impl(java.lang.String name,
java.lang.String user,
java.lang.String group,
int size,
long perm,
int atime,
int mtime,
int ctime)
|
boolean |
prepareWriting(java.lang.String name,
java.lang.String user,
java.lang.String group,
int size)
Alternative method for writing: call prepareWriting(), then feed the data in small chunks using writeData(), and call doneWriting() when done. |
boolean |
prepareWriting(java.lang.String name,
java.lang.String user,
java.lang.String group,
int size,
long perm,
int atime,
int mtime,
int ctime)
Here's another way of writing a file into an archive: Call prepareWriting, then call writeData() as many times as wanted then call doneWriting( totalSize ). |
void |
setCompression(int c)
Call this before writeFile or prepareWriting, to define whether the next files to be written should be compressed or not. |
void |
setExtraField(int ef)
Call this before writeFile or prepareWriting, to define what the next file to be written should have in its extra field. |
protected boolean |
writeData_impl(java.lang.String data,
int size)
|
boolean |
writeData(java.lang.String data,
int size)
Write data to a file that has been created using prepareWriting(). |
boolean |
writeDir(java.lang.String name,
java.lang.String user,
java.lang.String group)
If an archive is opened for writing then you can add new directories using this function. |
boolean |
writeFile(java.lang.String name,
java.lang.String user,
java.lang.String group,
int size,
long perm,
int atime,
int mtime,
int ctime,
java.lang.String data)
If an archive is opened for writing then you can add a new file using this function. |
boolean |
writeFile(java.lang.String name,
java.lang.String user,
java.lang.String group,
int size,
java.lang.String data)
If an archive is opened for writing then you can add a new file using this function. |
protected boolean |
writeSymLink_impl(java.lang.String name,
java.lang.String target,
java.lang.String user,
java.lang.String group,
long perm,
int atime,
int mtime,
int ctime)
|
boolean |
writeSymLink(java.lang.String name,
java.lang.String target,
java.lang.String user,
java.lang.String group,
long perm,
int atime,
int mtime,
int ctime)
Writes a symbolic link to the archive if the archive must be opened for writing. |
Methods inherited from class org.kde.koala.KArchive |
---|
addLocalDirectory, addLocalFile, close, closeSucceeded, device, directory, isOpened, mode, open, writeDir |
Methods inherited from class java.lang.Object |
---|
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int NoExtraField
public static final int ModificationTime
public static final int DefaultExtraField
public static final int NoCompression
public static final int DeflateCompression
Constructor Detail |
---|
protected KZip(java.lang.Class dummy)
public KZip(java.lang.String filename)
filename
- is a local path (e.g. "/home/holger/myfile.zip")public KZip(org.kde.qt.QIODeviceInterface dev)
dev
- the device to accessMethod Detail |
---|
public java.lang.String fileName()
public void setExtraField(int ef)
ef
- the type of "extra field"extraField()
public int extraField()
setExtraField(int)
public void setCompression(int c)
c
- the new compression modecompression()
public int compression()
setCompression(int)
public boolean writeFile(java.lang.String name, java.lang.String user, java.lang.String group, int size, java.lang.String data)
writeFile
in class KArchive
name
- can include subdirs e.g. path/to/the/fileuser
- the user owning the filegroup
- the group owning the filesize
- the size of the filedata
- a pointer to the data
public boolean prepareWriting(java.lang.String name, java.lang.String user, java.lang.String group, int size)
prepareWriting
in class KArchive
name
- can include subdirs e.g. path/to/the/fileuser
- the user owning the filegroup
- the group owning the filesize
- unused argument
public boolean writeSymLink(java.lang.String name, java.lang.String target, java.lang.String user, java.lang.String group, long perm, int atime, int mtime, int ctime)
KArchive
writeSymLink
in class KArchive
name
- name of symbolic linktarget
- target of symbolic linkuser
- the user that owns the directorygroup
- the group that owns the directoryperm
- permissions of the directoryatime
- time the file was last accessedmtime
- modification time of the filectime
- creation time of the filepublic boolean prepareWriting(java.lang.String name, java.lang.String user, java.lang.String group, int size, long perm, int atime, int mtime, int ctime)
KArchive
prepareWriting
in class KArchive
name
- the name of the fileuser
- the user that owns the filegroup
- the group that owns the filesize
- the size of the fileperm
- permissions of the fileatime
- time the file was last accessedmtime
- modification time of the filectime
- creation time of the filepublic boolean writeFile(java.lang.String name, java.lang.String user, java.lang.String group, int size, long perm, int atime, int mtime, int ctime, java.lang.String data)
KArchive
writeFile
in class KArchive
name
- the name of the fileuser
- the user that owns the filegroup
- the group that owns the filesize
- the size of the fileperm
- permissions of the fileatime
- time the file was last accessedmtime
- modification time of the filectime
- creation time of the filedata
- the data to write (size
bytes)public boolean writeData(java.lang.String data, int size)
writeData
in class KArchive
data
- a pointer to the datasize
- the size of the chunk
public boolean doneWriting(int size)
doneWriting
in class KArchive
size
- the size of the file
KArchive.prepareWriting(java.lang.String, java.lang.String, java.lang.String, int)
protected boolean openArchive(int mode)
mode
- the mode of the fileprotected boolean closeArchive()
public boolean writeDir(java.lang.String name, java.lang.String user, java.lang.String group)
KArchive
writeDir
in class KArchive
name
- the name of the directoryuser
- the user that owns the directorygroup
- the group that owns the directoryprotected boolean writeData_impl(java.lang.String data, int size)
protected boolean prepareWriting_impl(java.lang.String name, java.lang.String user, java.lang.String group, int size, long perm, int atime, int mtime, int ctime)
protected boolean writeSymLink_impl(java.lang.String name, java.lang.String target, java.lang.String user, java.lang.String group, long perm, int atime, int mtime, int ctime)
protected void finalize() throws java.lang.InternalError
finalize
in class java.lang.Object
java.lang.InternalError
public void dispose()
public boolean isDisposed()
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |