org.kde.koala

Class KArchive

public class KArchive extends Object implements QtSupport

KArchive is a base class for reading and writing archives.

Author: David Faure

UNKNOWN: generic class for reading/writing archives.

Field Summary
static intVIRTUAL_PREPARE_WRITING
static intVIRTUAL_WRITE_DATA
static intVIRTUAL_WRITE_DIR
static intVIRTUAL_WRITE_FILE
static intVIRTUAL_WRITE_SYMLINK
Constructor Summary
protected KArchive(Class dummy)
Method Summary
booleanaddLocalDirectory(String path, String destName)
Writes a local directory into the archive, including all its contents, recursively.
booleanaddLocalFile(String fileName, String destName)
Writes a local file into the archive.
voidclose()
Closes the archive.
booleancloseSucceeded()
Use to check if close had any problem
QIODeviceInterfacedevice()
The underlying device.
KArchiveDirectorydirectory()
If an archive is opened for reading, then the contents of the archive can be accessed via this function.
booleandoneWriting(int size)
Call doneWriting after writing the data.
booleanisOpened()
Checks whether the archive is open.
intmode()
Returns the mode in which the archive was opened
booleanopen(int mode)
Opens the archive for reading or writing.
booleanprepareWriting(String name, String user, String group, int size)
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 ).
booleanprepareWriting(String name, String user, 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 ).
booleanwriteData(String data, int size)
Write data into the current file - to be called after calling prepareWriting
booleanwriteDir(String name, String user, String group)
If an archive is opened for writing then you can add new directories using this function.
booleanwriteDir(String name, String user, String group, long perm, int atime, int mtime, int ctime)
If an archive is opened for writing then you can add new directories using this function.
booleanwriteFile(String name, String user, String group, int size, String data)
If an archive is opened for writing then you can add a new file using this function.
booleanwriteFile(String name, String user, String group, int size, long perm, int atime, int mtime, int ctime, String data)
If an archive is opened for writing then you can add a new file using this function.
booleanwriteSymLink(String name, String target, String user, 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.

Field Detail

VIRTUAL_PREPARE_WRITING

public static final int VIRTUAL_PREPARE_WRITING

VIRTUAL_WRITE_DATA

public static final int VIRTUAL_WRITE_DATA

VIRTUAL_WRITE_DIR

public static final int VIRTUAL_WRITE_DIR

VIRTUAL_WRITE_FILE

public static final int VIRTUAL_WRITE_FILE

VIRTUAL_WRITE_SYMLINK

public static final int VIRTUAL_WRITE_SYMLINK

Constructor Detail

KArchive

protected KArchive(Class dummy)

Method Detail

addLocalDirectory

public boolean addLocalDirectory(String path, String destName)
Writes a local directory into the archive, including all its contents, recursively. Calls addLocalFile for each file to be added. Since KDE 3.2 it will also add a path that is a symbolic link to a directory. The symbolic link will be dereferenced and the content of the directory it is pointing to added recursively. However, symbolic links under path will be stored as is.

Parameters: path full path to an existing local directory, to be added to the archive. destName the resulting name (or relative path) of the file in the archive.

UNKNOWN: Writes a local directory into the archive, including all its contents, recursively.

addLocalFile

public boolean addLocalFile(String fileName, String destName)
Writes a local file into the archive. The main difference with writeFile, is that this method minimizes memory usage, by not loading the whole file into memory in one go. If fileName is a symbolic link, it will be written as is, i. e. it will not be resolved before.

Parameters: fileName full path to an existing local file, to be added to the archive. destName the resulting name (or relative path) of the file in the archive.

UNKNOWN: Writes a local file into the archive.

close

public void close()
Closes the archive. Inherited classes might want to reimplement closeArchive instead.

See Also: KArchive

UNKNOWN: Closes the archive.

closeSucceeded

public boolean closeSucceeded()
Use to check if close had any problem

Returns: true if close succeded without problems

UNKNOWN: Use to check if close had any problem

device

public QIODeviceInterface device()
The underlying device.

Returns: the underlying device.

UNKNOWN: The underlying device.

directory

public KArchiveDirectory directory()
If an archive is opened for reading, then the contents of the archive can be accessed via this function.

Returns: the directory of the archive

UNKNOWN: If an archive is opened for reading, then the contents of the archive can be accessed via this function.

doneWriting

public boolean doneWriting(int size)
Call doneWriting after writing the data.

Parameters: size the size of the file

See Also: KArchive

UNKNOWN: Call doneWriting after writing the data.

isOpened

public boolean isOpened()
Checks whether the archive is open.

Returns: true if the archive is opened

UNKNOWN: Checks whether the archive is open.

mode

public int mode()
Returns the mode in which the archive was opened

Returns: the mode in which the archive was opened (IO_ReadOnly or IO_WriteOnly)

See Also: KArchive

UNKNOWN: Returns the mode in which the archive was opened

open

public boolean open(int mode)
Opens the archive for reading or writing. Inherited classes might want to reimplement openArchive instead.

Parameters: mode may be IO_ReadOnly or IO_WriteOnly

See Also: KArchive

UNKNOWN: Opens the archive for reading or writing.

prepareWriting

public boolean prepareWriting(String name, String user, String group, int size)
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 ). For tar.gz files, you need to know the size before hand, since it is needed in the header. For zip files, size isn't used.

