typedef struct apr_file_t apr_file_t |
Structure for referencing files.
typedef apr_uint32_t apr_fileattrs_t |
File attributes
typedef int apr_seek_where_t |
Type to pass as whence argument to apr_file_seek.
apr_status_t apr_dir_make | ( | const char * | path, | |
apr_fileperms_t | perm, | |||
apr_pool_t * | pool | |||
) |
Create a new directory on the file system.
path | the path for the directory to be created. (use / on all systems) | |
perm | Permissions for the new directory. | |
pool | the pool to use. |
apr_status_t apr_dir_make_recursive | ( | const char * | path, | |
apr_fileperms_t | perm, | |||
apr_pool_t * | pool | |||
) |
Creates a new directory on the file system, but behaves like 'mkdir -p'. Creates intermediate directories as required. No error will be reported if PATH already exists.
path | the path for the directory to be created. (use / on all systems) | |
perm | Permissions for the new directory. | |
pool | the pool to use. |
apr_status_t apr_dir_remove | ( | const char * | path, | |
apr_pool_t * | pool | |||
) |
Remove directory from the file system.
path | the path for the directory to be removed. (use / on all systems) | |
pool | the pool to use. |
apr_status_t apr_file_append | ( | const char * | from_path, | |
const char * | to_path, | |||
apr_fileperms_t | perms, | |||
apr_pool_t * | pool | |||
) |
Append the specified file to another file.
from_path | The full path to the source file (use / on all systems) | |
to_path | The full path to the destination file (use / on all systems) | |
perms | Access permissions for the destination file if it is created. In place of the usual or'd combination of file permissions, the value APR_FPROT_FILE_SOURCE_PERMS may be given, in which case the source file's permissions are copied. | |
pool | The pool to use. |
Note that advanced filesystem permissions such as ACLs are not duplicated by this API. The target permissions (including duplicating the source file permissions) are assigned only when the target file does not yet exist.
apr_status_t apr_file_attrs_set | ( | const char * | fname, | |
apr_fileattrs_t | attributes, | |||
apr_fileattrs_t | attr_mask, | |||
apr_pool_t * | pool | |||
) |
Set attributes of the specified file.
fname | The full path to the file (using / on all systems) | |
attributes | Or'd combination of
| |
attr_mask | Mask of valid bits in attributes. | |
pool | the pool to use. |
apr_status_t apr_file_buffer_set | ( | apr_file_t * | thefile, | |
char * | buffer, | |||
apr_size_t | bufsize | |||
) |
Give the specified apr file handle a new buffer
thefile | The file handle that is to be modified | |
buffer | The buffer | |
bufsize | The size of the buffer |
apr_size_t apr_file_buffer_size_get | ( | apr_file_t * | thefile | ) |
Get the size of any buffer for the specified apr file handle
thefile | The file handle |
apr_status_t apr_file_close | ( | apr_file_t * | file | ) |
Close the specified file.
file | The file descriptor to close. |
apr_status_t apr_file_copy | ( | const char * | from_path, | |
const char * | to_path, | |||
apr_fileperms_t | perms, | |||
apr_pool_t * | pool | |||
) |
Copy the specified file to another file.
from_path | The full path to the original file (using / on all systems) | |
to_path | The full path to the new file (using / on all systems) | |
perms | Access permissions for the new file if it is created. In place of the usual or'd combination of file permissions, the value APR_FPROT_FILE_SOURCE_PERMS may be given, in which case the source file's permissions are copied. | |
pool | The pool to use. |
apr_status_t apr_file_data_get | ( | void ** | data, | |
const char * | key, | |||
apr_file_t * | file | |||
) |
Return the data associated with the current file.
data | The user data associated with the file. | |
key | The key to use for retrieving data associated with this file. | |
file | The currently open file. |
apr_status_t apr_file_data_set | ( | apr_file_t * | file, | |
void * | data, | |||
const char * | key, | |||
apr_status_t(*)(void *) | cleanup | |||
) |
Set the data associated with the current file.
file | The currently open file. | |
data | The user data to associate with the file. | |
key | The key to use for associating data with the file. | |
cleanup | The cleanup routine to use when the file is destroyed. |
apr_status_t apr_file_datasync | ( | apr_file_t * | thefile | ) |
Transfer all file modified data to disk.
thefile | The file descriptor to sync |
apr_status_t apr_file_dup | ( | apr_file_t ** | new_file, | |
apr_file_t * | old_file, | |||
apr_pool_t * | p | |||
) |
Duplicate the specified file descriptor.
new_file | The structure to duplicate into. | |
old_file | The file to duplicate. | |
p | The pool to use for the new file. |
apr_status_t apr_file_dup2 | ( | apr_file_t * | new_file, | |
apr_file_t * | old_file, | |||
apr_pool_t * | p | |||
) |
Duplicate the specified file descriptor and close the original
new_file | The old file that is to be closed and reused | |
old_file | The file to duplicate | |
p | The pool to use for the new file |
apr_status_t apr_file_eof | ( | apr_file_t * | fptr | ) |
Are we at the end of the file
fptr | The apr file we are testing. |
apr_int32_t apr_file_flags_get | ( | apr_file_t * | f | ) |
Retrieve the flags that were passed into apr_file_open() when the file was opened.
apr_status_t apr_file_flush | ( | apr_file_t * | thefile | ) |
Flush the file's buffer.
thefile | The file descriptor to flush |
apr_status_t apr_file_getc | ( | char * | ch, | |
apr_file_t * | thefile | |||
) |
Read a character from the specified file.
ch | The character to read into | |
thefile | The file descriptor to read from |
apr_status_t apr_file_gets | ( | char * | str, | |
int | len, | |||
apr_file_t * | thefile | |||
) |
Read a line from the specified file
str | The buffer to store the string in. | |
len | The length of the string | |
thefile | The file descriptor to read from |
apr_status_t apr_file_info_get | ( | apr_finfo_t * | finfo, | |
apr_int32_t | wanted, | |||
apr_file_t * | thefile | |||
) |
get the specified file's stats.
finfo | Where to store the information about the file. | |
wanted | The desired apr_finfo_t fields, as a bit flag of APR_FINFO_* values | |
thefile | The file to get information about. |
apr_status_t apr_file_inherit_set | ( | apr_file_t * | thefile | ) |
Set a file to be inherited by child processes.
apr_status_t apr_file_inherit_unset | ( | apr_file_t * | thefile | ) |
Unset a file from being inherited by child processes.
apr_status_t apr_file_link | ( | const char * | from_path, | |
const char * | to_path | |||
) |
Create a hard link to the specified file.
from_path | The full path to the original file (using / on all systems) | |
to_path | The full path to the new file (using / on all systems) |
apr_status_t apr_file_lock | ( | apr_file_t * | thefile, | |
int | type | |||
) |
file (un)locking functions. Establish a lock on the specified, open file. The lock may be advisory or mandatory, at the discretion of the platform. The lock applies to the file as a whole, rather than a specific range. Locks are established on a per-thread/process basis; a second lock by the same thread will not block.
thefile | The file to lock. | |
type | The type of lock to establish on the file. |
apr_status_t apr_file_mktemp | ( | apr_file_t ** | fp, | |
char * | templ, | |||
apr_int32_t | flags, | |||
apr_pool_t * | p | |||
) |
Open a temporary file
fp | The apr file to use as a temporary file. | |
templ | The template to use when creating a temp file. | |
flags | The flags to open the file with. If this is zero, the file is opened with APR_FOPEN_CREATE | APR_FOPEN_READ | APR_FOPEN_WRITE | APR_FOPEN_EXCL | APR_FOPEN_DELONCLOSE | |
p | The pool to allocate the file out of. |
apr_status_t apr_file_mtime_set | ( | const char * | fname, | |
apr_time_t | mtime, | |||
apr_pool_t * | pool | |||
) |
Set the mtime of the specified file.
fname | The full path to the file (using / on all systems) | |
mtime | The mtime to apply to the file. | |
pool | The pool to use. |
apr_status_t apr_file_name_get | ( | const char ** | new_path, | |
apr_file_t * | thefile | |||
) |
accessor and general file_io functions. return the file name of the current file.
new_path | The path of the file. | |
thefile | The currently open file. |
apr_status_t apr_file_namedpipe_create | ( | const char * | filename, | |
apr_fileperms_t | perm, | |||
apr_pool_t * | pool | |||
) |
Create a named pipe.
filename | The filename of the named pipe | |
perm | The permissions for the newly created pipe. | |
pool | The pool to operate on. |
apr_status_t apr_file_open | ( | apr_file_t ** | newf, | |
const char * | fname, | |||
apr_int32_t | flag, | |||
apr_fileperms_t | perm, | |||
apr_pool_t * | pool | |||
) |
Open the specified file.
newf | The opened file descriptor. | |
fname | The full path to the file (using / on all systems) | |
flag | Or'ed value of:
| |
perm | Access permissions for file. | |
pool | The pool to use. |
By default, the returned file descriptor will not be inherited by child processes created by apr_proc_create(). This can be changed using apr_file_inherit_set().
apr_status_t apr_file_open_flags_stderr | ( | apr_file_t ** | thefile, | |
apr_int32_t | flags, | |||
apr_pool_t * | pool | |||
) |
open standard error as an apr file pointer, with flags.
thefile | The apr file to use as stderr. | |
flags | The flags to open the file with. Only the
| |
pool | The pool to allocate the file out of. |
apr_status_t apr_file_open_flags_stdin | ( | apr_file_t ** | thefile, | |
apr_int32_t | flags, | |||
apr_pool_t * | pool | |||
) |
open standard input as an apr file pointer, with flags.
thefile | The apr file to use as stdin. | |
flags | The flags to open the file with. Only the
| |
pool | The pool to allocate the file out of. |
apr_status_t apr_file_open_flags_stdout | ( | apr_file_t ** | thefile, | |
apr_int32_t | flags, | |||
apr_pool_t * | pool | |||
) |
open standard output as an apr file pointer, with flags.
thefile | The apr file to use as stdout. | |
flags | The flags to open the file with. Only the
| |
pool | The pool to allocate the file out of. |
apr_status_t apr_file_open_stderr | ( | apr_file_t ** | thefile, | |
apr_pool_t * | pool | |||
) |
Open standard error as an apr file pointer.
thefile | The apr file to use as stderr. | |
pool | The pool to allocate the file out of. |
The other problem is that the C library functions generally work differently on Windows and Unix. So, by using apr_file_open_std* functions, you can get a handle to an APR struct that works with the APR functions which are supposed to work identically on all platforms.
apr_status_t apr_file_open_stdin | ( | apr_file_t ** | thefile, | |
apr_pool_t * | pool | |||
) |
open standard input as an apr file pointer.
thefile | The apr file to use as stdin. | |
pool | The pool to allocate the file out of. |
apr_status_t apr_file_open_stdout | ( | apr_file_t ** | thefile, | |
apr_pool_t * | pool | |||
) |
open standard output as an apr file pointer.
thefile | The apr file to use as stdout. | |
pool | The pool to allocate the file out of. |
apr_status_t apr_file_perms_set | ( | const char * | fname, | |
apr_fileperms_t | perms | |||
) |
set the specified file's permission bits.
fname | The file (name) to apply the permissions to. | |
perms | The permission bits to apply to the file. |
Platforms which do not implement this feature will return APR_ENOTIMPL.
apr_status_t apr_file_pipe_create | ( | apr_file_t ** | in, | |
apr_file_t ** | out, | |||
apr_pool_t * | pool | |||
) |
Create an anonymous pipe.
in | The newly created pipe's file for reading. | |
out | The newly created pipe's file for writing. | |
pool | The pool to operate on. |
apr_status_t apr_file_pipe_create_ex | ( | apr_file_t ** | in, | |
apr_file_t ** | out, | |||
apr_int32_t | blocking, | |||
apr_pool_t * | pool | |||
) |
Create an anonymous pipe which portably supports async timeout options.
in | The newly created pipe's file for reading. | |
out | The newly created pipe's file for writing. | |
blocking | one of these values defined in apr_thread_proc.h; | |
pool | The pool to operate on. |
Some platforms cannot toggle between blocking and nonblocking, and when passing a pipe as a standard handle to an application which does not expect it, a non-blocking stream will fluxor the client app. Use this function rather than apr_file_pipe_create() to create pipes where one or both ends require non-blocking semantics.
apr_status_t apr_file_pipe_create_pools | ( | apr_file_t ** | in, | |
apr_file_t ** | out, | |||
apr_int32_t | blocking, | |||
apr_pool_t * | pool_in, | |||
apr_pool_t * | pool_out | |||
) |
Create an anonymous pipe which portably supports async timeout options, placing each side of the pipe in a different pool.
in | The newly created pipe's file for reading. | |
out | The newly created pipe's file for writing. | |
blocking | one of these values defined in apr_thread_proc.h; | |
pool_in | The pool for the reading pipe. | |
pool_out | The pool for the writing pipe. |
Some platforms cannot toggle between blocking and nonblocking, and when passing a pipe as a standard handle to an application which does not expect it, a non-blocking stream will fluxor the client app. Use this function rather than apr_file_pipe_create() to create pipes where one or both ends require non-blocking semantics.
apr_status_t apr_file_pipe_timeout_get | ( | apr_file_t * | thepipe, | |
apr_interval_time_t * | timeout | |||
) |
Get the timeout value for a pipe or manipulate the blocking state.
thepipe | The pipe we are getting a timeout for. | |
timeout | The current timeout value in microseconds. |
apr_status_t apr_file_pipe_timeout_set | ( | apr_file_t * | thepipe, | |
apr_interval_time_t | timeout | |||
) |
Set the timeout value for a pipe or manipulate the blocking state.
thepipe | The pipe we are setting a timeout on. | |
timeout | The timeout value in microseconds. Values < 0 mean wait forever, 0 means do not wait at all. |
apr_pool_t* apr_file_pool_get | ( | const apr_file_t * | thefile | ) |
Get the pool used by the file.
int apr_file_printf | ( | apr_file_t * | fptr, | |
const char * | format, | |||
... | ||||
) |
Write a string to a file using a printf format.
fptr | The file to write to. | |
format | The format string | |
... | The values to substitute in the format string |
apr_status_t apr_file_putc | ( | char | ch, | |
apr_file_t * | thefile | |||
) |
Write a character into the specified file.
ch | The character to write. | |
thefile | The file descriptor to write to |
apr_status_t apr_file_puts | ( | const char * | str, | |
apr_file_t * | thefile | |||
) |
Write the string into the specified file.
str | The string to write. | |
thefile | The file descriptor to write to |
apr_status_t apr_file_read | ( | apr_file_t * | thefile, | |
void * | buf, | |||
apr_size_t * | nbytes | |||
) |
Read data from the specified file.
thefile | The file descriptor to read from. | |
buf | The buffer to store the data to. | |
nbytes | On entry, the number of bytes to read; on exit, the number of bytes read. |
It is not possible for both bytes to be read and an APR_EOF or other error to be returned. APR_EINTR is never returned.
apr_status_t apr_file_read_full | ( | apr_file_t * | thefile, | |
void * | buf, | |||
apr_size_t | nbytes, | |||
apr_size_t * | bytes_read | |||
) |
Read data from the specified file, ensuring that the buffer is filled before returning.
thefile | The file descriptor to read from. | |
buf | The buffer to store the data to. | |
nbytes | The number of bytes to read. | |
bytes_read | If non-NULL, this will contain the number of bytes read. |
It is possible for both bytes to be read and an error to be returned. And if *bytes_read is less than nbytes, an accompanying error is _always_ returned.
APR_EINTR is never returned.
apr_status_t apr_file_remove | ( | const char * | path, | |
apr_pool_t * | pool | |||
) |
Delete the specified file.
path | The full path to the file (using / on all systems) | |
pool | The pool to use. |
apr_status_t apr_file_rename | ( | const char * | from_path, | |
const char * | to_path, | |||
apr_pool_t * | pool | |||
) |
Rename the specified file.
from_path | The full path to the original file (using / on all systems) | |
to_path | The full path to the new file (using / on all systems) | |
pool | The pool to use. |
apr_status_t apr_file_seek | ( | apr_file_t * | thefile, | |
apr_seek_where_t | where, | |||
apr_off_t * | offset | |||
) |
Move the read/write file offset to a specified byte within a file.
thefile | The file descriptor | |
where | How to move the pointer, one of: | |
offset | The offset to move the pointer to. |
apr_status_t apr_file_setaside | ( | apr_file_t ** | new_file, | |
apr_file_t * | old_file, | |||
apr_pool_t * | p | |||
) |
Move the specified file descriptor to a new pool
new_file | Pointer in which to return the new apr_file_t | |
old_file | The file to move | |
p | The pool to which the descriptor is to be moved |
The new pool need not be an ancestor of old_file's pool.
After calling this function, old_file may not be used
apr_status_t apr_file_sync | ( | apr_file_t * | thefile | ) |
Transfer all file modified data and metadata to disk.
thefile | The file descriptor to sync |
apr_status_t apr_file_trunc | ( | apr_file_t * | fp, | |
apr_off_t | offset | |||
) |
Truncate the file's length to the specified offset
fp | The file to truncate | |
offset | The offset to truncate to. |
apr_status_t apr_file_ungetc | ( | char | ch, | |
apr_file_t * | thefile | |||
) |
Put a character back onto a specified stream.
ch | The character to write. | |
thefile | The file descriptor to write to |
apr_status_t apr_file_unlock | ( | apr_file_t * | thefile | ) |
Remove any outstanding locks on the file.
thefile | The file to unlock. |
apr_status_t apr_file_write | ( | apr_file_t * | thefile, | |
const void * | buf, | |||
apr_size_t * | nbytes | |||
) |
Write data to the specified file.
thefile | The file descriptor to write to. | |
buf | The buffer which contains the data. | |
nbytes | On entry, the number of bytes to write; on exit, the number of bytes written. |
It is possible for both bytes to be written and an error to be returned. APR_EINTR is never returned.
apr_status_t apr_file_write_full | ( | apr_file_t * | thefile, | |
const void * | buf, | |||
apr_size_t | nbytes, | |||
apr_size_t * | bytes_written | |||
) |
Write data to the specified file, ensuring that all of the data is written before returning.
thefile | The file descriptor to write to. | |
buf | The buffer which contains the data. | |
nbytes | The number of bytes to write. | |
bytes_written | If non-NULL, set to the number of bytes written. |
It is possible for both bytes to be written and an error to be returned. And if *bytes_written is less than nbytes, an accompanying error is _always_ returned.
APR_EINTR is never returned.
apr_status_t apr_file_writev | ( | apr_file_t * | thefile, | |
const struct iovec * | vec, | |||
apr_size_t | nvec, | |||
apr_size_t * | nbytes | |||
) |
Write data from iovec array to the specified file.
thefile | The file descriptor to write to. | |
vec | The array from which to get the data to write to the file. | |
nvec | The number of elements in the struct iovec array. This must be smaller than APR_MAX_IOVEC_SIZE. If it isn't, the function will fail with APR_EINVAL. | |
nbytes | The number of bytes written. |
apr_file_writev() is available even if the underlying operating system doesn't provide writev().
apr_status_t apr_file_writev_full | ( | apr_file_t * | thefile, | |
const struct iovec * | vec, | |||
apr_size_t | nvec, | |||
apr_size_t * | nbytes | |||
) |
Write data from iovec array to the specified file, ensuring that all of the data is written before returning.
thefile | The file descriptor to write to. | |
vec | The array from which to get the data to write to the file. | |
nvec | The number of elements in the struct iovec array. This must be smaller than APR_MAX_IOVEC_SIZE. If it isn't, the function will fail with APR_EINVAL. | |
nbytes | The number of bytes written. |
apr_status_t apr_temp_dir_get | ( | const char ** | temp_dir, | |
apr_pool_t * | p | |||
) |
Find an existing directory suitable as a temporary storage location.
temp_dir | The temp directory. | |
p | The pool to use for any necessary allocations. |