-
Notifications
You must be signed in to change notification settings - Fork 3
/
UFile.java
executable file
·420 lines (410 loc) · 14.6 KB
/
UFile.java
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
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
package jtux;
/**
*/
public class UFile {
/*
Not sure yet where this should be.
*/
static {
System.loadLibrary("jtux");
}
/**
Java version of C struct iovec.
<p>
<font size="-1"><b><i>Click {@link <a href="doc-files/synopses.html#struct_iovec">here</a>} for Posix/SUS C API.</i></b></font>
*/
static public class s_iovec {
public byte[] iov_base; // base address of data
public int iov_len; // size of this piece
}
/**
Java version of C struct statvfs.
<p>
<font size="-1"><b><i>Click {@link <a href="doc-files/synopses.html#struct_statvfs">here</a>} for Posix/SUS C API.</i></b></font>
*/
static public class s_statvfs {
public long f_bsize; // block size
public long f_frsize; // fundamental (fblock) size
public long f_blocks; // total number of fblocks
public long f_bfree; // number of free fblocks
public long f_bavail; // number of avail. fblocks
public long f_files; // total number of i-numbers
public long f_ffree; // number of free i-numbers
public long f_favail; // number of avail. i-numbers
public long f_fsid; // file-system ID
public long f_flag; // flags (see below)
public long f_namemax; // max length of filename
}
/**
Java version of C struct stat.
<p>
<font size="-1"><b><i>Click {@link <a href="doc-files/synopses.html#struct_stat">here</a>} for Posix/SUS C API.</i></b></font>
*/
static public class s_stat {
public int st_dev; // device ID of file system
public int st_ino; // i-number
public int st_mode; // mode (see below)
public int st_nlink; // number of hard links
public long st_uid; // user ID
public long st_gid; // group ID
public int st_rdev; // device ID (if special file)
public long st_size; // size in bytes
public long st_atime; // last access
public long st_mtime; // last data modification
public long st_ctime; // last i-node modification
public int st_blksize; // optimal I/O size
public long st_blocks; // allocated 512-byte blocks
}
/**
Java version of C struct utimbuf.
<p>
<font size="-1"><b><i>Click {@link <a href="doc-files/synopses.html#struct_utimbuf">here</a>} for Posix/SUS C API.</i></b></font>
*/
static public class s_utimbuf {
public long actime; // access time
public long modtime; // modification time
}
/**
Java version of fd_set.
*/
static public class fd_set {
static {
System.loadLibrary("jtux");
System.out.println("Loaded");
}
public byte[] set = new byte[GetSize_fd_set()];
native int GetSize_fd_set();
}
/**
Java version of C struct pollfd.
<p>
<font size="-1"><b><i>Click {@link <a href="doc-files/synopses.html#struct_pollfd">here</a>} for Posix/SUS C API.</i></b></font>
*/
static public class s_pollfd {
public int fd; // file descriptor
public short events; // input event flags
public short revents; // output event flags
}
/**
Calls access.
<p>
<font size="-1"><b><i>Click {@link <a href="doc-files/synopses.html#access">here</a>} for Posix/SUS C API.</i></b></font>
*/
public native static void access(String path, int what) throws UErrorException;
/**
Calls chmod.
<p>
<font size="-1"><b><i>Click {@link <a href="doc-files/synopses.html#chmod">here</a>} for Posix/SUS C API.</i></b></font>
*/
public native static void chmod(String path, int mode) throws UErrorException;
/**
Calls chown.
<p>
<font size="-1"><b><i>Click {@link <a href="doc-files/synopses.html#chown">here</a>} for Posix/SUS C API.</i></b></font>
*/
public native static void chown(String path, long uid, long gid) throws UErrorException;
/**
Calls close.
<p>
<font size="-1"><b><i>Click {@link <a href="doc-files/synopses.html#close">here</a>} for Posix/SUS C API.</i></b></font>
*/
public native static void close(int fd) throws UErrorException;
/**
Does the equivalent of creat, by calling open.
<p>
<font size="-1"><b><i>Click {@link <a href="doc-files/synopses.html#creat">here</a>} for Posix/SUS C API.</i></b></font>
*/
public static int creat(String path, int perms) throws UErrorException {
return open(path, UConstant.O_WRONLY | UConstant.O_CREAT | UConstant.O_TRUNC, perms);
}
/**
Calls dup.
<p>
<font size="-1"><b><i>Click {@link <a href="doc-files/synopses.html#dup">here</a>} for Posix/SUS C API.</i></b></font>
*/
public native static int dup(int fd) throws UErrorException;
/**
Calls dup2.
<p>
<font size="-1"><b><i>Click {@link <a href="doc-files/synopses.html#dup2">here</a>} for Posix/SUS C API.</i></b></font>
*/
public native static int dup2(int fd, int fd2) throws UErrorException;
/**
Calls fchmod.
<p>
<font size="-1"><b><i>Click {@link <a href="doc-files/synopses.html#fchmod">here</a>} for Posix/SUS C API.</i></b></font>
*/
public native static void fchmod(int fd, int mode) throws UErrorException;
/**
Calls fchown.
<p>
<font size="-1"><b><i>Click {@link <a href="doc-files/synopses.html#fchown">here</a>} for Posix/SUS C API.</i></b></font>
*/
public native static void fchown(int fd, long uid, long gid) throws UErrorException;
/**
Calls fcntl.
<p>
<font size="-1"><b><i>Click {@link <a href="doc-files/synopses.html#fcntl">here</a>} for Posix/SUS C API.</i></b></font>
*/
public native static int fcntl(int fd, int op, int arg) throws UErrorException;
/**
Calls FD_ZERO.
<p>
<font size="-1"><b><i>Click {@link <a href="doc-files/synopses.html#FD_ZERO">here</a>} for Posix/SUS C API.</i></b></font>
*/
public native static void FD_ZERO(fd_set set);
/**
Calls FD_SET.
<p>
<font size="-1"><b><i>Click {@link <a href="doc-files/synopses.html#FD_SET">here</a>} for Posix/SUS C API.</i></b></font>
*/
public native static void FD_SET(int fd, fd_set set);
/**
Calls FD_CLR.
<p>
<font size="-1"><b><i>Click {@link <a href="doc-files/synopses.html#FD_CLR">here</a>} for Posix/SUS C API.</i></b></font>
*/
public native static void FD_CLR(int fd, fd_set set);
/**
Calls FD_ISSET.
<p>
<font size="-1"><b><i>Click {@link <a href="doc-files/synopses.html#FD_ISSET">here</a>} for Posix/SUS C API.</i></b></font>
*/
public native static boolean FD_ISSET(int fd, fd_set set);
/**
Calls fdatasync.
<p>
<font size="-1"><b><i>Click {@link <a href="doc-files/synopses.html#fdatasync">here</a>} for Posix/SUS C API.</i></b></font>
*/
public native static void fdatasync(int fd) throws UErrorException;
/**
Calls fstat.
<p>
<font size="-1"><b><i>Click {@link <a href="doc-files/synopses.html#fstat">here</a>} for Posix/SUS C API.</i></b></font>
*/
public native static void fstat(int fd, s_stat buf) throws UErrorException;
/**
Calls fstatvfs.
<p>
<font size="-1"><b><i>Click {@link <a href="doc-files/synopses.html#fstatvfs">here</a>} for Posix/SUS C API.</i></b></font>
*/
public native static void fstatvfs(int fd, s_statvfs buf) throws UErrorException;
/**
Calls fsync.
<p>
<font size="-1"><b><i>Click {@link <a href="doc-files/synopses.html#fsync">here</a>} for Posix/SUS C API.</i></b></font>
*/
public native static void fsync(int fd) throws UErrorException;
/**
Calls ftruncate.
<p>
<font size="-1"><b><i>Click {@link <a href="doc-files/synopses.html#ftruncate">here</a>} for Posix/SUS C API.</i></b></font>
*/
public native static void ftruncate(int fd, long length) throws UErrorException;
/**
Calls lchown.
<p>
<font size="-1"><b><i>Click {@link <a href="doc-files/synopses.html#lchown">here</a>} for Posix/SUS C API.</i></b></font>
*/
public native static void lchown(String path, long uid, long gid) throws UErrorException;
/**
Calls link.
<p>
<font size="-1"><b><i>Click {@link <a href="doc-files/synopses.html#link">here</a>} for Posix/SUS C API.</i></b></font>
*/
public native static void link(String oldpath, String newpath) throws UErrorException;
/**
Calls lockf.
<p>
<font size="-1"><b><i>Click {@link <a href="doc-files/synopses.html#lockf">here</a>} for Posix/SUS C API.</i></b></font>
*/
public native static void lockf(int fd, int op, long len) throws UErrorException;
/**
Calls lseek.
<p>
<font size="-1"><b><i>Click {@link <a href="doc-files/synopses.html#lseek">here</a>} for Posix/SUS C API.</i></b></font>
*/
public native static long lseek(int fd, long pos, int whence) throws UErrorException;
/**
Calls lstat.
<p>
<font size="-1"><b><i>Click {@link <a href="doc-files/synopses.html#lstat">here</a>} for Posix/SUS C API.</i></b></font>
*/
public native static void lstat(String path, s_stat buf) throws UErrorException;
/**
Calls mkfifo.
<p>
<font size="-1"><b><i>Click {@link <a href="doc-files/synopses.html#mkfifo">here</a>} for Posix/SUS C API.</i></b></font>
*/
public native static void mkfifo(String path, int perms) throws UErrorException;
/**
Calls mknod.
<p>
<font size="-1"><b><i>Click {@link <a href="doc-files/synopses.html#mknod">here</a>} for Posix/SUS C API.</i></b></font>
*/
public native static void mknod(String path, int mode, int dev) throws UErrorException;
/**
Calls mkstemp.
<p>
<font size="-1"><b><i>Click {@link <a href="doc-files/synopses.html#mkstemp">here</a>} for Posix/SUS C API.</i></b></font>
*/
public native static int mkstemp(StringBuffer template) throws UErrorException;
/**
Calls open.
<p>
<font size="-1"><b><i>Click {@link <a href="doc-files/synopses.html#open">here</a>} for Posix/SUS C API.</i></b></font>
*/
public native static int open(String path, int flags, int perms) throws UErrorException;
/**
Calls open.
<p>
<font size="-1"><b><i>Click {@link <a href="doc-files/synopses.html#open">here</a>} for Posix/SUS C API.</i></b></font>
*/
public static int open(String path, int flags) throws UErrorException {
return open(path, flags, 0);
}
/**
Calls pipe.
<p>
<font size="-1"><b><i>Click {@link <a href="doc-files/synopses.html#pipe">here</a>} for Posix/SUS C API.</i></b></font>
*/
public native static void pipe(int[] pfd) throws UErrorException;
/**
Calls poll.
<p>
<font size="-1"><b><i>Click {@link <a href="doc-files/synopses.html#poll">here</a>} for Posix/SUS C API.</i></b></font>
*/
public native static int poll(s_pollfd[] fdinfo, int nfds, int timeout);
/**
Calls pread.
<p>
<font size="-1"><b><i>Click {@link <a href="doc-files/synopses.html#pread">here</a>} for Posix/SUS C API.</i></b></font>
*/
public native static int pread(int fd, byte[] buf, int nbytes, long offset) throws UErrorException;
/**
Calls pselect.
<p>
<font size="-1"><b><i>Click {@link <a href="doc-files/synopses.html#pselect">here</a>} for Posix/SUS C API.</i></b></font>
*/
public native static int pselect(int nfds, fd_set readset, fd_set writeset,
fd_set errorset, UProcess.s_timespec timeout, UProcess.sigset_t sigmask) throws UErrorException;
/**
Calls pwrite.
<p>
<font size="-1"><b><i>Click {@link <a href="doc-files/synopses.html#pwrite">here</a>} for Posix/SUS C API.</i></b></font>
*/
public native static int pwrite(int fd, byte[] buf, int nbytes, long position) throws UErrorException;
/**
Calls read.
<p>
<font size="-1"><b><i>Click {@link <a href="doc-files/synopses.html#read">here</a>} for Posix/SUS C API.</i></b></font>
*/
public native static int read(int fd, byte[] buf, int nbytes) throws UErrorException;
/**
Calls readlink.
<p>
<font size="-1"><b><i>Click {@link <a href="doc-files/synopses.html#readlink">here</a>} for Posix/SUS C API.</i></b></font>
*/
public native static int readlink(String path, byte[] buf, int bufsize) throws UErrorException;
/**
Calls readv.
<p>
<font size="-1"><b><i>Click {@link <a href="doc-files/synopses.html#readv">here</a>} for Posix/SUS C API.</i></b></font>
*/
public native static int readv(int fd, s_iovec[] iov, int iovcnt) throws UErrorException;
/**
Calls rename.
<p>
<font size="-1"><b><i>Click {@link <a href="doc-files/synopses.html#rename">here</a>} for Posix/SUS C API.</i></b></font>
*/
public native static void rename(String oldpath, String newpath) throws UErrorException;
/**
Calls S_ISBLK.
*/
public native static boolean S_ISBLK(int mode);
/**
Calls S_ISCHR.
*/
public native static boolean S_ISCHR(int mode);
/**
Calls S_ISDIR.
*/
public native static boolean S_ISDIR(int mode);
/**
Calls S_ISFIFO.
*/
public native static boolean S_ISFIFO(int mode);
/**
Calls S_ISLNK.
*/
public native static boolean S_ISLNK(int mode);
/**
Calls S_ISREG.
*/
public native static boolean S_ISREG(int mode);
/**
Calls S_ISSOCK.
*/
public native static boolean S_ISSOCK(int mode);
/**
Calls select.
<p>
<font size="-1"><b><i>Click {@link <a href="doc-files/synopses.html#select">here</a>} for Posix/SUS C API.</i></b></font>
*/
public native static int select(int nfds, fd_set readset, fd_set writeset,
fd_set errorset, UProcess.s_timeval timeout) throws UErrorException;
/**
Calls stat.
<p>
<font size="-1"><b><i>Click {@link <a href="doc-files/synopses.html#stat">here</a>} for Posix/SUS C API.</i></b></font>
*/
public native static void stat(String path, s_stat buf) throws UErrorException;
/**
Calls statvfs.
<p>
<font size="-1"><b><i>Click {@link <a href="doc-files/synopses.html#statvfs">here</a>} for Posix/SUS C API.</i></b></font>
*/
public native static void statvfs(String path, s_statvfs buf) throws UErrorException;
/**
Calls symlink.
<p>
<font size="-1"><b><i>Click {@link <a href="doc-files/synopses.html#symlink">here</a>} for Posix/SUS C API.</i></b></font>
*/
public native static void symlink(String oldpath, String newpath) throws UErrorException;
/**
Calls sync.
<p>
<font size="-1"><b><i>Click {@link <a href="doc-files/synopses.html#sync">here</a>} for Posix/SUS C API.</i></b></font>
*/
public native static void sync();
/**
Calls truncate.
<p>
<font size="-1"><b><i>Click {@link <a href="doc-files/synopses.html#truncate">here</a>} for Posix/SUS C API.</i></b></font>
*/
public native static void truncate(String path, long length) throws UErrorException;
/**
Calls unlink.
<p>
<font size="-1"><b><i>Click {@link <a href="doc-files/synopses.html#unlink">here</a>} for Posix/SUS C API.</i></b></font>
*/
public native static void unlink(String path) throws UErrorException;
/**
Calls utime.
<p>
<font size="-1"><b><i>Click {@link <a href="doc-files/synopses.html#utime">here</a>} for Posix/SUS C API.</i></b></font>
*/
public native static void utime(String path, s_utimbuf timbuf) throws UErrorException;
/**
Calls write.
<p>
<font size="-1"><b><i>Click {@link <a href="doc-files/synopses.html#write">here</a>} for Posix/SUS C API.</i></b></font>
*/
public native static int write(int fd, byte[] buf, int nbytes) throws UErrorException;
/**
Calls writev.
<p>
<font size="-1"><b><i>Click {@link <a href="doc-files/synopses.html#writev">here</a>} for Posix/SUS C API.</i></b></font>
*/
public native static int writev(int fd, s_iovec[] iov, int iovcnt) throws UErrorException;
}