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
|
//Auto-generated by kalyptus. DO NOT EDIT.
package org.kde.koala;
import org.kde.qt.Qt;
import org.kde.qt.QtSupport;
/**
May be removed in KDE 4.0.
Determine auto-magically the type of file,
not only by using its extension, but also by reading its contents.
Unless specified otherwise, KMimeMagic uses
$TDEDIR/share/mimelnk/magic for this purpose.
To make KMimeMagic restore the 'atime' of a file after it opened it,
add its directory in kmimemagicrc like:
[Settings]
atimeDirs=/tmp,/var/tmp,/home/dfaure/tmp
This isn't done by default because it changes the 'ctime'.
See kmimemagic.cpp for a full discussion on this issue.
The basic usage of KMimeMagic is :
<li>
Get a pointer to it, using KMimeMagic.self().
</li>
<li>
Use it for any file or buffer you want, using one of the three
<code>find...Type</code>() methods.
</li>
The result is contained in the class KMimeMagicResult.
@short
*/
public class KMimeMagic implements QtSupport {
private long _qt;
private boolean _allocatedInJavaWorld = true;
protected KMimeMagic(Class dummy){}
/**
Create a parser and initialize it with the KDE-global data:
the "magic" config file as well as the snippets from share/config/magic.
@short Create a parser and initialize it with the KDE-global data: the "magic" config file as well as the snippets from share/config/magic.
*/
public KMimeMagic() {
newKMimeMagic();
}
private native void newKMimeMagic();
/**
Create a parser and initialize it with the given config file.
@short Create a parser and initialize it with the given config file.
*/
public KMimeMagic(String configFile) {
newKMimeMagic(configFile);
}
private native void newKMimeMagic(String configFile);
/**
Merge an existing parse table with the data from the
given file.
@return <code>true</code> on success.
@short Merge an existing parse table with the data from the given file.
*/
public native boolean mergeConfig(String configFile);
/**
Merge an existing parse table with the data from the
given buffer.
@return <code>true</code> on success.
@short Merge an existing parse table with the data from the given buffer.
*/
public native boolean mergeBufConfig(String arg1);
/**
Enable/Disable follow-links.
(Default is disabled.)
@short Enable/Disable follow-links.
*/
public native void setFollowLinks(boolean _enable);
/**
Try to find a MimeType for the given file.
If no special
MimeType is found, the default MimeType is returned.
This function looks at the content of the file.
@return A pointer to the result object. Do @em not delete the
result object. After another call to KMimeMagic
the returned result object changes its value
since it is reused by KMimeMagic.
@short Try to find a MimeType for the given file.
*/
public native KMimeMagicResult findFileType(String _filename);
/**
Same functionality as above, except data is not
read from a file.
Instead a buffer can be supplied which
is examined.
@return A pointer to the result object. Do @em not delete the
result object. After another call to KMimeMagic
the returned result object changes its value
since it is reused by KMimeMagic.
@short Same functionality as above, except data is not read from a file.
*/
public native KMimeMagicResult findBufferType(byte[] p);
/**
Same functionality as findBufferType() but with
additional capability of distinguishing between
C-headers and C-Source.
For this purpose this function looks
at the extension of the filename. This means that 'filename'
can be a filename on some FTP server, too.
@return A pointer to the result object. Do @em not delete the
result object. After another call to KMimeMagic
the returned result object changes its value
since it is reused by KMimeMagic.
@short Same functionality as findBufferType() but with additional capability of distinguishing between C-headers and C-Source.
*/
public native KMimeMagicResult findBufferFileType(byte[] arg1, String filename);
/**
Returns a pointer to the unique KMimeMagic instance in this process.
@short Returns a pointer to the unique KMimeMagic instance in this process.
*/
public static native KMimeMagic self();
protected static native void initStatic();
/** 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();
}
|