summaryrefslogtreecommitdiffstats
path: root/tdejava/koala/org/trinitydesktop/koala/KZip.java
blob: 7ef3776927038a7ea4c00d1afcafa008190ec329 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
//Auto-generated by kalyptus. DO NOT EDIT.
package org.trinitydesktop.koala;

import org.trinitydesktop.qt.Qt;
import org.trinitydesktop.qt.QtSupport;
import org.trinitydesktop.qt.TQIODevice;
import org.trinitydesktop.qt.TQIODeviceInterface;

/**

   This class implements a tdeioslave 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
		@author Holger Schroeder <holger-kde@holgis.net>

		@short A class for reading/writing zip archives.

*/
public class KZip extends KArchive  {
	protected KZip(Class dummy){super((Class) null);}
	/**
		 Describes the contents of the "extra field" for a given file in the Zip archive.
		     		@short    Describes the contents of the "extra field" for a given file in the Zip archive.
	*/
	public static final int NoExtraField = 0;
	public static final int ModificationTime = 1;
	public static final int DefaultExtraField = 1;

	/**
		 Describes the compression type for a given file in the Zip archive.
		     		@short    Describes the compression type for a given file in the Zip archive.
	*/
	public static final int NoCompression = 0;
	public static final int DeflateCompression = 1;

	/**
		 Creates an instance that operates on the given filename.
		 using the compression filter associated to given mimetype.
			@param filename is a local path (e.g. "/home/holger/myfile.zip")
		     		@short    Creates an instance that operates on the given filename.
	*/
	public KZip(String filename) {
		super((Class) null);
		newKZip(filename);
	}
	private native void newKZip(String filename);
	/**
		 Creates an instance that operates on the given device.
		 The device can be compressed (KFilterDev) or not (TQFile, etc.).
		 @warning Do not assume that giving a TQFile here will decompress the file,
		 in case it's compressed!
			@param dev the device to access
		     		@short    Creates an instance that operates on the given device.
	*/
	public KZip(TQIODeviceInterface dev) {
		super((Class) null);
		newKZip(dev);
	}
	private native void newKZip(TQIODeviceInterface dev);
	/**
		 The name of the zip file, as passed to the constructor.
		 Null if you used the TQIODevice constructor.
				@return the zip's file name, or null if a TQIODevice is used

		@short    The name of the zip file, as passed to the constructor.
	*/
	public native String fileName();
	/**
		 Call this before writeFile or prepareWriting, to define what the next
		 file to be written should have in its extra field.
			@param ef the type of "extra field"
				@short    Call this before writeFile or prepareWriting, to define what the next  file to be written should have in its extra field.
		@see #extraField
	*/
	public native void setExtraField(int ef);
	/**
		 The current type of "extra field" that will be used for new files.
				@return the current type of "extra field"

		@short    The current type of "extra field" that will be used for new files.
		@see #setExtraField
	*/
	public native int extraField();
	/**
		 Call this before writeFile or prepareWriting, to define whether the next
		 files to be written should be compressed or not.
			@param c the new compression mode
				@short    Call this before writeFile or prepareWriting, to define whether the next  files to be written should be compressed or not.
		@see #compression
	*/
	public native void setCompression(int c);
	/**
		 The current compression mode that will be used for new files.
				@return the current compression mode

		@short    The current compression mode that will be used for new files.
		@see #setCompression
	*/
	public native int compression();
	/**
		 If an archive is opened for writing then you can add a new file
		 using this function.
		 This method takes the whole data at once.
			@param name can include subdirs e.g. path/to/the/file
			@param user the user owning the file
			@param group the group owning the file
			@param size the size of the file
			@param data a pointer to the data
				@return true if successful, false otherwise

		@short    If an archive is opened for writing then you can add a new file  using this function.
	*/
	public native boolean writeFile(String name, String user, String group, int size, String data);
	/**
		 Alternative method for writing: call prepareWriting(), then feed the data
		 in small chunks using writeData(), and call doneWriting() when done.
			@param name can include subdirs e.g. path/to/the/file
			@param user the user owning the file
			@param group the group owning the file
			@param size unused argument
				@return true if successful, false otherwise

		@short    Alternative method for writing: call prepareWriting(), then feed the data  in small chunks using writeData(), and call doneWriting() when done.
	*/
	public native boolean prepareWriting(String name, String user, String group, int size);
	public native boolean writeSymLink(String name, String target, String user, String group, long perm, int atime, int mtime, int ctime);
	public native boolean prepareWriting(String name, String user, String group, int size, long perm, int atime, int mtime, int ctime);
	public native boolean writeFile(String name, String user, String group, int size, long perm, int atime, int mtime, int ctime, String data);
	/**
		 Write data to a file that has been created using prepareWriting().
			@param data a pointer to the data
			@param size the size of the chunk
				@return true if successful, false otherwise

		@short    Write data to a file that has been created using prepareWriting().
	*/
	public native boolean writeData(String data, int size);
	/**
		 Write data to a file that has been created using prepareWriting().
			@param size the size of the file
				@return true if successful, false otherwise

		@short    Write data to a file that has been created using prepareWriting().
	*/
	public native boolean doneWriting(int size);
	/**
		 Opens the archive for reading.
		 Parses the directory listing of the archive
		 and creates the KArchiveDirectory/KArchiveFile entries.
			@param mode the mode of the file
		     		@short    Opens the archive for reading.
	*/
	protected native boolean openArchive(int mode);
	protected native boolean closeArchive();
	/**
			     		@short
	*/
	public native boolean writeDir(String name, String user, String group);
	/**	 @internal for virtual_hook 		@short   @internal for virtual_hook
	*/
	protected native boolean writeData_impl(String data, int size);
	protected native boolean prepareWriting_impl(String name, String user, String group, int size, long perm, int atime, int mtime, int ctime);
	protected native boolean writeSymLink_impl(String name, String target, String user, String group, long perm, int atime, int mtime, int ctime);
	/** Deletes the wrapped C++ instance */
	protected native void finalize() throws InternalError;
	/** Delete the wrapped C++ instance ahead of finalize() */
	public native void dispose();
	/** Has the wrapped C++ instance been deleted? */
	public native boolean isDisposed();
}