Source Code Cross Referenced for File.java in  » Sevlet-Container » apache-tomcat-6.0.14 » org » apache » tomcat » jni » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Sevlet Container » apache tomcat 6.0.14 » org.apache.tomcat.jni 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         *  Licensed to the Apache Software Foundation (ASF) under one or more
003:         *  contributor license agreements.  See the NOTICE file distributed with
004:         *  this work for additional information regarding copyright ownership.
005:         *  The ASF licenses this file to You under the Apache License, Version 2.0
006:         *  (the "License"); you may not use this file except in compliance with
007:         *  the License.  You may obtain a copy of the License at
008:         *
009:         *      http://www.apache.org/licenses/LICENSE-2.0
010:         *
011:         *  Unless required by applicable law or agreed to in writing, software
012:         *  distributed under the License is distributed on an "AS IS" BASIS,
013:         *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014:         *  See the License for the specific language governing permissions and
015:         *  limitations under the License.
016:         */
017:
018:        package org.apache.tomcat.jni;
019:
020:        /* Import needed classes */
021:        import java.nio.ByteBuffer;
022:
023:        /** File
024:         *
025:         * @author Mladen Turk
026:         * @version $Revision: 467222 $, $Date: 2006-10-24 05:17:11 +0200 (mar., 24 oct. 2006) $
027:         */
028:
029:        public class File {
030:
031:            /** Open the file for reading */
032:            public static final int APR_FOPEN_READ = 0x00001;
033:            /** Open the file for writing */
034:            public static final int APR_FOPEN_WRITE = 0x00002;
035:            /** Create the file if not there */
036:            public static final int APR_FOPEN_CREATE = 0x00004;
037:            /** Append to the end of the file */
038:            public static final int APR_FOPEN_APPEND = 0x00008;
039:            /** Open the file and truncate to 0 length */
040:            public static final int APR_FOPEN_TRUNCATE = 0x00010;
041:            /** Open the file in binary mode */
042:            public static final int APR_FOPEN_BINARY = 0x00020;
043:            /** Open should fail if APR_CREATE and file exists. */
044:            public static final int APR_FOPEN_EXCL = 0x00040;
045:            /** Open the file for buffered I/O */
046:            public static final int APR_FOPEN_BUFFERED = 0x00080;
047:            /** Delete the file after close */
048:            public static final int APR_FOPEN_DELONCLOSE = 0x00100;
049:            /** Platform dependent tag to open the file for
050:             * use across multiple threads
051:             */
052:            public static final int APR_FOPEN_XTHREAD = 0x00200;
053:            /** Platform dependent support for higher level locked read/write
054:             * access to support writes across process/machines
055:             */
056:            public static final int APR_FOPEN_SHARELOCK = 0x00400;
057:            /** Do not register a cleanup when the file is opened */
058:            public static final int APR_FOPEN_NOCLEANUP = 0x00800;
059:            /** Advisory flag that this file should support
060:             * apr_socket_sendfile operation
061:             */
062:            public static final int APR_FOPEN_SENDFILE_ENABLED = 0x01000;
063:            /** Platform dependent flag to enable large file support;
064:             * <br /><b>Warning :</b> The APR_LARGEFILE flag only has effect on some platforms
065:             * where sizeof(apr_off_t) == 4.  Where implemented, it allows opening
066:             * and writing to a file which exceeds the size which can be
067:             * represented by apr_off_t (2 gigabytes).  When a file's size does
068:             * exceed 2Gb, apr_file_info_get() will fail with an error on the
069:             * descriptor, likewise apr_stat()/apr_lstat() will fail on the
070:             * filename.  apr_dir_read() will fail with APR_INCOMPLETE on a
071:             * directory entry for a large file depending on the particular
072:             * APR_FINFO_* flags.  Generally, it is not recommended to use this
073:             * flag.
074:             */
075:            public static final int APR_FOPEN_LARGEFILE = 0x04000;
076:
077:            /** Set the file position */
078:            public static final int APR_SET = 0;
079:            /** Current */
080:            public static final int APR_CUR = 1;
081:            /** Go to end of file */
082:            public static final int APR_END = 2;
083:
084:            /* flags for apr_file_attrs_set */
085:
086:            /** File is read-only */
087:            public static final int APR_FILE_ATTR_READONLY = 0x01;
088:            /** File is executable */
089:            public static final int APR_FILE_ATTR_EXECUTABLE = 0x02;
090:            /** File is hidden */
091:            public static final int APR_FILE_ATTR_HIDDEN = 0x04;
092:
093:            /* File lock types/flags */
094:
095:            /** Shared lock. More than one process or thread can hold a shared lock
096:             * at any given time. Essentially, this is a "read lock", preventing
097:             * writers from establishing an exclusive lock.
098:             */
099:            public static final int APR_FLOCK_SHARED = 1;
100:
101:            /** Exclusive lock. Only one process may hold an exclusive lock at any
102:             * given time. This is analogous to a "write lock".
103:             */
104:            public static final int APR_FLOCK_EXCLUSIVE = 2;
105:            /** mask to extract lock type */
106:            public static final int APR_FLOCK_TYPEMASK = 0x000F;
107:            /** do not block while acquiring the file lock */
108:            public static final int APR_FLOCK_NONBLOCK = 0x0010;
109:
110:            /* apr_filetype_e values for the filetype member of the
111:             * apr_file_info_t structure
112:             * <br /><b>Warning :</b>: Not all of the filetypes below can be determined.
113:             * For example, a given platform might not correctly report
114:             * a socket descriptor as APR_SOCK if that type isn't
115:             * well-identified on that platform.  In such cases where
116:             * a filetype exists but cannot be described by the recognized
117:             * flags below, the filetype will be APR_UNKFILE.  If the
118:             * filetype member is not determined, the type will be APR_NOFILE.
119:             */
120:
121:            /** no file type determined */
122:            public static final int APR_NOFILE = 0;
123:            /** a regular file */
124:            public static final int APR_REG = 1;
125:            /** a directory */
126:            public static final int APR_DIR = 2;
127:            /** a character device */
128:            public static final int APR_CHR = 3;
129:            /** a block device */
130:            public static final int APR_BLK = 4;
131:            /** a FIFO / pipe */
132:            public static final int APR_PIPE = 5;
133:            /** a symbolic link */
134:            public static final int APR_LNK = 6;
135:            /** a [unix domain] socket */
136:            public static final int APR_SOCK = 7;
137:            /** a file of some other unknown type */
138:            public static final int APR_UNKFILE = 127;
139:
140:            /*
141:             * apr_file_permissions File Permissions flags
142:             */
143:
144:            public static final int APR_FPROT_USETID = 0x8000;
145:            /** Set user id */
146:            public static final int APR_FPROT_UREAD = 0x0400;
147:            /** Read by user */
148:            public static final int APR_FPROT_UWRITE = 0x0200;
149:            /** Write by user */
150:            public static final int APR_FPROT_UEXECUTE = 0x0100;
151:            /** Execute by user */
152:
153:            public static final int APR_FPROT_GSETID = 0x4000;
154:            /** Set group id */
155:            public static final int APR_FPROT_GREAD = 0x0040;
156:            /** Read by group */
157:            public static final int APR_FPROT_GWRITE = 0x0020;
158:            /** Write by group */
159:            public static final int APR_FPROT_GEXECUTE = 0x0010;
160:            /** Execute by group */
161:
162:            public static final int APR_FPROT_WSTICKY = 0x2000;
163:            /** Sticky bit */
164:            public static final int APR_FPROT_WREAD = 0x0004;
165:            /** Read by others */
166:            public static final int APR_FPROT_WWRITE = 0x0002;
167:            /** Write by others */
168:            public static final int APR_FPROT_WEXECUTE = 0x0001;
169:            /** Execute by others */
170:            public static final int APR_FPROT_OS_DEFAULT = 0x0FFF;
171:            /** use OS's default permissions */
172:
173:            public static final int APR_FINFO_LINK = 0x00000001;
174:            /** Stat the link not the file itself if it is a link */
175:            public static final int APR_FINFO_MTIME = 0x00000010;
176:            /** Modification Time */
177:            public static final int APR_FINFO_CTIME = 0x00000020;
178:            /** Creation or inode-changed time */
179:            public static final int APR_FINFO_ATIME = 0x00000040;
180:            /** Access Time */
181:            public static final int APR_FINFO_SIZE = 0x00000100;
182:            /** Size of the file */
183:            public static final int APR_FINFO_CSIZE = 0x00000200;
184:            /** Storage size consumed by the file */
185:            public static final int APR_FINFO_DEV = 0x00001000;
186:            /** Device */
187:            public static final int APR_FINFO_INODE = 0x00002000;
188:            /** Inode */
189:            public static final int APR_FINFO_NLINK = 0x00004000;
190:            /** Number of links */
191:            public static final int APR_FINFO_TYPE = 0x00008000;
192:            /** Type */
193:            public static final int APR_FINFO_USER = 0x00010000;
194:            /** User */
195:            public static final int APR_FINFO_GROUP = 0x00020000;
196:            /** Group */
197:            public static final int APR_FINFO_UPROT = 0x00100000;
198:            /** User protection bits */
199:            public static final int APR_FINFO_GPROT = 0x00200000;
200:            /** Group protection bits */
201:            public static final int APR_FINFO_WPROT = 0x00400000;
202:            /** World protection bits */
203:            public static final int APR_FINFO_ICASE = 0x01000000;
204:            /** if dev is case insensitive */
205:            public static final int APR_FINFO_NAME = 0x02000000;
206:            /** ->name in proper case */
207:
208:            public static final int APR_FINFO_MIN = 0x00008170;
209:            /** type, mtime, ctime, atime, size */
210:            public static final int APR_FINFO_IDENT = 0x00003000;
211:            /** dev and inode */
212:            public static final int APR_FINFO_OWNER = 0x00030000;
213:            /** user and group */
214:            public static final int APR_FINFO_PROT = 0x00700000;
215:            /**  all protections */
216:            public static final int APR_FINFO_NORM = 0x0073b170;
217:            /**  an atomic unix apr_stat() */
218:            public static final int APR_FINFO_DIRENT = 0x02000000;
219:
220:            /**  an atomic unix apr_dir_read() */
221:
222:            /**
223:             * Open the specified file.
224:             * @param fname The full path to the file (using / on all systems)
225:             * @param flag Or'ed value of:
226:             * <PRE>
227:             * APR_FOPEN_READ              open for reading
228:             * APR_FOPEN_WRITE             open for writing
229:             * APR_FOPEN_CREATE            create the file if not there
230:             * APR_FOPEN_APPEND            file ptr is set to end prior to all writes
231:             * APR_FOPEN_TRUNCATE          set length to zero if file exists
232:             * APR_FOPEN_BINARY            not a text file (This flag is ignored on
233:             *                             UNIX because it has no meaning)
234:             * APR_FOPEN_BUFFERED          buffer the data.  Default is non-buffered
235:             * APR_FOPEN_EXCL              return error if APR_CREATE and file exists
236:             * APR_FOPEN_DELONCLOSE        delete the file after closing.
237:             * APR_FOPEN_XTHREAD           Platform dependent tag to open the file
238:             *                             for use across multiple threads
239:             * APR_FOPEN_SHARELOCK         Platform dependent support for higher
240:             *                             level locked read/write access to support
241:             *                             writes across process/machines
242:             * APR_FOPEN_NOCLEANUP         Do not register a cleanup with the pool
243:             *                             passed in on the <EM>pool</EM> argument (see below).
244:             *                             The apr_os_file_t handle in apr_file_t will not
245:             *                             be closed when the pool is destroyed.
246:             * APR_FOPEN_SENDFILE_ENABLED  Open with appropriate platform semantics
247:             *                             for sendfile operations.  Advisory only,
248:             *                             apr_socket_sendfile does not check this flag.
249:             * </PRE>
250:             * @param perm Access permissions for file.
251:             * @param pool The pool to use.
252:             * If perm is APR_OS_DEFAULT and the file is being created,
253:             * appropriate default permissions will be used.
254:             * @return The opened file descriptor.
255:             */
256:            public static native long open(String fname, int flag, int perm,
257:                    long pool) throws Error;
258:
259:            /**
260:             * Close the specified file.
261:             * @param file The file descriptor to close.
262:             */
263:            public static native int close(long file);
264:
265:            /**
266:             * Flush the file's buffer.
267:             * @param thefile The file descriptor to flush
268:             */
269:            public static native int flush(long thefile);
270:
271:            /**
272:             * Open a temporary file
273:             * @param templ The template to use when creating a temp file.
274:             * @param flags The flags to open the file with. If this is zero,
275:             *              the file is opened with
276:             *              APR_CREATE | APR_READ | APR_WRITE | APR_EXCL | APR_DELONCLOSE
277:             * @param pool The pool to allocate the file out of.
278:             * @return The apr file to use as a temporary file.
279:             * 
280:             * This function  generates  a unique temporary file name from template.
281:             * The last six characters of template must be XXXXXX and these are replaced
282:             * with a string that makes the filename unique. Since it will  be  modified,
283:             * template must not be a string constant, but should be declared as a character
284:             * array.
285:             *
286:             */
287:            public static native long mktemp(String templ, int flags, long pool)
288:                    throws Error;
289:
290:            /**
291:             * Delete the specified file.
292:             * @param path The full path to the file (using / on all systems)
293:             * @param pool The pool to use.
294:             * If the file is open, it won't be removed until all
295:             * instances are closed.
296:             */
297:            public static native int remove(String path, long pool);
298:
299:            /**
300:             * Rename the specified file.
301:             * <br /><b>Warning :</b> If a file exists at the new location, then it will be
302:             * overwritten.  Moving files or directories across devices may not be
303:             * possible.
304:             * @param fromPath The full path to the original file (using / on all systems)
305:             * @param toPath The full path to the new file (using / on all systems)
306:             * @param pool The pool to use.
307:             */
308:            public static native int rename(String fromPath, String toPath,
309:                    long pool);
310:
311:            /**
312:             * Copy the specified file to another file.
313:             * The new file does not need to exist, it will be created if required.
314:             * <br /><b>Warning :</b> If the new file already exists, its contents will be overwritten.
315:             * @param fromPath The full path to the original file (using / on all systems)
316:             * @param toPath The full path to the new file (using / on all systems)
317:             * @param perms Access permissions for the new file if it is created.
318:             *     In place of the usual or'd combination of file permissions, the
319:             *     value APR_FILE_SOURCE_PERMS may be given, in which case the source
320:             *     file's permissions are copied.
321:             * @param pool The pool to use.
322:             */
323:            public static native int copy(String fromPath, String toPath,
324:                    int perms, long pool);
325:
326:            /**
327:             * Append the specified file to another file.
328:             * The new file does not need to exist, it will be created if required.
329:             * @param fromPath The full path to the source file (use / on all systems)
330:             * @param toPath The full path to the destination file (use / on all systems)
331:             * @param perms Access permissions for the destination file if it is created.
332:             *     In place of the usual or'd combination of file permissions, the
333:             *     value APR_FILE_SOURCE_PERMS may be given, in which case the source
334:             *     file's permissions are copied.
335:             * @param pool The pool to use.
336:             */
337:            public static native int append(String fromPath, String toPath,
338:                    int perms, long pool);
339:
340:            /**
341:             * Write the string into the specified file.
342:             * @param str The string to write. Must be NUL terminated!
343:             * @param thefile The file descriptor to write to
344:             */
345:            public static native int puts(byte[] str, long thefile);
346:
347:            /**
348:             * Move the read/write file offset to a specified byte within a file.
349:             * @param thefile The file descriptor
350:             * @param where How to move the pointer, one of:
351:             * <PRE>
352:             * APR_SET  --  set the offset to offset
353:             * APR_CUR  --  add the offset to the current position
354:             * APR_END  --  add the offset to the current file size
355:             * </PRE>
356:             * @param offset The offset to move the pointer to.
357:             * @return Offset the pointer was actually moved to.
358:             */
359:            public static native long seek(long thefile, int where, long offset)
360:                    throws Error;
361:
362:            /**
363:             * Write a character into the specified file.
364:             * @param ch The character to write.
365:             * @param thefile The file descriptor to write to
366:             */
367:            public static native int putc(byte ch, long thefile);
368:
369:            /**
370:             * Put a character back onto a specified stream.
371:             * @param ch The character to write.
372:             * @param thefile The file descriptor to write to
373:             */
374:            public static native int ungetc(byte ch, long thefile);
375:
376:            /**
377:             * Write data to the specified file.
378:             *
379:             * Write will write up to the specified number of
380:             * bytes, but never more.  If the OS cannot write that many bytes, it
381:             * will write as many as it can.  The third argument is modified to
382:             * reflect the * number of bytes written.
383:             *
384:             * It is possible for both bytes to be written and an error to
385:             * be returned.  APR_EINTR is never returned.
386:             * @param thefile The file descriptor to write to.
387:             * @param buf The buffer which contains the data.
388:             * @param offset Start offset in buf
389:             * @param nbytes The number of bytes to write; (-1) for full array.
390:             * @return The number of bytes written.
391:             */
392:            public static native int write(long thefile, byte[] buf,
393:                    int offset, int nbytes);
394:
395:            /**
396:             * Write data to the specified file.
397:             *
398:             * Write will write up to the specified number of
399:             * bytes, but never more.  If the OS cannot write that many bytes, it
400:             * will write as many as it can.  The third argument is modified to
401:             * reflect the * number of bytes written.
402:             *
403:             * It is possible for both bytes to be written and an error to
404:             * be returned.  APR_EINTR is never returned.
405:             * @param thefile The file descriptor to write to.
406:             * @param buf The direct Byte buffer which contains the data.
407:             * @param offset Start offset in buf
408:             * @param nbytes The number of bytes to write
409:             * @return The number of bytes written.
410:             */
411:            public static native int writeb(long thefile, ByteBuffer buf,
412:                    int offset, int nbytes);
413:
414:            /**
415:             * Write data to the specified file, ensuring that all of the data is
416:             * written before returning.
417:             *
418:             * Write will write up to the specified number of
419:             * bytes, but never more.  If the OS cannot write that many bytes, the
420:             * process/thread will block until they can be written. Exceptional
421:             * error such as "out of space" or "pipe closed" will terminate with
422:             * an error.
423:             *
424:             * It is possible for both bytes to be written and an error to
425:             * be returned.  And if *bytes_written is less than nbytes, an
426:             * accompanying error is _always_ returned.
427:             *
428:             * APR_EINTR is never returned.
429:             * @param thefile The file descriptor to write to.
430:             * @param buf The buffer which contains the data.
431:             * @param offset Start offset in buf
432:             * @param nbytes The number of bytes to write; (-1) for full array.
433:             * @return The number of bytes written.
434:             */
435:            public static native int writeFull(long thefile, byte[] buf,
436:                    int offset, int nbytes);
437:
438:            /**
439:             * Write data to the specified file, ensuring that all of the data is
440:             * written before returning.
441:             *
442:             * Write will write up to the specified number of
443:             * bytes, but never more.  If the OS cannot write that many bytes, the
444:             * process/thread will block until they can be written. Exceptional
445:             * error such as "out of space" or "pipe closed" will terminate with
446:             * an error.
447:             *
448:             * It is possible for both bytes to be written and an error to
449:             * be returned.  And if *bytes_written is less than nbytes, an
450:             * accompanying error is _always_ returned.
451:             *
452:             * APR_EINTR is never returned.
453:             * @param thefile The file descriptor to write to.
454:             * @param buf The direct ByteBuffer which contains the data.
455:             * @param offset Start offset in buf
456:             * @param nbytes The number of bytes to write.
457:             * @return The number of bytes written.
458:             */
459:            public static native int writeFullb(long thefile, ByteBuffer buf,
460:                    int offset, int nbytes);
461:
462:            /**
463:             * Write data from aray of byte arrays to the specified file.
464:             *
465:             * It is possible for both bytes to be written and an error to
466:             * be returned.  APR_EINTR is never returned.
467:             *
468:             * apr_file_writev is available even if the underlying
469:             * operating system doesn't provide writev().
470:             * @param thefile The file descriptor to write to.
471:             * @param vec The array from which to get the data to write to the file.
472:             * @return The number of bytes written.
473:             */
474:            public static native int writev(long thefile, byte[][] vec);
475:
476:            /**
477:             * Write data from aray of byte arrays to the specified file,
478:             * ensuring that all of the data is written before returning.
479:             *
480:             * writevFull is available even if the underlying
481:             * operating system doesn't provide writev().
482:             * @param thefile The file descriptor to write to.
483:             * @param vec The array from which to get the data to write to the file.
484:             * @return The number of bytes written.
485:             */
486:            public static native int writevFull(long thefile, byte[][] vec);
487:
488:            /**
489:             * Read data from the specified file.
490:             *
491:             * apr_file_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, all of the available data is read.  The third
494:             * argument is modified to reflect the number of bytes read.  If a
495:             * char was put back into the stream via ungetc, it will be the first
496:             * character returned.
497:             *
498:             * It is not possible for both bytes to be read and an APR_EOF
499:             * or other error to be returned.  APR_EINTR is never returned.
500:             * @param thefile The file descriptor to read from.
501:             * @param buf The buffer to store the data to.
502:             * @param offset Start offset in buf
503:             * @param nbytes The number of bytes to read (-1) for full array.
504:             * @return the number of bytes read.
505:             */
506:            public static native int read(long thefile, byte[] buf, int offset,
507:                    int nbytes);
508:
509:            /**
510:             * Read data from the specified file.
511:             *
512:             * apr_file_read will read up to the specified number of
513:             * bytes, but never more.  If there isn't enough data to fill that
514:             * number of bytes, all of the available data is read.  The third
515:             * argument is modified to reflect the number of bytes read.  If a
516:             * char was put back into the stream via ungetc, it will be the first
517:             * character returned.
518:             *
519:             * It is not possible for both bytes to be read and an APR_EOF
520:             * or other error to be returned.  APR_EINTR is never returned.
521:             * @param thefile The file descriptor to read from.
522:             * @param buf The direct Byte buffer to store the data to.
523:             * @param offset Start offset in buf
524:             * @param nbytes The number of bytes to read.
525:             * @return the number of bytes read.
526:             */
527:            public static native int readb(long thefile, ByteBuffer buf,
528:                    int offset, int nbytes);
529:
530:            /**
531:             * Read data from the specified file, ensuring that the buffer is filled
532:             * before returning.
533:             *
534:             * Read will read up to the specified number of
535:             * bytes, but never more.  If there isn't enough data to fill that
536:             * number of bytes, then the process/thread will block until it is
537:             * available or EOF is reached.  If a char was put back into the
538:             * stream via ungetc, it will be the first character returned.
539:             *
540:             * It is possible for both bytes to be read and an error to be
541:             * returned.  And if *bytes_read is less than nbytes, an accompanying
542:             * error is _always_ returned.
543:             *
544:             * APR_EINTR is never returned.
545:             * @param thefile The file descriptor to read from.
546:             * @param buf The buffer to store the data to.
547:             * @param offset Start offset in buf
548:             * @param nbytes The number of bytes to read (-1) for full array.
549:             * @return the number of bytes read.
550:             */
551:            public static native int readFull(long thefile, byte[] buf,
552:                    int offset, int nbytes);
553:
554:            /**
555:             * Read data from the specified file, ensuring that the buffer is filled
556:             * before returning.
557:             *
558:             * Read will read up to the specified number of
559:             * bytes, but never more.  If there isn't enough data to fill that
560:             * number of bytes, then the process/thread will block until it is
561:             * available or EOF is reached.  If a char was put back into the
562:             * stream via ungetc, it will be the first character returned.
563:             *
564:             * It is possible for both bytes to be read and an error to be
565:             * returned.  And if *bytes_read is less than nbytes, an accompanying
566:             * error is _always_ returned.
567:             *
568:             * APR_EINTR is never returned.
569:             * @param thefile The file descriptor to read from.
570:             * @param buf The direct ByteBuffer to store the data to.
571:             * @param offset Start offset in buf
572:             * @param nbytes The number of bytes to read.
573:             * @return the number of bytes read.
574:             */
575:            public static native int readFullb(long thefile, ByteBuffer buf,
576:                    int offset, int nbytes);
577:
578:            /**
579:             * Read a string from the specified file.
580:             * The buffer will be NUL-terminated if any characters are stored.
581:             * @param buf The buffer to store the string in.
582:             * @param offset Start offset in buf
583:             * @param thefile The file descriptor to read from
584:             */
585:            public static native int gets(byte[] buf, int offset, long thefile);
586:
587:            /**
588:             * Read a character from the specified file.
589:             * @param thefile The file descriptor to read from
590:             * @return The readed character
591:             */
592:            public static native int getc(long thefile) throws Error;
593:
594:            /**
595:             * Are we at the end of the file
596:             * @param fptr The apr file we are testing.
597:             * @return Returns APR_EOF if we are at the end of file, APR_SUCCESS otherwise.
598:             */
599:            public static native int eof(long fptr);
600:
601:            /**
602:             * return the file name of the current file.
603:             * @param thefile The currently open file.
604:             */
605:            public static native String nameGet(long thefile);
606:
607:            /**
608:             * Set the specified file's permission bits.
609:             * <br /><b>Warning :</b> Some platforms may not be able to apply all of the
610:             * available permission bits; APR_INCOMPLETE will be returned if some
611:             * permissions are specified which could not be set.
612:             * <br /><b>Warning :</b> Platforms which do not implement this feature will return
613:             * APR_ENOTIMPL.
614:             * @param fname The file (name) to apply the permissions to.
615:             * @param perms The permission bits to apply to the file.
616:             *
617:             */
618:            public static native int permsSet(String fname, int perms);
619:
620:            /**
621:             * Set attributes of the specified file.
622:             * This function should be used in preference to explict manipulation
623:             *      of the file permissions, because the operations to provide these
624:             *      attributes are platform specific and may involve more than simply
625:             *      setting permission bits.
626:             * <br /><b>Warning :</b> Platforms which do not implement this feature will return
627:             *      APR_ENOTIMPL.
628:             * @param fname The full path to the file (using / on all systems)
629:             * @param attributes Or'd combination of
630:             * <PRE>
631:             *            APR_FILE_ATTR_READONLY   - make the file readonly
632:             *            APR_FILE_ATTR_EXECUTABLE - make the file executable
633:             *            APR_FILE_ATTR_HIDDEN     - make the file hidden
634:             * </PRE>
635:             * @param mask Mask of valid bits in attributes.
636:             * @param pool the pool to use.
637:             */
638:            public static native int attrsSet(String fname, int attributes,
639:                    int mask, long pool);
640:
641:            /**
642:             * Set the mtime of the specified file.
643:             * <br /><b>Warning :</b> Platforms which do not implement this feature will return
644:             *      APR_ENOTIMPL.
645:             * @param fname The full path to the file (using / on all systems)
646:             * @param mtime The mtime to apply to the file in microseconds
647:             * @param pool The pool to use.
648:             */
649:            public static native int mtimeSet(String fname, long mtime,
650:                    long pool);
651:
652:            /**
653:             * Establish a lock on the specified, open file. The lock may be advisory
654:             * or mandatory, at the discretion of the platform. The lock applies to
655:             * the file as a whole, rather than a specific range. Locks are established
656:             * on a per-thread/process basis; a second lock by the same thread will not
657:             * block.
658:             * @param thefile The file to lock.
659:             * @param type The type of lock to establish on the file.
660:             */
661:            public static native int lock(long thefile, int type);
662:
663:            /**
664:             * Remove any outstanding locks on the file.
665:             * @param thefile The file to unlock.
666:             */
667:            public static native int unlock(long thefile);
668:
669:            /**
670:             * Retrieve the flags that were passed into apr_file_open()
671:             * when the file was opened.
672:             * @param file The file to retrive flags.
673:             * @return the flags
674:             */
675:            public static native int flagsGet(long file);
676:
677:            /**
678:             * Truncate the file's length to the specified offset
679:             * @param fp The file to truncate
680:             * @param offset The offset to truncate to.
681:             */
682:            public static native int trunc(long fp, long offset);
683:
684:            /**
685:             * Create an anonymous pipe.
686:             * @param io io[0] The file descriptors to use as input to the pipe.
687:             *           io[1] The file descriptor to use as output from the pipe.
688:             * @param pool The pool to operate on.
689:             */
690:            public static native int pipeCreate(long[] io, long pool);
691:
692:            /**
693:             * Get the timeout value for a pipe or manipulate the blocking state.
694:             * @param thepipe The pipe we are getting a timeout for.
695:             * @return The current timeout value in microseconds.
696:             */
697:            public static native long pipeTimeoutGet(long thepipe) throws Error;
698:
699:            /**
700:             * Set the timeout value for a pipe or manipulate the blocking state.
701:             * @param thepipe The pipe we are setting a timeout on.
702:             * @param timeout The timeout value in microseconds.  Values < 0 mean wait
703:             *        forever, 0 means do not wait at all.
704:             */
705:            public static native int pipeTimeoutSet(long thepipe, long timeout);
706:
707:            /**
708:             * Duplicate the specified file descriptor.
709:             * @param newFile The file to duplicate.
710:             * newFile must point to a valid apr_file_t, or point to NULL.
711:             * @param oldFile The file to duplicate.
712:             * @param pool The pool to use for the new file.
713:             * @return Duplicated file structure.
714:             */
715:            public static native long dup(long newFile, long oldFile, long pool)
716:                    throws Error;
717:
718:            /**
719:             * Duplicate the specified file descriptor and close the original.
720:             * @param newFile The old file that is to be closed and reused.
721:             * newFile MUST point at a valid apr_file_t. It cannot be NULL.
722:             * @param oldFile The file to duplicate.
723:             * @param pool The pool to use for the new file.
724:             * @return Status code.
725:             */
726:            public static native int dup2(long newFile, long oldFile, long pool);
727:
728:            /**
729:             * Get the specified file's stats.  The file is specified by filename,
730:             * instead of using a pre-opened file.
731:             * @param finfo Where to store the information about the file, which is
732:             * never touched if the call fails.
733:             * @param fname The name of the file to stat.
734:             * @param wanted The desired apr_finfo_t fields, as a bit flag of APR_FINFO_ values
735:             * @param pool the pool to use to allocate the new file.
736:             */
737:            public static native int stat(FileInfo finfo, String fname,
738:                    int wanted, long pool);
739:
740:            /**
741:             * Get the specified file's stats.
742:             * @param finfo Where to store the information about the file.
743:             * @param wanted The desired apr_finfo_t fields, as a bit flag of APR_FINFO_ values
744:             * @param thefile The file to get information about.
745:             */
746:            public static native int infoGet(FileInfo finfo, int wanted,
747:                    long thefile);
748:
749:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.