summaryrefslogtreecommitdiffstats
path: root/kdejava/koala/org/kde/koala/KArchive.java
blob: 5c5db0a4e244e9e8335c7128ba66c825e4331f9d (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
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
//Auto-generated by kalyptus. DO NOT EDIT.
package org.kde.koala;

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

/**

 KArchive is a base class for reading and writing archives.
		@author David Faure <faure@kde.org>
 
		@short generic class for reading/writing archives.

*/
public class KArchive implements QtSupport {
	private long _qt;
	private boolean _allocatedInJavaWorld = true;
	protected KArchive(Class dummy){}

	public static final int VIRTUAL_WRITE_DATA = 1;
	public static final int VIRTUAL_WRITE_SYMLINK = 2;
	public static final int VIRTUAL_WRITE_DIR = 3;
	public static final int VIRTUAL_WRITE_FILE = 4;
	public static final int VIRTUAL_PREPARE_WRITING = 5;

	/**	
		 Opens the archive for reading or writing.
		 Inherited classes might want to reimplement openArchive instead.
			@param mode may be IO_ReadOnly or IO_WriteOnly
				@short    Opens the archive for reading or writing.
		@see #close
	*/
	public native boolean open(int mode);
	/**	
		 Closes the archive.
		 Inherited classes might want to reimplement closeArchive instead.
				@short    Closes the archive.
		@see #open
	*/
	public native void close();
	/**	
		 Use to check if close had any problem
				@return true if close succeded without problems

		@short    Use to check if close had any problem
	*/
	public native boolean closeSucceeded();
	/**	
		 Checks whether the archive is open.
				@return true if the archive is opened
     
		@short    Checks whether the archive is open.
	*/
	public native boolean isOpened();
	/**	
		 Returns the mode in which the archive was opened
				@return the mode in which the archive was opened (IO_ReadOnly or IO_WriteOnly)

		@short    Returns the mode in which the archive was opened 
		@see #open
	*/
	public native int mode();
	/**	
		 The underlying device.
				@return the underlying device.
     
		@short    The underlying device.
	*/
	public native TQIODeviceInterface device();
	/**	
		 If an archive is opened for reading, then the contents
		 of the archive can be accessed via this function.
				@return the directory of the archive
     
		@short    If an archive is opened for reading, then the contents  of the archive can be accessed via this function.
	*/
	public native KArchiveDirectory directory();
	/**	
		 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 <code>fileName</code> is a symbolic link, it will be written as is, i. e.
		 it will not be resolved before.
			@param fileName full path to an existing local file, to be added to the archive.
			@param destName the resulting name (or relative path) of the file in the archive.
		     		@short    Writes a local file into the archive.
	*/
	public native boolean addLocalFile(String fileName, 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 <code>path</code> 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 <code>path</code> will be stored as is.
			@param path full path to an existing local directory, to be added to the archive.
			@param destName the resulting name (or relative path) of the file in the archive.
		     		@short    Writes a local directory into the archive, including all its contents, recursively.
	*/
	public native boolean addLocalDirectory(String path, String destName);
	/**	
		 If an archive is opened for writing then you can add new directories
		 using this function. KArchive won't write one directory twice.
			@param name the name of the directory
			@param user the user that owns the directory
			@param group the group that owns the directory
			 @todo TODO(BIC): make this a thin wrapper around
		 writeDir(name,user,group,perm,atime,mtime,ctime)
		 or eliminate it
		     		@short    If an archive is opened for writing then you can add new directories  using this function.
	*/
	public native 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.
			 This method also allows some file metadata to be
		 set. However, depending on the archive type not all metadata might be
		 regarded.
			@param name the name of the directory
			@param user the user that owns the directory
			@param group the group that owns the directory
			@param perm permissions of the directory
			@param atime time the file was last accessed
			@param mtime modification time of the file
			@param ctime creation time of the file
				@short    If an archive is opened for writing then you can add new directories  using this function.
	*/
	public native boolean writeDir(String name, 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.
			@param name name of symbolic link
			@param target target of symbolic link
			@param user the user that owns the directory
			@param group the group that owns the directory
			@param perm permissions of the directory
			@param atime time the file was last accessed
			@param mtime modification time of the file
			@param ctime creation time of the file
				@short    Writes a symbolic link to the archive if the archive must be opened for  writing.
	*/
	public native boolean writeSymLink(String name, String target, String user, String group, long perm, int atime, int mtime, int ctime);
	/**	
		 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.
			@param name the name of the file
			@param user the user that owns the file
			@param group the group that owns the file
			@param size the size of the file
			@param data the data to write (<code>size</code> bytes)
		 @todo TODO(BIC): make this a thin non-wrapper around
		   writeFile(name,user,group,size,perm,atime,mtime,ctime,data)
		     		@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);
	/**	
		 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.
			@param name the name of the file
			@param user the user that owns the file
			@param group the group that owns the file
			@param size the size of the file
			@param perm permissions of the file
			@param atime time the file was last accessed
			@param mtime modification time of the file
			@param ctime creation time of the file
			@param data the data to write (<code>size</code> bytes)
				@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, long perm, int atime, int mtime, int ctime, String data);
	/**	
		 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.
			@param name the name of the file
			@param user the user that owns the file
			@param group the group that owns the file
			@param size the size of the file
			 @todo TODO(BIC): make this a thin non-wrapper around
		 prepareWriting(name,user,group,size,perm,atime,mtime,ctime)
		 or eliminate it.
		     		@short    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 ).
	*/
	public native 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, 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.
			@param name the name of the file
			@param user the user that owns the file
			@param group the group that owns the file
			@param size the size of the file
			@param perm permissions of the file
			@param atime time the file was last accessed
			@param mtime modification time of the file
			@param ctime creation time of the file
				@short    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 ).
	*/
	public native boolean prepareWriting(String name, String user, String group, int size, long perm, int atime, int mtime, int ctime);
	/**	
		 Write data into the current file - to be called after calling prepareWriting
		 @todo TODO(BIC) make virtual. For now virtual_hook allows reimplementing it.
		     		@short    Write data into the current file - to be called after calling prepareWriting  @todo TODO(BIC) make virtual.
	*/
	public native boolean writeData(String data, int size);
	/**	
		 Call doneWriting after writing the data.
			@param size the size of the file
				@short    Call doneWriting after writing the data.
		@see #prepareWriting
	*/
	public native boolean doneWriting(int size);
}