1
{ Copyright 2000-2005 The Apache Software Foundation or its licensors, as
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
* you may not use this file except in compliance with the License.
6
* You may obtain a copy of the License at
8
* http://www.apache.org/licenses/LICENSE-2.0
10
* Unless required by applicable law or agreed to in writing, software
11
* distributed under the License is distributed on an "AS IS" BASIS,
12
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
* See the License for the specific language governing permissions and
14
* limitations under the License.
19
* @brief APR File I/O Handling
23
#include "apr_pools.h"
25
#include "apr_errno.h"}
26
{.$include apr_file_info.inc}
27
{#include "apr_inherit.h"}
29
//#define APR_WANT_STDIO {< for SEEK_* }
30
//#define APR_WANT_IOVEC {< for apr_file_writev }
31
//#include "apr_want.h"
34
* @defgroup apr_file_io File I/O Handling Functions
39
* @defgroup apr_file_open_flags File Open Flags/Routines
42
{ Note to implementors: Values in the range 0x00100000--0x80000000
43
are reserved for platform-specific values. }
46
APR_FOPEN_READ = $00001; {< Open the file for reading }
47
APR_FOPEN_WRITE = $00002; {< Open the file for writing }
48
APR_FOPEN_CREATE = $00004; {< Create the file if not there }
49
APR_FOPEN_APPEND = $00008; {< Append to the end of the file }
50
APR_FOPEN_TRUNCATE = $00010; {< Open the file and truncate
52
APR_FOPEN_BINARY = $00020; {< Open the file in binary mode }
53
APR_FOPEN_EXCL = $00040; {< Open should fail if APR_CREATE
55
APR_FOPEN_BUFFERED = $00080; {< Open the file for buffered I/O }
56
APR_FOPEN_DELONCLOSE= $00100; {< Delete the file after close }
57
APR_FOPEN_XTHREAD = $00200; {< Platform dependent tag to open
58
the file for use across multiple
60
APR_FOPEN_SHARELOCK = $00400; {< Platform dependent support for
61
higher level locked read/write
62
access to support writes across
64
APR_FOPEN_NOCLEANUP = $00800; {< Do not register a cleanup
65
when the file is opened }
66
APR_FOPEN_SENDFILE_ENABLED = $01000; {< Advisory flag that this
68
apr_socket_sendfile operation }
69
APR_FOPEN_LARGEFILE = $04000; {< Platform dependent flag to enable
70
large file support; WARNING see
73
APR_READ = APR_FOPEN_READ; {< @deprecated @see APR_FOPEN_READ }
74
APR_WRITE = APR_FOPEN_WRITE; {< @deprecated @see APR_FOPEN_WRITE }
75
APR_CREATE = APR_FOPEN_CREATE; {< @deprecated @see APR_FOPEN_CREATE }
76
APR_APPEND = APR_FOPEN_APPEND; {< @deprecated @see APR_FOPEN_APPEND }
77
APR_TRUNCATE = APR_FOPEN_TRUNCATE; {< @deprecated @see APR_FOPEN_TRUNCATE }
78
APR_BINARY = APR_FOPEN_BINARY; {< @deprecated @see APR_FOPEN_BINARY }
79
APR_EXCL = APR_FOPEN_EXCL; {< @deprecated @see APR_FOPEN_EXCL }
80
APR_BUFFERED = APR_FOPEN_BUFFERED; {< @deprecated @see APR_FOPEN_BUFFERED }
81
APR_DELONCLOSE = APR_FOPEN_DELONCLOSE; {< @deprecated @see APR_FOPEN_DELONCLOSE }
82
APR_XTHREAD = APR_FOPEN_XTHREAD; {< @deprecated @see APR_FOPEN_XTHREAD }
83
APR_SHARELOCK = APR_FOPEN_SHARELOCK; {< @deprecated @see APR_FOPEN_SHARELOCK }
84
APR_FILE_NOCLEANUP = APR_FOPEN_NOCLEANUP; {< @deprecated @see APR_FOPEN_NOCLEANUP }
85
APR_SENDFILE_ENABLED= APR_FOPEN_SENDFILE_ENABLED; {< @deprecated @see APR_FOPEN_SENDFILE_ENABLED }
86
APR_LARGEFILE = APR_FOPEN_LARGEFILE; {< @deprecated @see APR_FOPEN_LARGEFILE }
88
{ @warning The APR_LARGEFILE flag only has effect on some platforms
89
* where sizeof(apr_off_t) == 4. Where implemented, it allows opening
90
* and writing to a file which exceeds the size which can be
91
* represented by apr_off_t (2 gigabytes). When a file's size does
92
* exceed 2Gb, apr_file_info_get() will fail with an error on the
93
* descriptor, likewise apr_stat()/apr_lstat() will fail on the
94
* filename. apr_dir_read() will fail with APR_INCOMPLETE on a
95
* directory entry for a large file depending on the particular
96
* APR_FINFO_* flags. Generally, it is not recommended to use this
100
* @defgroup apr_file_seek_flags File Seek Flags
104
* @defgroup apr_file_attrs_set_flags File Attribute Flags
107
{ flags for apr_file_attrs_set }
108
APR_FILE_ATTR_READONLY = $01; {< File is read-only }
109
APR_FILE_ATTR_EXECUTABLE =$02; {< File is executable }
110
APR_FILE_ATTR_HIDDEN = $04; {< File is hidden }
113
* @defgroup apr_file_writev(_full) max iovec size
116
APR_MAX_IOVEC_SIZE = 1024; {< System dependent maximum
117
size of an iovec array }
118
{#elif defined(IOV_MAX)
119
#define APR_MAX_IOVEC_SIZE IOV_MAX
120
#elif defined(MAX_IOVEC)
121
#define APR_MAX_IOVEC_SIZE MAX_IOVEC}
123
APR_MAX_IOVEC_SIZE = 1024;
128
apr_fileattrs_t = apr_uint32_t;
130
{ Type to pass as whence argument to apr_file_seek. }
131
apr_seek_where_t = Integer;
134
* Structure for referencing files.
136
apr_file_t = record end;
137
// Papr_file_t = ^apr_file_t;
138
PPapr_file_t = ^Papr_file_t;
140
{ File lock types/flags }
142
* @defgroup apr_file_lock_types File Lock Types
146
APR_FLOCK_SHARED = 1; {< Shared lock. More than one process
147
or thread can hold a shared lock
148
at any given time. Essentially,
149
this is a "read lock", preventing
150
writers from establishing an
152
APR_FLOCK_EXCLUSIVE = 2; {< Exclusive lock. Only one process
153
may hold an exclusive lock at any
154
given time. This is analogous to
157
APR_FLOCK_TYPEMASK = $000F; {< mask to extract lock type }
158
APR_FLOCK_NONBLOCK = $0010; {< do not block while acquiring the
161
* Open the specified file.
162
* @param newf The opened file descriptor.
163
* @param fname The full path to the file (using / on all systems)
164
* @param flag Or'ed value of:
166
* APR_READ open for reading
167
* APR_WRITE open for writing
168
* APR_CREATE create the file if not there
169
* APR_APPEND file ptr is set to end prior to all writes
170
* APR_TRUNCATE set length to zero if file exists
171
* APR_BINARY not a text file (This flag is ignored on
172
* UNIX because it has no meaning)
173
* APR_BUFFERED buffer the data. Default is non-buffered
174
* APR_EXCL return error if APR_CREATE and file exists
175
* APR_DELONCLOSE delete the file after closing.
176
* APR_XTHREAD Platform dependent tag to open the file
177
* for use across multiple threads
178
* APR_SHARELOCK Platform dependent support for higher
179
* level locked read/write access to support
180
* writes across process/machines
181
* APR_FILE_NOCLEANUP Do not register a cleanup with the pool
182
* passed in on the <EM>pool</EM> argument (see below).
183
* The apr_os_file_t handle in apr_file_t will not
184
* be closed when the pool is destroyed.
185
* APR_SENDFILE_ENABLED Open with appropriate platform semantics
186
* for sendfile operations. Advisory only,
187
* apr_socket_sendfile does not check this flag.
189
* @param perm Access permissions for file.
190
* @param pool The pool to use.
191
* @remark If perm is APR_OS_DEFAULT and the file is being created, appropriate
192
* default permissions will be used. *arg1 must point to a valid file_t,
193
* or NULL (in which case it will be allocated)
195
function apr_file_open(newf: PPapr_file_t; const fname: PChar;
196
flag: apr_int32_t; perm: apr_fileperms_t;
197
pool: Papr_pool_t): apr_status_t;
198
{$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
199
external LibAPR name LibNamePrefix + 'apr_file_open' + LibSuff20;
202
* Close the specified file.
203
* @param file The file descriptor to close.
205
function apr_file_close(file_: Papr_file_t): apr_status_t;
206
{$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
207
external LibAPR name LibNamePrefix + 'apr_file_close' + LibSuff4;
210
* delete the specified file.
211
* @param path The full path to the file (using / on all systems)
212
* @param pool The pool to use.
213
* @remark If the file is open, it won't be removed until all instances are closed.
215
function apr_file_remove(const path: PChar; pool: Papr_pool_t): apr_status_t;
216
{$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
217
external LibAPR name LibNamePrefix + 'apr_file_remove' + LibSuff8;
220
* rename the specified file.
221
* @param from_path The full path to the original file (using / on all systems)
222
* @param to_path The full path to the new file (using / on all systems)
223
* @param pool The pool to use.
224
* @warning If a file exists at the new location, then it will be overwritten.
225
* Moving files or directories across devices may not be possible.
227
function apr_file_rename(const from_path, to_path: PChar; pool: Papr_pool_t): apr_status_t;
228
{$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
229
external LibAPR name LibNamePrefix + 'apr_file_rename' + LibSuff12;
232
* copy the specified file to another file.
233
* @param from_path The full path to the original file (using / on all systems)
234
* @param to_path The full path to the new file (using / on all systems)
235
* @param perms Access permissions for the new file if it is created.
236
* In place of the usual or'd combination of file permissions, the
237
* value APR_FILE_SOURCE_PERMS may be given, in which case the source
238
* file's permissions are copied.
239
* @param pool The pool to use.
240
* @remark The new file does not need to exist, it will be created if required.
241
* @warning If the new file already exists, its contents will be overwritten.
243
function apr_file_copy(const from_path, to_path: PChar;
244
perms: apr_fileperms_t; pool: Papr_pool_t): apr_status_t;
245
{$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
246
external LibAPR name LibNamePrefix + 'apr_file_copy' + LibSuff16;
249
* append the specified file to another file.
250
* @param from_path The full path to the source file (using / on all systems)
251
* @param to_path The full path to the destination file (using / on all systems)
252
* @param perms Access permissions for the destination file if it is created.
253
* In place of the usual or'd combination of file permissions, the
254
* value APR_FILE_SOURCE_PERMS may be given, in which case the source
255
* file's permissions are copied.
256
* @param pool The pool to use.
257
* @remark The new file does not need to exist, it will be created if required.
259
function apr_file_append(const from_path, to_path: PChar;
260
perms: apr_fileperms_t; pool: Papr_pool_t): apr_status_t;
261
{$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
262
external LibAPR name LibNamePrefix + 'apr_file_append' + LibSuff16;
265
* Are we at the end of the file
266
* @param fptr The apr file we are testing.
267
* @remark Returns APR_EOF if we are at the end of file, APR_SUCCESS otherwise.
269
function apr_file_eof(fptr: Papr_file_t): apr_status_t;
270
{$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
271
external LibAPR name LibNamePrefix + 'apr_file_eof' + LibSuff4;
274
* open standard error as an apr file pointer.
275
* @param thefile The apr file to use as stderr.
276
* @param pool The pool to allocate the file out of.
278
* @remark The only reason that the apr_file_open_std* functions exist
279
* is that you may not always have a stderr/out/in on Windows. This
280
* is generally a problem with newer versions of Windows and services.
282
* The other problem is that the C library functions generally work
283
* differently on Windows and Unix. So, by using apr_file_open_std*
284
* functions, you can get a handle to an APR struct that works with
285
* the APR functions which are supposed to work identically on all
288
function apr_file_open_stderr(thefile: PPapr_file_t;
289
pool: Papr_pool_t): apr_status_t;
290
{$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
291
external LibAPR name LibNamePrefix + 'apr_file_open_stderr' + LibSuff8;
294
* open standard output as an apr file pointer.
295
* @param thefile The apr file to use as stdout.
296
* @param pool The pool to allocate the file out of.
298
* @remark See remarks for apr_file_open_stdout.
300
function apr_file_open_stdout(thefile: PPapr_file_t;
301
pool: Papr_pool_t): apr_status_t;
302
{$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
303
external LibAPR name LibNamePrefix + 'apr_file_open_stdout' + LibSuff8;
306
* open standard input as an apr file pointer.
307
* @param thefile The apr file to use as stdin.
308
* @param pool The pool to allocate the file out of.
310
* @remark See remarks for apr_file_open_stdout.
312
function apr_file_open_stdin(thefile: PPapr_file_t;
313
pool: Papr_pool_t): apr_status_t;
314
{$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
315
external LibAPR name LibNamePrefix + 'apr_file_open_stdin' + LibSuff8;
318
* Read data from the specified file.
319
* @param thefile The file descriptor to read from.
320
* @param buf The buffer to store the data to.
321
* @param nbytes On entry, the number of bytes to read; on exit, the number
324
* @remark apr_file_read will read up to the specified number of
325
* bytes, but never more. If there isn't enough data to fill that
326
* number of bytes, all of the available data is read. The third
327
* argument is modified to reflect the number of bytes read. If a
328
* char was put back into the stream via ungetc, it will be the first
329
* character returned.
331
* @remark It is not possible for both bytes to be read and an APR_EOF
332
* or other error to be returned. APR_EINTR is never returned.
334
function apr_file_read(thefile: Papr_file_t; buf: Pointer;
335
nbytes: Papr_size_t): apr_status_t;
336
{$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
337
external LibAPR name LibNamePrefix + 'apr_file_read' + LibSuff12;
340
* Write data to the specified file.
341
* @param thefile The file descriptor to write to.
342
* @param buf The buffer which contains the data.
343
* @param nbytes On entry, the number of bytes to write; on exit, the number
346
* @remark apr_file_write will write up to the specified number of
347
* bytes, but never more. If the OS cannot write that many bytes, it
348
* will write as many as it can. The third argument is modified to
349
* reflect the * number of bytes written.
351
* @remark It is possible for both bytes to be written and an error to
352
* be returned. APR_EINTR is never returned.
354
function apr_file_write(thefile: Papr_file_t; buf: Pointer;
355
nbytes: Papr_size_t): apr_status_t;
356
{$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
357
external LibAPR name LibNamePrefix + 'apr_file_write' + LibSuff12;
360
* Write data from iovec array to the specified file.
361
* @param thefile The file descriptor to write to.
362
* @param vec The array from which to get the data to write to the file.
363
* @param nvec The number of elements in the struct iovec array. This must
364
* be smaller than APR_MAX_IOVEC_SIZE. If it isn't, the function
365
* will fail with APR_EINVAL.
366
* @param nbytes The number of bytes written.
368
* @remark It is possible for both bytes to be written and an error to
369
* be returned. APR_EINTR is never returned.
371
* @remark apr_file_writev is available even if the underlying
372
* operating system doesn't provide writev().
374
function apr_file_writev(thefile: Papr_file_t; const vec: Piovec;
375
nvec: apr_size_t; nbytes: Papr_size_t): apr_status_t;
376
{$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
377
external LibAPR name LibNamePrefix + 'apr_file_writev' + LibSuff16;
380
* Read data from the specified file, ensuring that the buffer is filled
382
* @param thefile The file descriptor to read from.
383
* @param buf The buffer to store the data to.
384
* @param nbytes The number of bytes to read.
385
* @param bytes_read If non-NULL, this will contain the number of bytes read.
387
* @remark apr_file_read will read up to the specified number of
388
* bytes, but never more. If there isn't enough data to fill that
389
* number of bytes, then the process/thread will block until it is
390
* available or EOF is reached. If a char was put back into the
391
* stream via ungetc, it will be the first character returned.
393
* @remark It is possible for both bytes to be read and an error to be
394
* returned. And if *bytes_read is less than nbytes, an accompanying
395
* error is _always_ returned.
397
* @remark APR_EINTR is never returned.
399
function apr_file_read_full(thefile: Papr_file_t; buf: Pointer;
400
nbytes: apr_size_t; bytes_read: Papr_size_t): apr_status_t;
401
{$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
402
external LibAPR name LibNamePrefix + 'apr_file_read_full' + LibSuff16;
405
* Write data to the specified file, ensuring that all of the data is
406
* written before returning.
407
* @param thefile The file descriptor to write to.
408
* @param buf The buffer which contains the data.
409
* @param nbytes The number of bytes to write.
410
* @param bytes_written If non-NULL, set to the number of bytes written.
412
* @remark apr_file_write will write up to the specified number of
413
* bytes, but never more. If the OS cannot write that many bytes, the
414
* process/thread will block until they can be written. Exceptional
415
* error such as "out of space" or "pipe closed" will terminate with
418
* @remark It is possible for both bytes to be written and an error to
419
* be returned. And if *bytes_written is less than nbytes, an
420
* accompanying error is _always_ returned.
422
* @remark APR_EINTR is never returned.
424
function apr_file_write_full(thefile: Papr_file_t; buf: Pointer;
425
nbytes: apr_size_t; bytes_written: Papr_size_t): apr_status_t;
426
{$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
427
external LibAPR name LibNamePrefix + 'apr_file_write_full' + LibSuff16;
430
* Write data from iovec array to the specified file, ensuring that all of the
431
* data is written before returning.
432
* @param thefile The file descriptor to write to.
433
* @param vec The array from which to get the data to write to the file.
434
* @param nvec The number of elements in the struct iovec array. This must
435
* be smaller than APR_MAX_IOVEC_SIZE. If it isn't, the function
436
* will fail with APR_EINVAL.
437
* @param nbytes The number of bytes written.
439
* @remark apr_file_writev_full is available even if the underlying
440
* operating system doesn't provide writev().
442
function apr_file_writev_full(thefile: Papr_file_t; const vec: Piovec;
443
nvec: apr_size_t; nbytes: Papr_size_t): apr_status_t;
444
{$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
445
external LibAPR name LibNamePrefix + 'apr_file_writev_full' + LibSuff16;
448
* Write a character into the specified file.
449
* @param ch The character to write.
450
* @param thefile The file descriptor to write to
452
function apr_file_putc(ch: Char; thefile: Papr_file_t): apr_status_t;
453
{$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
454
external LibAPR name LibNamePrefix + 'apr_file_putc' + LibSuff8;
457
* get a character from the specified file.
458
* @param ch The character to read into
459
* @param thefile The file descriptor to read from
461
function apr_file_getc(ch: PChar; thefile: Papr_file_t): apr_status_t;
462
{$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
463
external LibAPR name LibNamePrefix + 'apr_file_getc' + LibSuff8;
466
* put a character back onto a specified stream.
467
* @param ch The character to write.
468
* @param thefile The file descriptor to write to
470
function apr_file_ungetc(ch: Char; thefile: PPapr_file_t): apr_status_t;
471
{$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
472
external LibAPR name LibNamePrefix + 'apr_file_ungetc' + LibSuff8;
475
* Get a string from a specified file.
476
* @param str The buffer to store the string in.
477
* @param len The length of the string
478
* @param thefile The file descriptor to read from
479
* @remark The buffer will be '\0'-terminated if any characters are stored.
481
function apr_file_gets(str: PChar; len: Integer;
482
thefile: Papr_file_t): apr_status_t;
483
{$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
484
external LibAPR name LibNamePrefix + 'apr_file_gets' + LibSuff12;
487
* Put the string into a specified file.
488
* @param str The string to write.
489
* @param thefile The file descriptor to write to
491
function apr_file_puts(const str: PChar; thefile: Papr_file_t): apr_status_t;
492
{$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
493
external LibAPR name LibNamePrefix + 'apr_file_puts' + LibSuff8;
496
* Flush the file's buffer.
497
* @param thefile The file descriptor to flush
499
function apr_file_flush(thefile: PPapr_file_t): apr_status_t;
500
{$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
501
external LibAPR name LibNamePrefix + 'apr_file_flush' + LibSuff4;
504
* duplicate the specified file descriptor.
505
* @param new_file The structure to duplicate into.
506
* @param old_file The file to duplicate.
507
* @param p The pool to use for the new file.
508
* @remark *new_file must point to a valid apr_file_t, or point to NULL
510
function apr_file_dup(new_file: PPapr_file_t; old_file: PPapr_file_t;
511
p: Papr_pool_t): apr_status_t;
512
{$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
513
external LibAPR name LibNamePrefix + 'apr_file_dup' + LibSuff12;
516
* duplicate the specified file descriptor and close the original
517
* @param new_file The old file that is to be closed and reused
518
* @param old_file The file to duplicate
519
* @param p The pool to use for the new file
521
* @remark new_file MUST point at a valid apr_file_t. It cannot be NULL
523
function apr_file_dup2(new_file: PPapr_file_t; old_file: PPapr_file_t;
524
p: Papr_pool_t): apr_status_t;
525
{$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
526
external LibAPR name LibNamePrefix + 'apr_file_dup2' + LibSuff12;
529
* move the specified file descriptor to a new pool
530
* @param new_file Pointer in which to return the new apr_file_t
531
* @param old_file The file to move
532
* @param p The pool to which the descriptor is to be moved
533
* @remark Unlike apr_file_dup2(), this function doesn't do an
534
* OS dup() operation on the underlying descriptor; it just
535
* moves the descriptor's apr_file_t wrapper to a new pool.
536
* @remark The new pool need not be an ancestor of old_file's pool.
537
* @remark After calling this function, old_file may not be used
539
function apr_file_setaside(new_file: PPapr_file_t; old_file: PPapr_file_t;
540
p: Papr_pool_t): apr_status_t;
541
{$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
542
external LibAPR name LibNamePrefix + 'apr_file_setaside' + LibSuff12;
545
* Move the read/write file offset to a specified byte within a file.
546
* @param thefile The file descriptor
547
* @param where How to move the pointer, one of:
549
* APR_SET -- set the offset to offset
550
* APR_CUR -- add the offset to the current position
551
* APR_END -- add the offset to the current file size
553
* @param offset The offset to move the pointer to.
554
* @remark The third argument is modified to be the offset the pointer
555
was actually moved to.
557
function apr_file_seek(thefile: Papr_file_t;
558
where: apr_seek_where_t; offset: Papr_off_t): apr_status_t;
559
{$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
560
external LibAPR name LibNamePrefix + 'apr_file_seek' + LibSuff12;
563
* Create an anonymous pipe.
564
* @param in The file descriptor to use as input to the pipe.
565
* @param out The file descriptor to use as output from the pipe.
566
* @param pool The pool to operate on.
568
function apr_file_pipe_create(in_: PPapr_file_t; out_: PPapr_file_t;
569
pool: Papr_pool_t): apr_status_t;
570
{$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
571
external LibAPR name LibNamePrefix + 'apr_file_pipe_create' + LibSuff12;
574
* Create a named pipe.
575
* @param filename The filename of the named pipe
576
* @param perm The permissions for the newly created pipe.
577
* @param pool The pool to operate on.
579
function apr_file_namedpipe_create(const filename: PChar;
580
perm: apr_fileperms_t; pool: Papr_pool_t): apr_status_t;
581
{$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
582
external LibAPR name LibNamePrefix + 'apr_file_namedpipe_create' + LibSuff12;
585
* Get the timeout value for a pipe or manipulate the blocking state.
586
* @param thepipe The pipe we are getting a timeout for.
587
* @param timeout The current timeout value in microseconds.
589
function apr_file_pipe_timeout_get(thepipe: Papr_file_t;
590
timeout: Papr_interval_time_t): apr_status_t;
591
{$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
592
external LibAPR name LibNamePrefix + 'apr_file_pipe_timeout_get' + LibSuff8;
595
* Set the timeout value for a pipe or manipulate the blocking state.
596
* @param thepipe The pipe we are setting a timeout on.
597
* @param timeout The timeout value in microseconds. Values < 0 mean wait
598
* forever, 0 means do not wait at all.
600
function apr_file_pipe_timeout_set(thepipe: Papr_file_t;
601
timeout: apr_interval_time_t): apr_status_t;
602
{$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
603
external LibAPR name LibNamePrefix + 'apr_file_pipe_timeout_set' + LibSuff12;
605
{ file (un)locking functions. }
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
613
* @param thefile The file to lock.
614
* @param type The type of lock to establish on the file.
616
function apr_file_lock(thefile: Papr_file_t; type_: Integer): apr_status_t;
617
{$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
618
external LibAPR name LibNamePrefix + 'apr_file_lock' + LibSuff8;
621
* Remove any outstanding locks on the file.
622
* @param thefile The file to unlock.
624
function apr_file_unlock(thefile: Papr_file_t): apr_status_t;
625
{$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
626
external LibAPR name LibNamePrefix + 'apr_file_unlock' + LibSuff4;
628
{accessor and general file_io functions. }
631
* return the file name of the current file.
632
* @param new_path The path of the file.
633
* @param thefile The currently open file.
635
function apr_file_name_get(const newpath: PPChar; thefile: Papr_file_t): apr_status_t;
636
{$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
637
external LibAPR name LibNamePrefix + 'apr_file_name_get' + LibSuff8;
640
* Return the data associated with the current file.
641
* @param data The user data associated with the file.
642
* @param key The key to use for retreiving data associated with this file.
643
* @param file The currently open file.
645
function apr_file_data_get(data: PPointer; const key: PChar;
646
file_: Papr_file_t): apr_status_t;
647
{$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
648
external LibAPR name LibNamePrefix + 'apr_file_data_get' + LibSuff12;
651
* Set the data associated with the current file.
652
* @param file The currently open file.
653
* @param data The user data to associate with the file.
654
* @param key The key to use for assocaiteing data with the file.
655
* @param cleanup The cleanup routine to use when the file is destroyed.
657
//function apr_file_data_set(ch: Char; thefile: PPapr_file_t): apr_status_t;
658
// {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
659
// external LibAPR name LibNamePrefix + 'apr_file_data_set' + LibSuff4;
660
//APR_DECLARE(apr_status_t) (apr_file_t *file, void *data,
662
// apr_status_t (*cleanup)(void *));
665
* Write a string to a file using a printf format.
666
* @param fptr The file to write to.
667
* @param format The format string
668
* @param ... The values to substitute in the format string
669
* @return The number of bytes written
671
function apr_file_printf(fptr: Papr_file_t; const format: PChar;
672
othres: array of const): Integer;
673
cdecl; external LibAPR name 'apr_file_printf';
676
* set the specified file's permission bits.
677
* @param fname The file (name) to apply the permissions to.
678
* @param perms The permission bits to apply to the file.
679
* @warning Some platforms may not be able to apply all of the available
680
* permission bits; APR_INCOMPLETE will be returned if some permissions
681
* are specified which could not be set.
683
* Platforms which do not implement this feature will return APR_ENOTIMPL.
685
function apr_file_perms_set(const fname: PChar;
686
perms: apr_fileperms_t): apr_status_t;
687
{$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
688
external LibAPR name LibNamePrefix + 'apr_file_perms_set' + LibSuff8;
691
* Set attributes of the specified file.
692
* @param fname The full path to the file (using / on all systems)
693
* @param attributes Or'd combination of
695
* APR_FILE_ATTR_READONLY - make the file readonly
696
* APR_FILE_ATTR_EXECUTABLE - make the file executable
697
* APR_FILE_ATTR_HIDDEN - make the file hidden
699
* @param attr_mask Mask of valid bits in attributes.
700
* @param pool the pool to use.
701
* @remark This function should be used in preference to explict manipulation
702
* of the file permissions, because the operations to provide these
703
* attributes are platform specific and may involve more than simply
704
* setting permission bits.
705
* @warning Platforms which do not implement this feature will return
708
function apr_file_attrs_set(const fname: PChar;
709
attributes, attr_mask: apr_fileattrs_t;
710
pool: Papr_pool_t): apr_status_t;
711
{$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
712
external LibAPR name LibNamePrefix + 'apr_file_attrs_set' + LibSuff16;
715
* Set the mtime of the specified file.
716
* @param fname The full path to the file (using / on all systems)
717
* @param mtime The mtime to apply to the file.
718
* @param pool The pool to use.
719
* @warning Platforms which do not implement this feature will return
722
function apr_file_mtime_set(const fname: PChar;
723
mtime: apr_time_t; pool: Papr_pool_t): apr_status_t;
724
{$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
725
external LibAPR name LibNamePrefix + 'apr_file_mtime_set' + LibSuff16;
728
* Create a new directory on the file system.
729
* @param path the path for the directory to be created. (use / on all systems)
730
* @param perm Permissions for the new direcoty.
731
* @param pool the pool to use.
733
function apr_dir_make(const path: PChar; perm: apr_fileperms_t;
734
pool: Papr_pool_t): apr_status_t;
735
{$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
736
external LibAPR name LibNamePrefix + 'apr_dir_make' + LibSuff12;
738
{ Creates a new directory on the file system, but behaves like
739
* 'mkdir -p'. Creates intermediate directories as required. No error
740
* will be reported if PATH already exists.
741
* @param path the path for the directory to be created. (use / on all systems)
742
* @param perm Permissions for the new direcoty.
743
* @param pool the pool to use.
745
function apr_dir_make_recursive(const path: PChar;
746
perm: apr_fileperms_t; pool: Papr_pool_t): apr_status_t;
747
{$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
748
external LibAPR name LibNamePrefix + 'apr_dir_make_recursive' + LibSuff12;
751
* Remove directory from the file system.
752
* @param path the path for the directory to be removed. (use / on all systems)
753
* @param pool the pool to use.
755
function apr_dir_remove(const path: PChar; pool: Papr_pool_t): apr_status_t;
756
{$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
757
external LibAPR name LibNamePrefix + 'apr_dir_remove' + LibSuff8;
760
* get the specified file's stats.
761
* @param finfo Where to store the information about the file.
762
* @param wanted The desired apr_finfo_t fields, as a bit flag of APR_FINFO_ values
763
* @param thefile The file to get information about.
765
function apr_file_info_get(finfo: Papr_finfo_t;
766
wanted: apr_int32_t; thefile: Papr_file_t): apr_status_t;
767
{$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
768
external LibAPR name LibNamePrefix + 'apr_file_info_get' + LibSuff12;
771
* Truncate the file's length to the specified offset
772
* @param fp The file to truncate
773
* @param offset The offset to truncate to.
775
function apr_file_trunc(fp: Papr_file_t; offset: apr_off_t): apr_status_t;
776
{$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
777
external LibAPR name LibNamePrefix + 'apr_file_trunc' + LibSuff12;
780
* Retrieve the flags that were passed into apr_file_open()
781
* when the file was opened.
782
* @return apr_int32_t the flags
784
function apr_file_flags_get(f: Papr_file_t): apr_int32_t;
785
{$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
786
external LibAPR name LibNamePrefix + 'apr_file_flags_get' + LibSuff4;
789
* Get the pool used by the file.
791
{APR_POOL_DECLARE_ACCESSOR(file);
794
* Set a file to be inherited by child processes.
797
{APR_DECLARE_INHERIT_SET(file);
801
* Unset a file from being inherited by child processes.
803
{APR_DECLARE_INHERIT_UNSET(file);
807
* Open a temporary file
808
* @param fp The apr file to use as a temporary file.
809
* @param templ The template to use when creating a temp file.
810
* @param flags The flags to open the file with. If this is zero,
811
* the file is opened with
812
* APR_CREATE | APR_READ | APR_WRITE | APR_EXCL | APR_DELONCLOSE
813
* @param p The pool to allocate the file out of.
815
* This function generates a unique temporary file name from template.
816
* The last six characters of template must be XXXXXX and these are replaced
817
* with a string that makes the filename unique. Since it will be modified,
818
* template must not be a string constant, but should be declared as a character
822
function apr_file_mktemp(fp: PPapr_file_t; templ: PChar;
823
flags: apr_int32_t; p: Papr_pool_t): apr_status_t;
824
{$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
825
external LibAPR name LibNamePrefix + 'apr_file_mktemp' + LibSuff16;
828
* Find an existing directory suitable as a temporary storage location.
829
* @param temp_dir The temp directory.
830
* @param p The pool to use for any necessary allocations.
832
* This function uses an algorithm to search for a directory that an
833
* an application can use for temporary storage. Once such a
834
* directory is found, that location is cached by the library. Thus,
835
* callers only pay the cost of this algorithm once if that one time
839
function apr_temp_dir_get(const temp_dir: PPChar; p: Papr_pool_t): apr_status_t;
840
{$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
841
external LibAPR name LibNamePrefix + 'apr_temp_dir_get' + LibSuff8;