KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > tomcat > jni > File


1 /*
2  * Licensed to the Apache Software Foundation (ASF) under one or more
3  * contributor license agreements. See the NOTICE file distributed with
4  * this work for additional information regarding copyright ownership.
5  * The ASF licenses this file to You under the Apache License, Version 2.0
6  * (the "License"); you may not use this file except in compliance with
7  * the License. You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */

17
18 package org.apache.tomcat.jni;
19 /* Import needed classes */
20 import java.nio.ByteBuffer JavaDoc;
21 /** File
22  *
23  * @author Mladen Turk
24  * @version $Revision: 467222 $, $Date: 2006-10-24 05:17:11 +0200 (mar., 24 oct. 2006) $
25  */

26
27 public class File {
28
29     /** Open the file for reading */
30     public static final int APR_FOPEN_READ = 0x00001;
31     /** Open the file for writing */
32     public static final int APR_FOPEN_WRITE = 0x00002;
33     /** Create the file if not there */
34     public static final int APR_FOPEN_CREATE = 0x00004;
35     /** Append to the end of the file */
36     public static final int APR_FOPEN_APPEND = 0x00008;
37     /** Open the file and truncate to 0 length */
38     public static final int APR_FOPEN_TRUNCATE = 0x00010;
39     /** Open the file in binary mode */
40     public static final int APR_FOPEN_BINARY = 0x00020;
41     /** Open should fail if APR_CREATE and file exists. */
42     public static final int APR_FOPEN_EXCL = 0x00040;
43     /** Open the file for buffered I/O */
44     public static final int APR_FOPEN_BUFFERED = 0x00080;
45     /** Delete the file after close */
46     public static final int APR_FOPEN_DELONCLOSE = 0x00100;
47     /** Platform dependent tag to open the file for
48      * use across multiple threads
49      */

50     public static final int APR_FOPEN_XTHREAD = 0x00200;
51     /** Platform dependent support for higher level locked read/write
52      * access to support writes across process/machines
53      */

54     public static final int APR_FOPEN_SHARELOCK = 0x00400;
55     /** Do not register a cleanup when the file is opened */
56     public static final int APR_FOPEN_NOCLEANUP = 0x00800;
57     /** Advisory flag that this file should support
58      * apr_socket_sendfile operation
59      */

60     public static final int APR_FOPEN_SENDFILE_ENABLED = 0x01000;
61     /** Platform dependent flag to enable large file support;
62      * <br /><b>Warning :</b> The APR_LARGEFILE flag only has effect on some platforms
63      * where sizeof(apr_off_t) == 4. Where implemented, it allows opening
64      * and writing to a file which exceeds the size which can be
65      * represented by apr_off_t (2 gigabytes). When a file's size does
66      * exceed 2Gb, apr_file_info_get() will fail with an error on the
67      * descriptor, likewise apr_stat()/apr_lstat() will fail on the
68      * filename. apr_dir_read() will fail with APR_INCOMPLETE on a
69      * directory entry for a large file depending on the particular
70      * APR_FINFO_* flags. Generally, it is not recommended to use this
71      * flag.
72      */

73     public static final int APR_FOPEN_LARGEFILE = 0x04000;
74
75     /** Set the file position */
76     public static final int APR_SET = 0;
77     /** Current */
78     public static final int APR_CUR = 1;
79     /** Go to end of file */
80     public static final int APR_END = 2;
81
82     /* flags for apr_file_attrs_set */
83
84     /** File is read-only */
85     public static final int APR_FILE_ATTR_READONLY = 0x01;
86     /** File is executable */
87     public static final int APR_FILE_ATTR_EXECUTABLE = 0x02;
88     /** File is hidden */
89     public static final int APR_FILE_ATTR_HIDDEN = 0x04;
90
91
92     /* File lock types/flags */
93
94     /** Shared lock. More than one process or thread can hold a shared lock
95      * at any given time. Essentially, this is a "read lock", preventing
96      * writers from establishing an exclusive lock.
97      */

98     public static final int APR_FLOCK_SHARED = 1;
99
100     /** Exclusive lock. Only one process may hold an exclusive lock at any
101      * given time. This is analogous to a "write lock".
102      */

103     public static final int APR_FLOCK_EXCLUSIVE = 2;
104     /** mask to extract lock type */
105     public static final int APR_FLOCK_TYPEMASK = 0x000F;
106     /** do not block while acquiring the file lock */
107     public static final int APR_FLOCK_NONBLOCK = 0x0010;
108
109     /* apr_filetype_e values for the filetype member of the
110      * apr_file_info_t structure
111      * <br /><b>Warning :</b>: Not all of the filetypes below can be determined.
112      * For example, a given platform might not correctly report
113      * a socket descriptor as APR_SOCK if that type isn't
114      * well-identified on that platform. In such cases where
115      * a filetype exists but cannot be described by the recognized
116      * flags below, the filetype will be APR_UNKFILE. If the
117      * filetype member is not determined, the type will be APR_NOFILE.
118      */

119
120     /** no file type determined */
121     public static final int APR_NOFILE = 0;
122     /** a regular file */
123     public static final int APR_REG = 1;
124     /** a directory */
125     public static final int APR_DIR = 2;
126     /** a character device */
127     public static final int APR_CHR = 3;
128     /** a block device */
129     public static final int APR_BLK = 4;
130     /** a FIFO / pipe */
131     public static final int APR_PIPE = 5;
132     /** a symbolic link */
133     public static final int APR_LNK = 6;
134     /** a [unix domain] socket */
135     public static final int APR_SOCK = 7;
136     /** a file of some other unknown type */
137     public static final int APR_UNKFILE = 127;
138
139
140     /*
141      * apr_file_permissions File Permissions flags
142      */

143
144     public static final int APR_FPROT_USETID = 0x8000; /** Set user id */
145     public static final int APR_FPROT_UREAD = 0x0400; /** Read by user */
146     public static final int APR_FPROT_UWRITE = 0x0200; /** Write by user */
147     public static final int APR_FPROT_UEXECUTE = 0x0100; /** Execute by user */
148
149     public static final int APR_FPROT_GSETID = 0x4000; /** Set group id */
150     public static final int APR_FPROT_GREAD = 0x0040; /** Read by group */
151     public static final int APR_FPROT_GWRITE = 0x0020; /** Write by group */
152     public static final int APR_FPROT_GEXECUTE = 0x0010; /** Execute by group */
153
154     public static final int APR_FPROT_WSTICKY = 0x2000; /** Sticky bit */
155     public static final int APR_FPROT_WREAD = 0x0004; /** Read by others */
156     public static final int APR_FPROT_WWRITE = 0x0002; /** Write by others */
157     public static final int APR_FPROT_WEXECUTE = 0x0001; /** Execute by others */
158     public static final int APR_FPROT_OS_DEFAULT = 0x0FFF; /** use OS's default permissions */
159
160
161     public static final int APR_FINFO_LINK = 0x00000001; /** Stat the link not the file itself if it is a link */
162     public static final int APR_FINFO_MTIME = 0x00000010; /** Modification Time */
163     public static final int APR_FINFO_CTIME = 0x00000020; /** Creation or inode-changed time */
164     public static final int APR_FINFO_ATIME = 0x00000040; /** Access Time */
165     public static final int APR_FINFO_SIZE = 0x00000100; /** Size of the file */
166     public static final int APR_FINFO_CSIZE = 0x00000200; /** Storage size consumed by the file */
167     public static final int APR_FINFO_DEV = 0x00001000; /** Device */
168     public static final int APR_FINFO_INODE = 0x00002000; /** Inode */
169     public static final int APR_FINFO_NLINK = 0x00004000; /** Number of links */
170     public static final int APR_FINFO_TYPE = 0x00008000; /** Type */
171     public static final int APR_FINFO_USER = 0x00010000; /** User */
172     public static final int APR_FINFO_GROUP = 0x00020000; /** Group */
173     public static final int APR_FINFO_UPROT = 0x00100000; /** User protection bits */
174     public static final int APR_FINFO_GPROT = 0x00200000; /** Group protection bits */
175     public static final int APR_FINFO_WPROT = 0x00400000; /** World protection bits */
176     public static final int APR_FINFO_ICASE = 0x01000000; /** if dev is case insensitive */
177     public static final int APR_FINFO_NAME = 0x02000000; /** ->name in proper case */
178
179     public static final int APR_FINFO_MIN = 0x00008170; /** type, mtime, ctime, atime, size */
180     public static final int APR_FINFO_IDENT = 0x00003000; /** dev and inode */
181     public static final int APR_FINFO_OWNER = 0x00030000; /** user and group */
182     public static final int APR_FINFO_PROT = 0x00700000; /** all protections */
183     public static final int APR_FINFO_NORM = 0x0073b170; /** an atomic unix apr_stat() */
184     public static final int APR_FINFO_DIRENT = 0x02000000; /** an atomic unix apr_dir_read() */
185
186
187
188     /**
189      * Open the specified file.
190      * @param fname The full path to the file (using / on all systems)
191      * @param flag Or'ed value of:
192      * <PRE>
193      * APR_FOPEN_READ open for reading
194      * APR_FOPEN_WRITE open for writing
195      * APR_FOPEN_CREATE create the file if not there
196      * APR_FOPEN_APPEND file ptr is set to end prior to all writes
197      * APR_FOPEN_TRUNCATE set length to zero if file exists
198      * APR_FOPEN_BINARY not a text file (This flag is ignored on
199      * UNIX because it has no meaning)
200      * APR_FOPEN_BUFFERED buffer the data. Default is non-buffered
201      * APR_FOPEN_EXCL return error if APR_CREATE and file exists
202      * APR_FOPEN_DELONCLOSE delete the file after closing.
203      * APR_FOPEN_XTHREAD Platform dependent tag to open the file
204      * for use across multiple threads
205      * APR_FOPEN_SHARELOCK Platform dependent support for higher
206      * level locked read/write access to support
207      * writes across process/machines
208      * APR_FOPEN_NOCLEANUP Do not register a cleanup with the pool
209      * passed in on the <EM>pool</EM> argument (see below).
210      * The apr_os_file_t handle in apr_file_t will not
211      * be closed when the pool is destroyed.
212      * APR_FOPEN_SENDFILE_ENABLED Open with appropriate platform semantics
213      * for sendfile operations. Advisory only,
214      * apr_socket_sendfile does not check this flag.
215      * </PRE>
216      * @param perm Access permissions for file.
217      * @param pool The pool to use.
218      * If perm is APR_OS_DEFAULT and the file is being created,
219      * appropriate default permissions will be used.
220      * @return The opened file descriptor.
221      */

222     public static native long open(String JavaDoc fname, int flag, int perm, long pool)
223         throws Error JavaDoc;
224
225     /**
226      * Close the specified file.
227      * @param file The file descriptor to close.
228      */

229     public static native int close(long file);
230
231     /**
232      * Flush the file's buffer.
233      * @param thefile The file descriptor to flush
234      */

235     public static native int flush(long thefile);
236
237     /**
238      * Open a temporary file
239      * @param templ The template to use when creating a temp file.
240      * @param flags The flags to open the file with. If this is zero,
241      * the file is opened with
242      * APR_CREATE | APR_READ | APR_WRITE | APR_EXCL | APR_DELONCLOSE
243      * @param pool The pool to allocate the file out of.
244      * @return The apr file to use as a temporary file.
245      *
246      * This function generates a unique temporary file name from template.
247      * The last six characters of template must be XXXXXX and these are replaced
248      * with a string that makes the filename unique. Since it will be modified,
249      * template must not be a string constant, but should be declared as a character
250      * array.
251      *
252      */

253     public static native long mktemp(String JavaDoc templ, int flags, long pool)
254         throws Error JavaDoc;
255
256     /**
257      * Delete the specified file.
258      * @param path The full path to the file (using / on all systems)
259      * @param pool The pool to use.
260      * If the file is open, it won't be removed until all
261      * instances are closed.
262      */

263     public static native int remove(String JavaDoc path, long pool);
264
265     /**
266      * Rename the specified file.
267      * <br /><b>Warning :</b> If a file exists at the new location, then it will be
268      * overwritten. Moving files or directories across devices may not be
269      * possible.
270      * @param fromPath The full path to the original file (using / on all systems)
271      * @param toPath The full path to the new file (using / on all systems)
272      * @param pool The pool to use.
273      */

274     public static native int rename(String JavaDoc fromPath, String JavaDoc toPath, long pool);
275
276     /**
277      * Copy the specified file to another file.
278      * The new file does not need to exist, it will be created if required.
279      * <br /><b>Warning :</b> If the new file already exists, its contents will be overwritten.
280      * @param fromPath The full path to the original file (using / on all systems)
281      * @param toPath The full path to the new file (using / on all systems)
282      * @param perms Access permissions for the new file if it is created.
283      * In place of the usual or'd combination of file permissions, the
284      * value APR_FILE_SOURCE_PERMS may be given, in which case the source
285      * file's permissions are copied.
286      * @param pool The pool to use.
287      */

288     public static native int copy(String JavaDoc fromPath, String JavaDoc toPath, int perms, long pool);
289
290     /**
291      * Append the specified file to another file.
292      * The new file does not need to exist, it will be created if required.
293      * @param fromPath The full path to the source file (use / on all systems)
294      * @param toPath The full path to the destination file (use / on all systems)
295      * @param perms Access permissions for the destination file if it is created.
296      * In place of the usual or'd combination of file permissions, the
297      * value APR_FILE_SOURCE_PERMS may be given, in which case the source
298      * file's permissions are copied.
299      * @param pool The pool to use.
300      */

301     public static native int append(String JavaDoc fromPath, String JavaDoc toPath, int perms, long pool);
302
303     /**
304      * Write the string into the specified file.
305      * @param str The string to write. Must be NUL terminated!
306      * @param thefile The file descriptor to write to
307      */

308     public static native int puts(byte [] str, long thefile);
309
310     /**
311      * Move the read/write file offset to a specified byte within a file.
312      * @param thefile The file descriptor
313      * @param where How to move the pointer, one of:
314      * <PRE>
315      * APR_SET -- set the offset to offset
316      * APR_CUR -- add the offset to the current position
317      * APR_END -- add the offset to the current file size
318      * </PRE>
319      * @param offset The offset to move the pointer to.
320      * @return Offset the pointer was actually moved to.
321      */

322     public static native long seek(long thefile, int where, long offset)
323         throws Error JavaDoc;
324
325     /**
326      * Write a character into the specified file.
327      * @param ch The character to write.
328      * @param thefile The file descriptor to write to
329      */

330     public static native int putc(byte ch, long thefile);
331
332     /**
333      * Put a character back onto a specified stream.
334      * @param ch The character to write.
335      * @param thefile The file descriptor to write to
336      */

337     public static native int ungetc(byte ch, long thefile);
338
339     /**
340      * Write data to the specified file.
341      *
342      * Write will write up to the specified number of
343      * bytes, but never more. If the OS cannot write that many bytes, it
344      * will write as many as it can. The third argument is modified to
345      * reflect the * number of bytes written.
346      *
347      * It is possible for both bytes to be written and an error to
348      * be returned. APR_EINTR is never returned.
349      * @param thefile The file descriptor to write to.
350      * @param buf The buffer which contains the data.
351      * @param offset Start offset in buf
352      * @param nbytes The number of bytes to write; (-1) for full array.
353      * @return The number of bytes written.
354      */

355     public static native int write(long thefile, byte[] buf, int offset, int nbytes);
356
357     /**
358      * Write data to the specified file.
359      *
360      * Write will write up to the specified number of
361      * bytes, but never more. If the OS cannot write that many bytes, it
362      * will write as many as it can. The third argument is modified to
363      * reflect the * number of bytes written.
364      *
365      * It is possible for both bytes to be written and an error to
366      * be returned. APR_EINTR is never returned.
367      * @param thefile The file descriptor to write to.
368      * @param buf The direct Byte buffer which contains the data.
369      * @param offset Start offset in buf
370      * @param nbytes The number of bytes to write
371      * @return The number of bytes written.
372      */

373     public static native int writeb(long thefile, ByteBuffer JavaDoc buf, int offset, int nbytes);
374
375     /**
376      * Write data to the specified file, ensuring that all of the data is
377      * written before returning.
378      *
379      * Write will write up to the specified number of
380      * bytes, but never more. If the OS cannot write that many bytes, the
381      * process/thread will block until they can be written. Exceptional
382      * error such as "out of space" or "pipe closed" will terminate with
383      * an error.
384      *
385      * It is possible for both bytes to be written and an error to
386      * be returned. And if *bytes_written is less than nbytes, an
387      * accompanying error is _always_ returned.
388      *
389      * APR_EINTR is never returned.
390      * @param thefile The file descriptor to write to.
391      * @param buf The buffer which contains the data.
392      * @param offset Start offset in buf
393      * @param nbytes The number of bytes to write; (-1) for full array.
394      * @return The number of bytes written.
395      */

396     public static native int writeFull(long thefile, byte[] buf, int offset, int nbytes);
397
398     /**
399      * Write data to the specified file, ensuring that all of the data is
400      * written before returning.
401      *
402      * Write will write up to the specified number of
403      * bytes, but never more. If the OS cannot write that many bytes, the
404      * process/thread will block until they can be written. Exceptional
405      * error such as "out of space" or "pipe closed" will terminate with
406      * an error.
407      *
408      * It is possible for both bytes to be written and an error to
409      * be returned. And if *bytes_written is less than nbytes, an
410      * accompanying error is _always_ returned.
411      *
412      * APR_EINTR is never returned.
413      * @param thefile The file descriptor to write to.
414      * @param buf The direct ByteBuffer which contains the data.
415      * @param offset Start offset in buf
416      * @param nbytes The number of bytes to write.
417      * @return The number of bytes written.
418      */

419     public static native int writeFullb(long thefile, ByteBuffer JavaDoc buf, int offset, int nbytes);
420
421     /**
422      * Write data from aray of byte arrays to the specified file.
423      *
424      * It is possible for both bytes to be written and an error to
425      * be returned. APR_EINTR is never returned.
426      *
427      * apr_file_writev is available even if the underlying
428      * operating system doesn't provide writev().
429      * @param thefile The file descriptor to write to.
430      * @param vec The array from which to get the data to write to the file.
431      * @return The number of bytes written.
432      */

433     public static native int writev(long thefile, byte[][] vec);
434
435     /**
436      * Write data from aray of byte arrays to the specified file,
437      * ensuring that all of the data is written before returning.
438      *
439      * writevFull is available even if the underlying
440      * operating system doesn't provide writev().
441      * @param thefile The file descriptor to write to.
442      * @param vec The array from which to get the data to write to the file.
443      * @return The number of bytes written.
444      */

445     public static native int writevFull(long thefile, byte[][] vec);
446
447     /**
448      * Read data from the specified file.
449      *
450      * apr_file_read will read up to the specified number of
451      * bytes, but never more. If there isn't enough data to fill that
452      * number of bytes, all of the available data is read. The third
453      * argument is modified to reflect the number of bytes read. If a
454      * char was put back into the stream via ungetc, it will be the first
455      * character returned.
456      *
457      * It is not possible for both bytes to be read and an APR_EOF
458      * or other error to be returned. APR_EINTR is never returned.
459      * @param thefile The file descriptor to read from.
460      * @param buf The buffer to store the data to.
461      * @param offset Start offset in buf
462      * @param nbytes The number of bytes to read (-1) for full array.
463      * @return the number of bytes read.
464      */

465     public static native int read(long thefile, byte[] buf, int offset, int nbytes);
466
467     /**
468      * Read data from the specified file.
469      *
470      * apr_file_read will read up to the specified number of
471      * bytes, but never more. If there isn't enough data to fill that
472      * number of bytes, all of the available data is read. The third
473      * argument is modified to reflect the number of bytes read. If a
474      * char was put back into the stream via ungetc, it will be the first
475      * character returned.
476      *
477      * It is not possible for both bytes to be read and an APR_EOF
478      * or other error to be returned. APR_EINTR is never returned.
479      * @param thefile The file descriptor to read from.
480      * @param buf The direct Byte buffer to store the data to.
481      * @param offset Start offset in buf
482      * @param nbytes The number of bytes to read.
483      * @return the number of bytes read.
484      */

485     public static native int readb(long thefile, ByteBuffer JavaDoc buf, int offset, int nbytes);
486
487     /**
488      * Read data from the specified file, ensuring that the buffer is filled
489      * before returning.
490      *
491      * Read will read up to the specified number of
492      * bytes, but never more. If there isn't enough data to fill that
493      * number of bytes, then the process/thread will block until it is
494      * available or EOF is reached. If a char was put back into the
495      * stream via ungetc, it will be the first character returned.
496      *
497      * It is possible for both bytes to be read and an error to be
498      * returned. And if *bytes_read is less than nbytes, an accompanying
499      * error is _always_ returned.
500      *
501      * APR_EINTR is never returned.
502      * @param thefile The file descriptor to read from.
503      * @param buf The buffer to store the data to.
504      * @param offset Start offset in buf
505      * @param nbytes The number of bytes to read (-1) for full array.
506      * @return the number of bytes read.
507      */

508     public static native int readFull(long thefile, byte[] buf, int offset, int nbytes);
509
510     /**
511      * Read data from the specified file, ensuring that the buffer is filled
512      * before returning.
513      *
514      * Read will read up to the specified number of
515      * bytes, but never more. If there isn't enough data to fill that
516      * number of bytes, then the process/thread will block until it is
517      * available or EOF is reached. If a char was put back into the
518      * stream via ungetc, it will be the first character returned.
519      *
520      * It is possible for both bytes to be read and an error to be
521      * returned. And if *bytes_read is less than nbytes, an accompanying
522      * error is _always_ returned.
523      *
524      * APR_EINTR is never returned.
525      * @param thefile The file descriptor to read from.
526      * @param buf The direct ByteBuffer to store the data to.
527      * @param offset Start offset in buf
528      * @param nbytes The number of bytes to read.
529      * @return the number of bytes read.
530      */

531     public static native int readFullb(long thefile, ByteBuffer JavaDoc buf, int offset, int nbytes);
532
533     /**
534      * Read a string from the specified file.
535      * The buffer will be NUL-terminated if any characters are stored.
536      * @param buf The buffer to store the string in.
537      * @param offset Start offset in buf
538      * @param thefile The file descriptor to read from
539      */

540     public static native int gets(byte[] buf, int offset, long thefile);
541
542
543     /**
544      * Read a character from the specified file.
545      * @param thefile The file descriptor to read from
546      * @return The readed character
547      */

548     public static native int getc(long thefile)
549         throws Error JavaDoc;
550
551     /**
552      * Are we at the end of the file
553      * @param fptr The apr file we are testing.
554      * @return Returns APR_EOF if we are at the end of file, APR_SUCCESS otherwise.
555      */

556     public static native int eof(long fptr);
557
558     /**
559      * return the file name of the current file.
560      * @param thefile The currently open file.
561      */

562     public static native String JavaDoc nameGet(long thefile);
563
564     /**
565      * Set the specified file's permission bits.
566      * <br /><b>Warning :</b> Some platforms may not be able to apply all of the
567      * available permission bits; APR_INCOMPLETE will be returned if some
568      * permissions are specified which could not be set.
569      * <br /><b>Warning :</b> Platforms which do not implement this feature will return
570      * APR_ENOTIMPL.
571      * @param fname The file (name) to apply the permissions to.
572      * @param perms The permission bits to apply to the file.
573      *
574      */

575     public static native int permsSet(String JavaDoc fname, int perms);
576
577     /**
578      * Set attributes of the specified file.
579      * This function should be used in preference to explict manipulation
580      * of the file permissions, because the operations to provide these
581      * attributes are platform specific and may involve more than simply
582      * setting permission bits.
583      * <br /><b>Warning :</b> Platforms which do not implement this feature will return
584      * APR_ENOTIMPL.
585      * @param fname The full path to the file (using / on all systems)
586      * @param attributes Or'd combination of
587      * <PRE>
588      * APR_FILE_ATTR_READONLY - make the file readonly
589      * APR_FILE_ATTR_EXECUTABLE - make the file executable
590      * APR_FILE_ATTR_HIDDEN - make the file hidden
591      * </PRE>
592      * @param mask Mask of valid bits in attributes.
593      * @param pool the pool to use.
594      */

595     public static native int attrsSet(String JavaDoc fname, int attributes, int mask, long pool);
596
597     /**
598      * Set the mtime of the specified file.
599      * <br /><b>Warning :</b> Platforms which do not implement this feature will return
600      * APR_ENOTIMPL.
601      * @param fname The full path to the file (using / on all systems)
602      * @param mtime The mtime to apply to the file in microseconds
603      * @param pool The pool to use.
604      */

605     public static native int mtimeSet(String JavaDoc fname, long mtime, long pool);
606
607     /**
608      * Establish a lock on the specified, open file. The lock may be advisory
609      * or mandatory, at the discretion of the platform. The lock applies to
610      * the file as a whole, rather than a specific range. Locks are established
611      * on a per-thread/process basis; a second lock by the same thread will not
612      * block.
613      * @param thefile The file to lock.
614      * @param type The type of lock to establish on the file.
615      */

616     public static native int lock(long thefile, int type);
617
618     /**
619      * Remove any outstanding locks on the file.
620      * @param thefile The file to unlock.
621      */

622     public static native int unlock(long thefile);
623
624     /**
625      * Retrieve the flags that were passed into apr_file_open()
626      * when the file was opened.
627      * @param file The file to retrive flags.
628      * @return the flags
629      */

630     public static native int flagsGet(long file);
631
632     /**
633      * Truncate the file's length to the specified offset
634      * @param fp The file to truncate
635      * @param offset The offset to truncate to.
636      */

637     public static native int trunc(long fp, long offset);
638
639     /**
640      * Create an anonymous pipe.
641      * @param io io[0] The file descriptors to use as input to the pipe.
642      * io[1] The file descriptor to use as output from the pipe.
643      * @param pool The pool to operate on.
644      */

645     public static native int pipeCreate(long [] io, long pool);
646
647     /**
648      * Get the timeout value for a pipe or manipulate the blocking state.
649      * @param thepipe The pipe we are getting a timeout for.
650      * @return The current timeout value in microseconds.
651      */

652     public static native long pipeTimeoutGet(long thepipe)
653         throws Error JavaDoc;
654
655     /**
656      * Set the timeout value for a pipe or manipulate the blocking state.
657      * @param thepipe The pipe we are setting a timeout on.
658      * @param timeout The timeout value in microseconds. Values < 0 mean wait
659      * forever, 0 means do not wait at all.
660      */

661     public static native int pipeTimeoutSet(long thepipe, long timeout);
662
663     /**
664      * Duplicate the specified file descriptor.
665      * @param newFile The file to duplicate.
666      * newFile must point to a valid apr_file_t, or point to NULL.
667      * @param oldFile The file to duplicate.
668      * @param pool The pool to use for the new file.
669      * @return Duplicated file structure.
670      */

671     public static native long dup(long newFile, long oldFile, long pool)
672         throws Error JavaDoc;
673
674     /**
675      * Duplicate the specified file descriptor and close the original.
676      * @param newFile The old file that is to be closed and reused.
677      * newFile MUST point at a valid apr_file_t. It cannot be NULL.
678      * @param oldFile The file to duplicate.
679      * @param pool The pool to use for the new file.
680      * @return Status code.
681      */

682     public static native int dup2(long newFile, long oldFile, long pool);
683
684     /**
685      * Get the specified file's stats. The file is specified by filename,
686      * instead of using a pre-opened file.
687      * @param finfo Where to store the information about the file, which is
688      * never touched if the call fails.
689      * @param fname The name of the file to stat.
690      * @param wanted The desired apr_finfo_t fields, as a bit flag of APR_FINFO_ values
691      * @param pool the pool to use to allocate the new file.
692      */

693     public static native int stat(FileInfo finfo, String JavaDoc fname, int wanted, long pool);
694
695     /**
696      * Get the specified file's stats.
697      * @param finfo Where to store the information about the file.
698      * @param wanted The desired apr_finfo_t fields, as a bit flag of APR_FINFO_ values
699      * @param thefile The file to get information about.
700      */

701     public static native int infoGet(FileInfo finfo, int wanted, long thefile);
702
703 }
704
Popular Tags