Parameters: name the name of the file user the user that owns the file group the group that owns the file size the size of the file

UNKNOWN: TODO(BIC): make this a thin non-wrapper around prepareWriting(name,user,group,size,perm,atime,mtime,ctime) or eliminate it. 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 ).

prepareWriting

public boolean prepareWriting(String name, String user, 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 ). For tar.gz files, you need to know the size before hand, it is needed in the header! For zip files, size isn't used. This method also allows some file metadata to be set. However, depending on the archive type not all metadata might be regarded.

Parameters: name the name of the file user the user that owns the file group the group that owns the file size the size of the file perm permissions of the file atime time the file was last accessed mtime modification time of the file ctime creation time of the file

UNKNOWN: 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 ).

writeData

public boolean writeData(String data, int size)
Write data into the current file - to be called after calling prepareWriting

UNKNOWN: TODO(BIC) make virtual. For now virtual_hook allows reimplementing it. Write data into the current file - to be called after calling prepareWriting @todo TODO(BIC) make virtual.

writeDir

public boolean writeDir(String name, String user, String group)
If an archive is opened for writing then you can add new directories using this function. KArchive won't write one directory twice.

Parameters: name the name of the directory user the user that owns the directory group the group that owns the directory

UNKNOWN: TODO(BIC): make this a thin wrapper around writeDir(name,user,group,perm,atime,mtime,ctime) or eliminate it If an archive is opened for writing then you can add new directories using this function.

writeDir

public boolean writeDir(String name, String user, String group, long perm, int atime, int mtime, int ctime)
If an archive is opened for writing then you can add new directories using this function. KArchive won't write one directory twice. This method also allows some file metadata to be set. However, depending on the archive type not all metadata might be regarded.

Parameters: name the name of the directory user the user that owns the directory group the group that owns the directory perm permissions of the directory atime time the file was last accessed mtime modification time of the file ctime creation time of the file

UNKNOWN: If an archive is opened for writing then you can add new directories using this function.

writeFile

public boolean writeFile(String name, String user, String group, int size, String data)
If an archive is opened for writing then you can add a new file using this function. If the file name is for example "mydir/test1" then the directory "mydir" is automatically appended first if that did not happen yet.

Parameters: name the name of the file user the user that owns the file group the group that owns the file size the size of the file data the data to write (size bytes)

UNKNOWN: TODO(BIC): make this a thin non-wrapper around writeFile(name,user,group,size,perm,atime,mtime,ctime,data) If an archive is opened for writing then you can add a new file using this function.

writeFile

public boolean writeFile(String name, String user, String group, int size, long perm, int atime, int mtime, int ctime, String data)
If an archive is opened for writing then you can add a new file using this function. If the file name is for example "mydir/test1" then the directory "mydir" is automatically appended first if that did not happen yet. This method also allows some file metadata to be set. However, depending on the archive type not all metadata might be regarded.

Parameters: name the name of the file user the user that owns the file group the group that owns the file size the size of the file perm permissions of the file atime time the file was last accessed mtime modification time of the file ctime creation time of the file data the data to write (size bytes)

UNKNOWN: If an archive is opened for writing then you can add a new file using this function.

writeSymLink

public boolean writeSymLink(String name, String target, String user, 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.

Parameters: name name of symbolic link target target of symbolic link user the user that owns the directory group the group that owns the directory perm permissions of the directory atime time the file was last accessed mtime modification time of the file ctime creation time of the file

UNKNOWN: Writes a symbolic link to the archive if the archive must be opened for writing.