<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1"> <title>Apache Portable Runtime: apr_file_io.h Source File</title> <link href="doxygen.css" rel="stylesheet" type="text/css"> </head><body> <!-- Generated by Doxygen 1.3.9.1 --> <div class="qindex"><a class="qindex" href="index.html">Main Page</a> | <a class="qindex" href="modules.html">Modules</a> | <a class="qindex" href="annotated.html">Data Structures</a> | <a class="qindex" href="files.html">File List</a> | <a class="qindex" href="functions.html">Data Fields</a> | <a class="qindex" href="globals.html">Globals</a> | <a class="qindex" href="pages.html">Related Pages</a></div> <div class="nav"> <a class="el" href="dir_000000.html">home</a> / <a class="el" href="dir_000001.html">oden</a> / <a class="el" href="dir_000002.html">RPM</a> / <a class="el" href="dir_000003.html">BUILD</a> / <a class="el" href="dir_000004.html">apr-1.1.1</a> / <a class="el" href="dir_000005.html">include</a></div> <h1>apr_file_io.h</h1><a href="apr__file__io_8h.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment">00001 <span class="comment">/* Copyright 2000-2004 The Apache Software Foundation</span> 00002 <span class="comment"> *</span> 00003 <span class="comment"> * Licensed under the Apache License, Version 2.0 (the "License");</span> 00004 <span class="comment"> * you may not use this file except in compliance with the License.</span> 00005 <span class="comment"> * You may obtain a copy of the License at</span> 00006 <span class="comment"> *</span> 00007 <span class="comment"> * http://www.apache.org/licenses/LICENSE-2.0</span> 00008 <span class="comment"> *</span> 00009 <span class="comment"> * Unless required by applicable law or agreed to in writing, software</span> 00010 <span class="comment"> * distributed under the License is distributed on an "AS IS" BASIS,</span> 00011 <span class="comment"> * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.</span> 00012 <span class="comment"> * See the License for the specific language governing permissions and</span> 00013 <span class="comment"> * limitations under the License.</span> 00014 <span class="comment"> */</span> 00015 00016 <span class="preprocessor">#ifndef APR_FILE_IO_H</span> 00017 <span class="preprocessor"></span><span class="preprocessor">#define APR_FILE_IO_H</span> 00018 <span class="preprocessor"></span><span class="comment"></span> 00019 <span class="comment">/**</span> 00020 <span class="comment"> * @file apr_file_io.h</span> 00021 <span class="comment"> * @brief APR File I/O Handling</span> 00022 <span class="comment"> */</span> 00023 00024 <span class="preprocessor">#include "<a class="code" href="apr_8h.html">apr.h</a>"</span> 00025 <span class="preprocessor">#include "<a class="code" href="apr__pools_8h.html">apr_pools.h</a>"</span> 00026 <span class="preprocessor">#include "<a class="code" href="apr__time_8h.html">apr_time.h</a>"</span> 00027 <span class="preprocessor">#include "<a class="code" href="apr__errno_8h.html">apr_errno.h</a>"</span> 00028 <span class="preprocessor">#include "<a class="code" href="apr__file__info_8h.html">apr_file_info.h</a>"</span> 00029 <span class="preprocessor">#include "<a class="code" href="apr__inherit_8h.html">apr_inherit.h</a>"</span> 00030 <a name="l00031"></a><a class="code" href="apr__file__io_8h.html#a0">00031</a> <span class="preprocessor">#define APR_WANT_STDIO </span><span class="comment">/**< for SEEK_* */</span> <a name="l00032"></a><a class="code" href="apr__file__io_8h.html#a1">00032</a> <span class="preprocessor">#define APR_WANT_IOVEC </span><span class="comment">/**< for apr_file_writev */</span> 00033 <span class="preprocessor">#include "<a class="code" href="apr__want_8h.html">apr_want.h</a>"</span> 00034 00035 <span class="preprocessor">#ifdef __cplusplus</span> 00036 <span class="preprocessor"></span><span class="keyword">extern</span> <span class="stringliteral">"C"</span> { 00037 <span class="preprocessor">#endif </span><span class="comment">/* __cplusplus */</span> 00038 <span class="comment"></span> 00039 <span class="comment">/**</span> 00040 <span class="comment"> * @defgroup apr_file_io File I/O Handling Functions</span> 00041 <span class="comment"> * @ingroup APR </span> 00042 <span class="comment"> * @{</span> 00043 <span class="comment"> */</span> 00044 <span class="comment"></span> 00045 <span class="comment">/**</span> 00046 <span class="comment"> * @defgroup apr_file_open_flags File Open Flags/Routines</span> 00047 <span class="comment"> * @{</span> 00048 <span class="comment"> */</span> 00049 00050 <span class="comment">/* Note to implementors: Values in the range 0x00100000--0x80000000</span> 00051 <span class="comment"> are reserved for platform-specific values. */</span> 00052 <a name="l00053"></a><a class="code" href="group__apr__file__open__flags.html#ga0">00053</a> <span class="preprocessor">#define APR_FOPEN_READ 0x00001 </span><span class="comment">/**< Open the file for reading */</span> <a name="l00054"></a><a class="code" href="group__apr__file__open__flags.html#ga1">00054</a> <span class="preprocessor">#define APR_FOPEN_WRITE 0x00002 </span><span class="comment">/**< Open the file for writing */</span> <a name="l00055"></a><a class="code" href="group__apr__file__open__flags.html#ga2">00055</a> <span class="preprocessor">#define APR_FOPEN_CREATE 0x00004 </span><span class="comment">/**< Create the file if not there */</span> <a name="l00056"></a><a class="code" href="group__apr__file__open__flags.html#ga3">00056</a> <span class="preprocessor">#define APR_FOPEN_APPEND 0x00008 </span><span class="comment">/**< Append to the end of the file */</span> <a name="l00057"></a><a class="code" href="group__apr__file__open__flags.html#ga4">00057</a> <span class="preprocessor">#define APR_FOPEN_TRUNCATE 0x00010 </span><span class="comment">/**< Open the file and truncate</span> 00058 <span class="comment"> to 0 length */</span> <a name="l00059"></a><a class="code" href="group__apr__file__open__flags.html#ga5">00059</a> <span class="preprocessor">#define APR_FOPEN_BINARY 0x00020 </span><span class="comment">/**< Open the file in binary mode */</span> <a name="l00060"></a><a class="code" href="group__apr__file__open__flags.html#ga6">00060</a> <span class="preprocessor">#define APR_FOPEN_EXCL 0x00040 </span><span class="comment">/**< Open should fail if APR_CREATE</span> 00061 <span class="comment"> and file exists. */</span> <a name="l00062"></a><a class="code" href="group__apr__file__open__flags.html#ga7">00062</a> <span class="preprocessor">#define APR_FOPEN_BUFFERED 0x00080 </span><span class="comment">/**< Open the file for buffered I/O */</span> <a name="l00063"></a><a class="code" href="group__apr__file__open__flags.html#ga8">00063</a> <span class="preprocessor">#define APR_FOPEN_DELONCLOSE 0x00100 </span><span class="comment">/**< Delete the file after close */</span> <a name="l00064"></a><a class="code" href="group__apr__file__open__flags.html#ga9">00064</a> <span class="preprocessor">#define APR_FOPEN_XTHREAD 0x00200 </span><span class="comment">/**< Platform dependent tag to open</span> 00065 <span class="comment"> the file for use across multiple</span> 00066 <span class="comment"> threads */</span> <a name="l00067"></a><a class="code" href="group__apr__file__open__flags.html#ga10">00067</a> <span class="preprocessor">#define APR_FOPEN_SHARELOCK 0x00400 </span><span class="comment">/**< Platform dependent support for</span> 00068 <span class="comment"> higher level locked read/write</span> 00069 <span class="comment"> access to support writes across</span> 00070 <span class="comment"> process/machines */</span> <a name="l00071"></a><a class="code" href="group__apr__file__open__flags.html#ga11">00071</a> <span class="preprocessor">#define APR_FOPEN_NOCLEANUP 0x00800 </span><span class="comment">/**< Do not register a cleanup</span> 00072 <span class="comment"> when the file is opened */</span> <a name="l00073"></a><a class="code" href="group__apr__file__open__flags.html#ga12">00073</a> <span class="preprocessor">#define APR_FOPEN_SENDFILE_ENABLED 0x01000 </span><span class="comment">/**< Advisory flag that this</span> 00074 <span class="comment"> file should support</span> 00075 <span class="comment"> apr_socket_sendfile operation */</span> <a name="l00076"></a><a class="code" href="group__apr__file__open__flags.html#ga13">00076</a> <span class="preprocessor">#define APR_FOPEN_LARGEFILE 0x04000 </span><span class="comment">/**< Platform dependent flag to enable</span> 00077 <span class="comment"> large file support; WARNING see</span> 00078 <span class="comment"> below. */</span> 00079 <span class="comment">/* backcompat */</span> <a name="l00080"></a><a class="code" href="group__apr__file__open__flags.html#ga14">00080</a> <span class="preprocessor">#define APR_READ APR_FOPEN_READ </span><span class="comment">/**< @deprecated @see APR_FOPEN_READ */</span> <a name="l00081"></a><a class="code" href="group__apr__file__open__flags.html#ga15">00081</a> <span class="preprocessor">#define APR_WRITE APR_FOPEN_WRITE </span><span class="comment">/**< @deprecated @see APR_FOPEN_WRITE */</span> <a name="l00082"></a><a class="code" href="group__apr__file__open__flags.html#ga16">00082</a> <span class="preprocessor">#define APR_CREATE APR_FOPEN_CREATE </span><span class="comment">/**< @deprecated @see APR_FOPEN_CREATE */</span> <a name="l00083"></a><a class="code" href="group__apr__file__open__flags.html#ga17">00083</a> <span class="preprocessor">#define APR_APPEND APR_FOPEN_APPEND </span><span class="comment">/**< @deprecated @see APR_FOPEN_APPEND */</span> <a name="l00084"></a><a class="code" href="group__apr__file__open__flags.html#ga18">00084</a> <span class="preprocessor">#define APR_TRUNCATE APR_FOPEN_TRUNCATE </span><span class="comment">/**< @deprecated @see APR_FOPEN_TRUNCATE */</span> <a name="l00085"></a><a class="code" href="group__apr__file__open__flags.html#ga19">00085</a> <span class="preprocessor">#define APR_BINARY APR_FOPEN_BINARY </span><span class="comment">/**< @deprecated @see APR_FOPEN_BINARY */</span> <a name="l00086"></a><a class="code" href="group__apr__file__open__flags.html#ga20">00086</a> <span class="preprocessor">#define APR_EXCL APR_FOPEN_EXCL </span><span class="comment">/**< @deprecated @see APR_FOPEN_EXCL */</span> <a name="l00087"></a><a class="code" href="group__apr__file__open__flags.html#ga21">00087</a> <span class="preprocessor">#define APR_BUFFERED APR_FOPEN_BUFFERED </span><span class="comment">/**< @deprecated @see APR_FOPEN_BUFFERED */</span> <a name="l00088"></a><a class="code" href="group__apr__file__open__flags.html#ga22">00088</a> <span class="preprocessor">#define APR_DELONCLOSE APR_FOPEN_DELONCLOSE </span><span class="comment">/**< @deprecated @see APR_FOPEN_DELONCLOSE */</span> <a name="l00089"></a><a class="code" href="group__apr__file__open__flags.html#ga23">00089</a> <span class="preprocessor">#define APR_XTHREAD APR_FOPEN_XTHREAD </span><span class="comment">/**< @deprecated @see APR_FOPEN_XTHREAD */</span> <a name="l00090"></a><a class="code" href="group__apr__file__open__flags.html#ga24">00090</a> <span class="preprocessor">#define APR_SHARELOCK APR_FOPEN_SHARELOCK </span><span class="comment">/**< @deprecated @see APR_FOPEN_SHARELOCK */</span> <a name="l00091"></a><a class="code" href="group__apr__file__open__flags.html#ga25">00091</a> <span class="preprocessor">#define APR_FILE_NOCLEANUP APR_FOPEN_NOCLEANUP </span><span class="comment">/**< @deprecated @see APR_FOPEN_NOCLEANUP */</span> <a name="l00092"></a><a class="code" href="group__apr__file__open__flags.html#ga26">00092</a> <span class="preprocessor">#define APR_SENDFILE_ENABLED APR_FOPEN_SENDFILE_ENABLED </span><span class="comment">/**< @deprecated @see APR_FOPEN_SENDFILE_ENABLED */</span> <a name="l00093"></a><a class="code" href="group__apr__file__open__flags.html#ga27">00093</a> <span class="preprocessor">#define APR_LARGEFILE APR_FOPEN_LARGEFILE </span><span class="comment">/**< @deprecated @see APR_FOPEN_LARGEFILE */</span> 00094 <span class="comment"></span> 00095 <span class="comment">/** @warning The APR_LARGEFILE flag only has effect on some platforms</span> 00096 <span class="comment"> * where sizeof(apr_off_t) == 4. Where implemented, it allows opening</span> 00097 <span class="comment"> * and writing to a file which exceeds the size which can be</span> 00098 <span class="comment"> * represented by apr_off_t (2 gigabytes). When a file's size does</span> 00099 <span class="comment"> * exceed 2Gb, apr_file_info_get() will fail with an error on the</span> 00100 <span class="comment"> * descriptor, likewise apr_stat()/apr_lstat() will fail on the</span> 00101 <span class="comment"> * filename. apr_dir_read() will fail with APR_INCOMPLETE on a</span> 00102 <span class="comment"> * directory entry for a large file depending on the particular</span> 00103 <span class="comment"> * APR_FINFO_* flags. Generally, it is not recommended to use this</span> 00104 <span class="comment"> * flag. */</span> 00105 <span class="comment"></span> 00106 <span class="comment">/** @} */</span> 00107 <span class="comment"></span> 00108 <span class="comment">/**</span> 00109 <span class="comment"> * @defgroup apr_file_seek_flags File Seek Flags</span> 00110 <span class="comment"> * @{</span> 00111 <span class="comment"> */</span> 00112 00113 <span class="comment">/* flags for apr_file_seek */</span><span class="comment"></span> 00114 <span class="comment">/** Set the file position */</span> <a name="l00115"></a><a class="code" href="group__apr__file__seek__flags.html#ga0">00115</a> <span class="preprocessor">#define APR_SET SEEK_SET</span> 00116 <span class="preprocessor"></span><span class="comment">/** Current */</span> <a name="l00117"></a><a class="code" href="group__apr__file__seek__flags.html#ga1">00117</a> <span class="preprocessor">#define APR_CUR SEEK_CUR</span> 00118 <span class="preprocessor"></span><span class="comment">/** Go to end of file */</span> <a name="l00119"></a><a class="code" href="group__apr__file__seek__flags.html#ga2">00119</a> <span class="preprocessor">#define APR_END SEEK_END</span> 00120 <span class="preprocessor"></span><span class="comment">/** @} */</span> 00121 <span class="comment"></span> 00122 <span class="comment">/**</span> 00123 <span class="comment"> * @defgroup apr_file_attrs_set_flags File Attribute Flags</span> 00124 <span class="comment"> * @{</span> 00125 <span class="comment"> */</span> 00126 00127 <span class="comment">/* flags for apr_file_attrs_set */</span> <a name="l00128"></a><a class="code" href="group__apr__file__attrs__set__flags.html#ga0">00128</a> <span class="preprocessor">#define APR_FILE_ATTR_READONLY 0x01 </span><span class="comment">/**< File is read-only */</span> <a name="l00129"></a><a class="code" href="group__apr__file__attrs__set__flags.html#ga1">00129</a> <span class="preprocessor">#define APR_FILE_ATTR_EXECUTABLE 0x02 </span><span class="comment">/**< File is executable */</span> <a name="l00130"></a><a class="code" href="group__apr__file__attrs__set__flags.html#ga2">00130</a> <span class="preprocessor">#define APR_FILE_ATTR_HIDDEN 0x04 </span><span class="comment">/**< File is hidden */</span> 00131 <span class="comment">/** @} */</span> 00132 <span class="comment"></span> 00133 <span class="comment">/**</span> 00134 <span class="comment"> * @defgroup apr_file_writev{_full} max iovec size</span> 00135 <span class="comment"> * @{</span> 00136 <span class="comment"> */</span> 00137 <span class="preprocessor">#if defined(DOXYGEN)</span> <a name="l00138"></a><a class="code" href="group__apr__file__writev.html#ga0">00138</a> <span class="preprocessor"></span><span class="preprocessor">#define APR_MAX_IOVEC_SIZE 1024 </span><span class="comment">/**< System dependent maximum </span> 00139 <span class="comment"> size of an iovec array */</span> 00140 <span class="preprocessor">#elif defined(IOV_MAX)</span> 00141 <span class="preprocessor"></span><span class="preprocessor">#define APR_MAX_IOVEC_SIZE IOV_MAX</span> 00142 <span class="preprocessor"></span><span class="preprocessor">#elif defined(MAX_IOVEC)</span> 00143 <span class="preprocessor"></span><span class="preprocessor">#define APR_MAX_IOVEC_SIZE MAX_IOVEC</span> 00144 <span class="preprocessor"></span><span class="preprocessor">#else</span> 00145 <span class="preprocessor"></span><span class="preprocessor">#define APR_MAX_IOVEC_SIZE 1024</span> 00146 <span class="preprocessor"></span><span class="preprocessor">#endif</span> 00147 <span class="preprocessor"></span><span class="comment">/** @} */</span> 00148 <span class="comment"></span> 00149 <span class="comment">/** File attributes */</span> <a name="l00150"></a><a class="code" href="group__apr__file__io.html#ga0">00150</a> <span class="keyword">typedef</span> apr_uint32_t apr_fileattrs_t; 00151 <span class="comment"></span> 00152 <span class="comment">/** Type to pass as whence argument to apr_file_seek. */</span> <a name="l00153"></a><a class="code" href="group__apr__file__io.html#ga1">00153</a> <span class="keyword">typedef</span> <span class="keywordtype">int</span> apr_seek_where_t; 00154 <span class="comment"></span> 00155 <span class="comment">/**</span> 00156 <span class="comment"> * Structure for referencing files.</span> 00157 <span class="comment"> */</span> <a name="l00158"></a><a class="code" href="group__apr__file__io.html#ga2">00158</a> <span class="keyword">typedef</span> <span class="keyword">struct </span><a class="code" href="group__apr__file__io.html#ga2">apr_file_t</a> <a class="code" href="group__apr__file__io.html#ga2">apr_file_t</a>; 00159 00160 <span class="comment">/* File lock types/flags */</span><span class="comment"></span> 00161 <span class="comment">/**</span> 00162 <span class="comment"> * @defgroup apr_file_lock_types File Lock Types</span> 00163 <span class="comment"> * @{</span> 00164 <span class="comment"> */</span> 00165 <a name="l00166"></a><a class="code" href="group__apr__file__lock__types.html#ga0">00166</a> <span class="preprocessor">#define APR_FLOCK_SHARED 1 </span><span class="comment">/**< Shared lock. More than one process</span> 00167 <span class="comment"> or thread can hold a shared lock</span> 00168 <span class="comment"> at any given time. Essentially,</span> 00169 <span class="comment"> this is a "read lock", preventing</span> 00170 <span class="comment"> writers from establishing an</span> 00171 <span class="comment"> exclusive lock. */</span> <a name="l00172"></a><a class="code" href="group__apr__file__lock__types.html#ga1">00172</a> <span class="preprocessor">#define APR_FLOCK_EXCLUSIVE 2 </span><span class="comment">/**< Exclusive lock. Only one process</span> 00173 <span class="comment"> may hold an exclusive lock at any</span> 00174 <span class="comment"> given time. This is analogous to</span> 00175 <span class="comment"> a "write lock". */</span> 00176 <a name="l00177"></a><a class="code" href="group__apr__file__lock__types.html#ga2">00177</a> <span class="preprocessor">#define APR_FLOCK_TYPEMASK 0x000F </span><span class="comment">/**< mask to extract lock type */</span> <a name="l00178"></a><a class="code" href="group__apr__file__lock__types.html#ga3">00178</a> <span class="preprocessor">#define APR_FLOCK_NONBLOCK 0x0010 </span><span class="comment">/**< do not block while acquiring the</span> 00179 <span class="comment"> file lock */</span> 00180 <span class="comment">/** @} */</span> 00181 <span class="comment"></span> 00182 <span class="comment">/**</span> 00183 <span class="comment"> * Open the specified file.</span> 00184 <span class="comment"> * @param newf The opened file descriptor.</span> 00185 <span class="comment"> * @param fname The full path to the file (using / on all systems)</span> 00186 <span class="comment"> * @param flag Or'ed value of:</span> 00187 <span class="comment"> * <PRE></span> 00188 <span class="comment"> * APR_READ open for reading</span> 00189 <span class="comment"> * APR_WRITE open for writing</span> 00190 <span class="comment"> * APR_CREATE create the file if not there</span> 00191 <span class="comment"> * APR_APPEND file ptr is set to end prior to all writes</span> 00192 <span class="comment"> * APR_TRUNCATE set length to zero if file exists</span> 00193 <span class="comment"> * APR_BINARY not a text file (This flag is ignored on </span> 00194 <span class="comment"> * UNIX because it has no meaning)</span> 00195 <span class="comment"> * APR_BUFFERED buffer the data. Default is non-buffered</span> 00196 <span class="comment"> * APR_EXCL return error if APR_CREATE and file exists</span> 00197 <span class="comment"> * APR_DELONCLOSE delete the file after closing.</span> 00198 <span class="comment"> * APR_XTHREAD Platform dependent tag to open the file</span> 00199 <span class="comment"> * for use across multiple threads</span> 00200 <span class="comment"> * APR_SHARELOCK Platform dependent support for higher</span> 00201 <span class="comment"> * level locked read/write access to support</span> 00202 <span class="comment"> * writes across process/machines</span> 00203 <span class="comment"> * APR_FILE_NOCLEANUP Do not register a cleanup with the pool </span> 00204 <span class="comment"> * passed in on the <EM>pool</EM> argument (see below).</span> 00205 <span class="comment"> * The apr_os_file_t handle in apr_file_t will not</span> 00206 <span class="comment"> * be closed when the pool is destroyed.</span> 00207 <span class="comment"> * APR_SENDFILE_ENABLED Open with appropriate platform semantics</span> 00208 <span class="comment"> * for sendfile operations. Advisory only,</span> 00209 <span class="comment"> * apr_socket_sendfile does not check this flag.</span> 00210 <span class="comment"> * </PRE></span> 00211 <span class="comment"> * @param perm Access permissions for file.</span> 00212 <span class="comment"> * @param pool The pool to use.</span> 00213 <span class="comment"> * @remark If perm is APR_OS_DEFAULT and the file is being created,</span> 00214 <span class="comment"> * appropriate default permissions will be used.</span> 00215 <span class="comment"> */</span> 00216 <a class="code" href="group__apr__platform.html#ga123">APR_DECLARE</a>(apr_status_t) apr_file_open(apr_file_t **newf, const <span class="keywordtype">char</span> *fname, 00217 apr_int32_t flag, apr_fileperms_t perm, 00218 apr_pool_t *pool); 00219 <span class="comment"></span> 00220 <span class="comment">/**</span> 00221 <span class="comment"> * Close the specified file.</span> 00222 <span class="comment"> * @param file The file descriptor to close.</span> 00223 <span class="comment"> */</span> 00224 APR_DECLARE(apr_status_t) apr_file_close(apr_file_t *file); 00225 <span class="comment"></span> 00226 <span class="comment">/**</span> 00227 <span class="comment"> * Delete the specified file.</span> 00228 <span class="comment"> * @param path The full path to the file (using / on all systems)</span> 00229 <span class="comment"> * @param pool The pool to use.</span> 00230 <span class="comment"> * @remark If the file is open, it won't be removed until all</span> 00231 <span class="comment"> * instances are closed.</span> 00232 <span class="comment"> */</span> 00233 APR_DECLARE(apr_status_t) apr_file_remove(const <span class="keywordtype">char</span> *path, apr_pool_t *pool); 00234 <span class="comment"></span> 00235 <span class="comment">/**</span> 00236 <span class="comment"> * Rename the specified file.</span> 00237 <span class="comment"> * @param from_path The full path to the original file (using / on all systems)</span> 00238 <span class="comment"> * @param to_path The full path to the new file (using / on all systems)</span> 00239 <span class="comment"> * @param pool The pool to use.</span> 00240 <span class="comment"> * @warning If a file exists at the new location, then it will be</span> 00241 <span class="comment"> * overwritten. Moving files or directories across devices may not be</span> 00242 <span class="comment"> * possible.</span> 00243 <span class="comment"> */</span> 00244 APR_DECLARE(apr_status_t) apr_file_rename(const <span class="keywordtype">char</span> *from_path, 00245 const <span class="keywordtype">char</span> *to_path, 00246 apr_pool_t *pool); 00247 <span class="comment"></span> 00248 <span class="comment">/**</span> 00249 <span class="comment"> * Copy the specified file to another file.</span> 00250 <span class="comment"> * @param from_path The full path to the original file (using / on all systems)</span> 00251 <span class="comment"> * @param to_path The full path to the new file (using / on all systems)</span> 00252 <span class="comment"> * @param perms Access permissions for the new file if it is created.</span> 00253 <span class="comment"> * In place of the usual or'd combination of file permissions, the</span> 00254 <span class="comment"> * value APR_FILE_SOURCE_PERMS may be given, in which case the source</span> 00255 <span class="comment"> * file's permissions are copied.</span> 00256 <span class="comment"> * @param pool The pool to use.</span> 00257 <span class="comment"> * @remark The new file does not need to exist, it will be created if required.</span> 00258 <span class="comment"> * @warning If the new file already exists, its contents will be overwritten.</span> 00259 <span class="comment"> */</span> 00260 APR_DECLARE(apr_status_t) apr_file_copy(const <span class="keywordtype">char</span> *from_path, 00261 const <span class="keywordtype">char</span> *to_path, 00262 apr_fileperms_t perms, 00263 apr_pool_t *pool); 00264 <span class="comment"></span> 00265 <span class="comment">/**</span> 00266 <span class="comment"> * Append the specified file to another file.</span> 00267 <span class="comment"> * @param from_path The full path to the source file (use / on all systems)</span> 00268 <span class="comment"> * @param to_path The full path to the destination file (use / on all systems)</span> 00269 <span class="comment"> * @param perms Access permissions for the destination file if it is created.</span> 00270 <span class="comment"> * In place of the usual or'd combination of file permissions, the</span> 00271 <span class="comment"> * value APR_FILE_SOURCE_PERMS may be given, in which case the source</span> 00272 <span class="comment"> * file's permissions are copied.</span> 00273 <span class="comment"> * @param pool The pool to use.</span> 00274 <span class="comment"> * @remark The new file does not need to exist, it will be created if required.</span> 00275 <span class="comment"> */</span> 00276 APR_DECLARE(apr_status_t) apr_file_append(const <span class="keywordtype">char</span> *from_path, 00277 const <span class="keywordtype">char</span> *to_path, 00278 apr_fileperms_t perms, 00279 apr_pool_t *pool); 00280 <span class="comment"></span> 00281 <span class="comment">/**</span> 00282 <span class="comment"> * Are we at the end of the file</span> 00283 <span class="comment"> * @param fptr The apr file we are testing.</span> 00284 <span class="comment"> * @remark Returns APR_EOF if we are at the end of file, APR_SUCCESS otherwise.</span> 00285 <span class="comment"> */</span> 00286 APR_DECLARE(apr_status_t) apr_file_eof(apr_file_t *fptr); 00287 <span class="comment"></span> 00288 <span class="comment">/**</span> 00289 <span class="comment"> * Open standard error as an apr file pointer.</span> 00290 <span class="comment"> * @param thefile The apr file to use as stderr.</span> 00291 <span class="comment"> * @param pool The pool to allocate the file out of.</span> 00292 <span class="comment"> * </span> 00293 <span class="comment"> * @remark The only reason that the apr_file_open_std* functions exist</span> 00294 <span class="comment"> * is that you may not always have a stderr/out/in on Windows. This</span> 00295 <span class="comment"> * is generally a problem with newer versions of Windows and services.</span> 00296 <span class="comment"> * </span> 00297 <span class="comment"> * @remark The other problem is that the C library functions generally work</span> 00298 <span class="comment"> * differently on Windows and Unix. So, by using apr_file_open_std*</span> 00299 <span class="comment"> * functions, you can get a handle to an APR struct that works with</span> 00300 <span class="comment"> * the APR functions which are supposed to work identically on all</span> 00301 <span class="comment"> * platforms.</span> 00302 <span class="comment"> */</span> 00303 APR_DECLARE(apr_status_t) apr_file_open_stderr(apr_file_t **thefile, 00304 apr_pool_t *pool); 00305 <span class="comment"></span> 00306 <span class="comment">/**</span> 00307 <span class="comment"> * open standard output as an apr file pointer.</span> 00308 <span class="comment"> * @param thefile The apr file to use as stdout.</span> 00309 <span class="comment"> * @param pool The pool to allocate the file out of.</span> 00310 <span class="comment"> * </span> 00311 <span class="comment"> * @remark See remarks for apr_file_open_stdout.</span> 00312 <span class="comment"> */</span> 00313 APR_DECLARE(apr_status_t) apr_file_open_stdout(apr_file_t **thefile, 00314 apr_pool_t *pool); 00315 <span class="comment"></span> 00316 <span class="comment">/**</span> 00317 <span class="comment"> * open standard input as an apr file pointer.</span> 00318 <span class="comment"> * @param thefile The apr file to use as stdin.</span> 00319 <span class="comment"> * @param pool The pool to allocate the file out of.</span> 00320 <span class="comment"> * </span> 00321 <span class="comment"> * @remark See remarks for apr_file_open_stdout.</span> 00322 <span class="comment"> */</span> 00323 APR_DECLARE(apr_status_t) apr_file_open_stdin(apr_file_t **thefile, 00324 apr_pool_t *pool); 00325 <span class="comment"></span> 00326 <span class="comment">/**</span> 00327 <span class="comment"> * Read data from the specified file.</span> 00328 <span class="comment"> * @param thefile The file descriptor to read from.</span> 00329 <span class="comment"> * @param buf The buffer to store the data to.</span> 00330 <span class="comment"> * @param nbytes On entry, the number of bytes to read; on exit, the number</span> 00331 <span class="comment"> * of bytes read.</span> 00332 <span class="comment"> *</span> 00333 <span class="comment"> * @remark apr_file_read will read up to the specified number of</span> 00334 <span class="comment"> * bytes, but never more. If there isn't enough data to fill that</span> 00335 <span class="comment"> * number of bytes, all of the available data is read. The third</span> 00336 <span class="comment"> * argument is modified to reflect the number of bytes read. If a</span> 00337 <span class="comment"> * char was put back into the stream via ungetc, it will be the first</span> 00338 <span class="comment"> * character returned.</span> 00339 <span class="comment"> *</span> 00340 <span class="comment"> * @remark It is not possible for both bytes to be read and an APR_EOF</span> 00341 <span class="comment"> * or other error to be returned. APR_EINTR is never returned.</span> 00342 <span class="comment"> */</span> 00343 APR_DECLARE(apr_status_t) apr_file_read(apr_file_t *thefile, <span class="keywordtype">void</span> *buf, 00344 apr_size_t *nbytes); 00345 <span class="comment"></span> 00346 <span class="comment">/**</span> 00347 <span class="comment"> * Write data to the specified file.</span> 00348 <span class="comment"> * @param thefile The file descriptor to write to.</span> 00349 <span class="comment"> * @param buf The buffer which contains the data.</span> 00350 <span class="comment"> * @param nbytes On entry, the number of bytes to write; on exit, the number </span> 00351 <span class="comment"> * of bytes written.</span> 00352 <span class="comment"> *</span> 00353 <span class="comment"> * @remark apr_file_write will write up to the specified number of</span> 00354 <span class="comment"> * bytes, but never more. If the OS cannot write that many bytes, it</span> 00355 <span class="comment"> * will write as many as it can. The third argument is modified to</span> 00356 <span class="comment"> * reflect the * number of bytes written.</span> 00357 <span class="comment"> *</span> 00358 <span class="comment"> * @remark It is possible for both bytes to be written and an error to</span> 00359 <span class="comment"> * be returned. APR_EINTR is never returned.</span> 00360 <span class="comment"> */</span> 00361 APR_DECLARE(apr_status_t) apr_file_write(apr_file_t *thefile, const <span class="keywordtype">void</span> *buf, 00362 apr_size_t *nbytes); 00363 <span class="comment"></span> 00364 <span class="comment">/**</span> 00365 <span class="comment"> * Write data from iovec array to the specified file.</span> 00366 <span class="comment"> * @param thefile The file descriptor to write to.</span> 00367 <span class="comment"> * @param vec The array from which to get the data to write to the file.</span> 00368 <span class="comment"> * @param nvec The number of elements in the struct iovec array. This must </span> 00369 <span class="comment"> * be smaller than APR_MAX_IOVEC_SIZE. If it isn't, the function </span> 00370 <span class="comment"> * will fail with APR_EINVAL.</span> 00371 <span class="comment"> * @param nbytes The number of bytes written.</span> 00372 <span class="comment"> *</span> 00373 <span class="comment"> * @remark It is possible for both bytes to be written and an error to</span> 00374 <span class="comment"> * be returned. APR_EINTR is never returned.</span> 00375 <span class="comment"> *</span> 00376 <span class="comment"> * @remark apr_file_writev is available even if the underlying</span> 00377 <span class="comment"> * operating system doesn't provide writev().</span> 00378 <span class="comment"> */</span> 00379 APR_DECLARE(apr_status_t) apr_file_writev(apr_file_t *thefile, 00380 const struct iovec *vec, 00381 apr_size_t nvec, apr_size_t *nbytes); 00382 <span class="comment"></span> 00383 <span class="comment">/**</span> 00384 <span class="comment"> * Read data from the specified file, ensuring that the buffer is filled</span> 00385 <span class="comment"> * before returning.</span> 00386 <span class="comment"> * @param thefile The file descriptor to read from.</span> 00387 <span class="comment"> * @param buf The buffer to store the data to.</span> 00388 <span class="comment"> * @param nbytes The number of bytes to read.</span> 00389 <span class="comment"> * @param bytes_read If non-NULL, this will contain the number of bytes read.</span> 00390 <span class="comment"> *</span> 00391 <span class="comment"> * @remark apr_file_read will read up to the specified number of</span> 00392 <span class="comment"> * bytes, but never more. If there isn't enough data to fill that</span> 00393 <span class="comment"> * number of bytes, then the process/thread will block until it is</span> 00394 <span class="comment"> * available or EOF is reached. If a char was put back into the</span> 00395 <span class="comment"> * stream via ungetc, it will be the first character returned.</span> 00396 <span class="comment"> *</span> 00397 <span class="comment"> * @remark It is possible for both bytes to be read and an error to be</span> 00398 <span class="comment"> * returned. And if *bytes_read is less than nbytes, an accompanying</span> 00399 <span class="comment"> * error is _always_ returned.</span> 00400 <span class="comment"> *</span> 00401 <span class="comment"> * @remark APR_EINTR is never returned.</span> 00402 <span class="comment"> */</span> 00403 APR_DECLARE(apr_status_t) apr_file_read_full(apr_file_t *thefile, <span class="keywordtype">void</span> *buf, 00404 apr_size_t nbytes, 00405 apr_size_t *bytes_read); 00406 <span class="comment"></span> 00407 <span class="comment">/**</span> 00408 <span class="comment"> * Write data to the specified file, ensuring that all of the data is</span> 00409 <span class="comment"> * written before returning.</span> 00410 <span class="comment"> * @param thefile The file descriptor to write to.</span> 00411 <span class="comment"> * @param buf The buffer which contains the data.</span> 00412 <span class="comment"> * @param nbytes The number of bytes to write.</span> 00413 <span class="comment"> * @param bytes_written If non-NULL, set to the number of bytes written.</span> 00414 <span class="comment"> * </span> 00415 <span class="comment"> * @remark apr_file_write will write up to the specified number of</span> 00416 <span class="comment"> * bytes, but never more. If the OS cannot write that many bytes, the</span> 00417 <span class="comment"> * process/thread will block until they can be written. Exceptional</span> 00418 <span class="comment"> * error such as "out of space" or "pipe closed" will terminate with</span> 00419 <span class="comment"> * an error.</span> 00420 <span class="comment"> *</span> 00421 <span class="comment"> * @remark It is possible for both bytes to be written and an error to</span> 00422 <span class="comment"> * be returned. And if *bytes_written is less than nbytes, an</span> 00423 <span class="comment"> * accompanying error is _always_ returned.</span> 00424 <span class="comment"> *</span> 00425 <span class="comment"> * @remark APR_EINTR is never returned.</span> 00426 <span class="comment"> */</span> 00427 APR_DECLARE(apr_status_t) apr_file_write_full(apr_file_t *thefile, 00428 const <span class="keywordtype">void</span> *buf, 00429 apr_size_t nbytes, 00430 apr_size_t *bytes_written); 00431 00432 <span class="comment"></span> 00433 <span class="comment">/**</span> 00434 <span class="comment"> * Write data from iovec array to the specified file, ensuring that all of the</span> 00435 <span class="comment"> * data is written before returning.</span> 00436 <span class="comment"> * @param thefile The file descriptor to write to.</span> 00437 <span class="comment"> * @param vec The array from which to get the data to write to the file.</span> 00438 <span class="comment"> * @param nvec The number of elements in the struct iovec array. This must </span> 00439 <span class="comment"> * be smaller than APR_MAX_IOVEC_SIZE. If it isn't, the function </span> 00440 <span class="comment"> * will fail with APR_EINVAL.</span> 00441 <span class="comment"> * @param nbytes The number of bytes written.</span> 00442 <span class="comment"> *</span> 00443 <span class="comment"> * @remark apr_file_writev_full is available even if the underlying</span> 00444 <span class="comment"> * operating system doesn't provide writev().</span> 00445 <span class="comment"> */</span> 00446 APR_DECLARE(apr_status_t) apr_file_writev_full(apr_file_t *thefile, 00447 const struct iovec *vec, 00448 apr_size_t nvec, 00449 apr_size_t *nbytes);<span class="comment"></span> 00450 <span class="comment">/**</span> 00451 <span class="comment"> * Write a character into the specified file.</span> 00452 <span class="comment"> * @param ch The character to write.</span> 00453 <span class="comment"> * @param thefile The file descriptor to write to</span> 00454 <span class="comment"> */</span> 00455 APR_DECLARE(apr_status_t) apr_file_putc(<span class="keywordtype">char</span> ch, apr_file_t *thefile); 00456 <span class="comment"></span> 00457 <span class="comment">/**</span> 00458 <span class="comment"> * Read a character from the specified file.</span> 00459 <span class="comment"> * @param ch The character to read into</span> 00460 <span class="comment"> * @param thefile The file descriptor to read from</span> 00461 <span class="comment"> */</span> 00462 APR_DECLARE(apr_status_t) apr_file_getc(<span class="keywordtype">char</span> *ch, apr_file_t *thefile); 00463 <span class="comment"></span> 00464 <span class="comment">/**</span> 00465 <span class="comment"> * Put a character back onto a specified stream.</span> 00466 <span class="comment"> * @param ch The character to write.</span> 00467 <span class="comment"> * @param thefile The file descriptor to write to</span> 00468 <span class="comment"> */</span> 00469 APR_DECLARE(apr_status_t) apr_file_ungetc(<span class="keywordtype">char</span> ch, apr_file_t *thefile); 00470 <span class="comment"></span> 00471 <span class="comment">/**</span> 00472 <span class="comment"> * Read a string from the specified file.</span> 00473 <span class="comment"> * @param str The buffer to store the string in. </span> 00474 <span class="comment"> * @param len The length of the string</span> 00475 <span class="comment"> * @param thefile The file descriptor to read from</span> 00476 <span class="comment"> * @remark The buffer will be NUL-terminated if any characters are stored.</span> 00477 <span class="comment"> */</span> 00478 APR_DECLARE(apr_status_t) apr_file_gets(<span class="keywordtype">char</span> *str, <span class="keywordtype">int</span> len, 00479 apr_file_t *thefile); 00480 <span class="comment"></span> 00481 <span class="comment">/**</span> 00482 <span class="comment"> * Write the string into the specified file.</span> 00483 <span class="comment"> * @param str The string to write. </span> 00484 <span class="comment"> * @param thefile The file descriptor to write to</span> 00485 <span class="comment"> */</span> 00486 APR_DECLARE(apr_status_t) apr_file_puts(const <span class="keywordtype">char</span> *str, apr_file_t *thefile); 00487 <span class="comment"></span> 00488 <span class="comment">/**</span> 00489 <span class="comment"> * Flush the file's buffer.</span> 00490 <span class="comment"> * @param thefile The file descriptor to flush</span> 00491 <span class="comment"> */</span> 00492 APR_DECLARE(apr_status_t) apr_file_flush(apr_file_t *thefile); 00493 <span class="comment"></span> 00494 <span class="comment">/**</span> 00495 <span class="comment"> * Duplicate the specified file descriptor.</span> 00496 <span class="comment"> * @param new_file The structure to duplicate into. </span> 00497 <span class="comment"> * @param old_file The file to duplicate.</span> 00498 <span class="comment"> * @param p The pool to use for the new file.</span> 00499 <span class="comment"> * @remark *new_file must point to a valid apr_file_t, or point to NULL.</span> 00500 <span class="comment"> */</span> 00501 APR_DECLARE(apr_status_t) apr_file_dup(apr_file_t **new_file, 00502 apr_file_t *old_file, 00503 apr_pool_t *p); 00504 <span class="comment"></span> 00505 <span class="comment">/**</span> 00506 <span class="comment"> * Duplicate the specified file descriptor and close the original</span> 00507 <span class="comment"> * @param new_file The old file that is to be closed and reused</span> 00508 <span class="comment"> * @param old_file The file to duplicate</span> 00509 <span class="comment"> * @param p The pool to use for the new file</span> 00510 <span class="comment"> *</span> 00511 <span class="comment"> * @remark new_file MUST point at a valid apr_file_t. It cannot be NULL.</span> 00512 <span class="comment"> */</span> 00513 APR_DECLARE(apr_status_t) apr_file_dup2(apr_file_t *new_file, 00514 apr_file_t *old_file, 00515 apr_pool_t *p); 00516 <span class="comment"></span> 00517 <span class="comment">/**</span> 00518 <span class="comment"> * Move the specified file descriptor to a new pool</span> 00519 <span class="comment"> * @param new_file Pointer in which to return the new apr_file_t</span> 00520 <span class="comment"> * @param old_file The file to move</span> 00521 <span class="comment"> * @param p The pool to which the descriptor is to be moved</span> 00522 <span class="comment"> * @remark Unlike apr_file_dup2(), this function doesn't do an</span> 00523 <span class="comment"> * OS dup() operation on the underlying descriptor; it just</span> 00524 <span class="comment"> * moves the descriptor's apr_file_t wrapper to a new pool.</span> 00525 <span class="comment"> * @remark The new pool need not be an ancestor of old_file's pool.</span> 00526 <span class="comment"> * @remark After calling this function, old_file may not be used</span> 00527 <span class="comment"> */</span> 00528 APR_DECLARE(apr_status_t) apr_file_setaside(apr_file_t **new_file, 00529 apr_file_t *old_file, 00530 apr_pool_t *p); 00531 <span class="comment"></span> 00532 <span class="comment">/**</span> 00533 <span class="comment"> * Move the read/write file offset to a specified byte within a file.</span> 00534 <span class="comment"> * @param thefile The file descriptor</span> 00535 <span class="comment"> * @param where How to move the pointer, one of:</span> 00536 <span class="comment"> * <PRE></span> 00537 <span class="comment"> * APR_SET -- set the offset to offset</span> 00538 <span class="comment"> * APR_CUR -- add the offset to the current position </span> 00539 <span class="comment"> * APR_END -- add the offset to the current file size </span> 00540 <span class="comment"> * </PRE></span> 00541 <span class="comment"> * @param offset The offset to move the pointer to.</span> 00542 <span class="comment"> * @remark The third argument is modified to be the offset the pointer</span> 00543 <span class="comment"> was actually moved to.</span> 00544 <span class="comment"> */</span> 00545 APR_DECLARE(apr_status_t) apr_file_seek(apr_file_t *thefile, 00546 apr_seek_where_t where, 00547 apr_off_t *offset); 00548 <span class="comment"></span> 00549 <span class="comment">/**</span> 00550 <span class="comment"> * Create an anonymous pipe.</span> 00551 <span class="comment"> * @param in The file descriptor to use as input to the pipe.</span> 00552 <span class="comment"> * @param out The file descriptor to use as output from the pipe.</span> 00553 <span class="comment"> * @param pool The pool to operate on.</span> 00554 <span class="comment"> */</span> 00555 APR_DECLARE(apr_status_t) apr_file_pipe_create(apr_file_t **in, 00556 apr_file_t **out, 00557 apr_pool_t *pool); 00558 <span class="comment"></span> 00559 <span class="comment">/**</span> 00560 <span class="comment"> * Create a named pipe.</span> 00561 <span class="comment"> * @param filename The filename of the named pipe</span> 00562 <span class="comment"> * @param perm The permissions for the newly created pipe.</span> 00563 <span class="comment"> * @param pool The pool to operate on.</span> 00564 <span class="comment"> */</span> 00565 APR_DECLARE(apr_status_t) apr_file_namedpipe_create(const <span class="keywordtype">char</span> *filename, 00566 apr_fileperms_t perm, 00567 apr_pool_t *pool); 00568 <span class="comment"></span> 00569 <span class="comment">/**</span> 00570 <span class="comment"> * Get the timeout value for a pipe or manipulate the blocking state.</span> 00571 <span class="comment"> * @param thepipe The pipe we are getting a timeout for.</span> 00572 <span class="comment"> * @param timeout The current timeout value in microseconds. </span> 00573 <span class="comment"> */</span> 00574 APR_DECLARE(apr_status_t) apr_file_pipe_timeout_get(apr_file_t *thepipe, 00575 apr_interval_time_t *timeout); 00576 <span class="comment"></span> 00577 <span class="comment">/**</span> 00578 <span class="comment"> * Set the timeout value for a pipe or manipulate the blocking state.</span> 00579 <span class="comment"> * @param thepipe The pipe we are setting a timeout on.</span> 00580 <span class="comment"> * @param timeout The timeout value in microseconds. Values < 0 mean wait </span> 00581 <span class="comment"> * forever, 0 means do not wait at all.</span> 00582 <span class="comment"> */</span> 00583 APR_DECLARE(apr_status_t) apr_file_pipe_timeout_set(apr_file_t *thepipe, 00584 apr_interval_time_t timeout); 00585 <span class="comment"></span> 00586 <span class="comment">/** file (un)locking functions. */</span> 00587 <span class="comment"></span> 00588 <span class="comment">/**</span> 00589 <span class="comment"> * Establish a lock on the specified, open file. The lock may be advisory</span> 00590 <span class="comment"> * or mandatory, at the discretion of the platform. The lock applies to</span> 00591 <span class="comment"> * the file as a whole, rather than a specific range. Locks are established</span> 00592 <span class="comment"> * on a per-thread/process basis; a second lock by the same thread will not</span> 00593 <span class="comment"> * block.</span> 00594 <span class="comment"> * @param thefile The file to lock.</span> 00595 <span class="comment"> * @param type The type of lock to establish on the file.</span> 00596 <span class="comment"> */</span> 00597 APR_DECLARE(apr_status_t) apr_file_lock(apr_file_t *thefile, <span class="keywordtype">int</span> type); 00598 <span class="comment"></span> 00599 <span class="comment">/**</span> 00600 <span class="comment"> * Remove any outstanding locks on the file.</span> 00601 <span class="comment"> * @param thefile The file to unlock.</span> 00602 <span class="comment"> */</span> 00603 APR_DECLARE(apr_status_t) apr_file_unlock(apr_file_t *thefile); 00604 <span class="comment"></span> 00605 <span class="comment">/**accessor and general file_io functions. */</span> 00606 <span class="comment"></span> 00607 <span class="comment">/**</span> 00608 <span class="comment"> * return the file name of the current file.</span> 00609 <span class="comment"> * @param new_path The path of the file. </span> 00610 <span class="comment"> * @param thefile The currently open file.</span> 00611 <span class="comment"> */</span> 00612 APR_DECLARE(apr_status_t) apr_file_name_get(const <span class="keywordtype">char</span> **new_path, 00613 apr_file_t *thefile); 00614 <span class="comment"></span> 00615 <span class="comment">/**</span> 00616 <span class="comment"> * Return the data associated with the current file.</span> 00617 <span class="comment"> * @param data The user data associated with the file. </span> 00618 <span class="comment"> * @param key The key to use for retreiving data associated with this file.</span> 00619 <span class="comment"> * @param file The currently open file.</span> 00620 <span class="comment"> */</span> 00621 APR_DECLARE(apr_status_t) apr_file_data_get(<span class="keywordtype">void</span> **data, const <span class="keywordtype">char</span> *key, 00622 apr_file_t *file); 00623 <span class="comment"></span> 00624 <span class="comment">/**</span> 00625 <span class="comment"> * Set the data associated with the current file.</span> 00626 <span class="comment"> * @param file The currently open file.</span> 00627 <span class="comment"> * @param data The user data to associate with the file. </span> 00628 <span class="comment"> * @param key The key to use for assocaiteing data with the file.</span> 00629 <span class="comment"> * @param cleanup The cleanup routine to use when the file is destroyed.</span> 00630 <span class="comment"> */</span> 00631 APR_DECLARE(apr_status_t) apr_file_data_set(apr_file_t *file, <span class="keywordtype">void</span> *data, 00632 const <span class="keywordtype">char</span> *key, 00633 apr_status_t (*cleanup)(<span class="keywordtype">void</span> *)); 00634 <span class="comment"></span> 00635 <span class="comment">/**</span> 00636 <span class="comment"> * Write a string to a file using a printf format.</span> 00637 <span class="comment"> * @param fptr The file to write to.</span> 00638 <span class="comment"> * @param format The format string</span> 00639 <span class="comment"> * @param ... The values to substitute in the format string</span> 00640 <span class="comment"> * @return The number of bytes written</span> 00641 <span class="comment"> */</span> 00642 APR_DECLARE_NONSTD(<span class="keywordtype">int</span>) apr_file_printf(apr_file_t *fptr, 00643 const <span class="keywordtype">char</span> *format, ...) 00644 __attribute__((format(printf,2,3))); 00645 <span class="comment"></span> 00646 <span class="comment">/**</span> 00647 <span class="comment"> * set the specified file's permission bits.</span> 00648 <span class="comment"> * @param fname The file (name) to apply the permissions to.</span> 00649 <span class="comment"> * @param perms The permission bits to apply to the file.</span> 00650 <span class="comment"> *</span> 00651 <span class="comment"> * @warning Some platforms may not be able to apply all of the</span> 00652 <span class="comment"> * available permission bits; APR_INCOMPLETE will be returned if some</span> 00653 <span class="comment"> * permissions are specified which could not be set.</span> 00654 <span class="comment"> *</span> 00655 <span class="comment"> * @warning Platforms which do not implement this feature will return</span> 00656 <span class="comment"> * APR_ENOTIMPL.</span> 00657 <span class="comment"> */</span> 00658 APR_DECLARE(apr_status_t) apr_file_perms_set(const <span class="keywordtype">char</span> *fname, 00659 apr_fileperms_t perms); 00660 <span class="comment"></span> 00661 <span class="comment">/**</span> 00662 <span class="comment"> * Set attributes of the specified file.</span> 00663 <span class="comment"> * @param fname The full path to the file (using / on all systems)</span> 00664 <span class="comment"> * @param attributes Or'd combination of</span> 00665 <span class="comment"> * <PRE></span> 00666 <span class="comment"> * APR_FILE_ATTR_READONLY - make the file readonly</span> 00667 <span class="comment"> * APR_FILE_ATTR_EXECUTABLE - make the file executable</span> 00668 <span class="comment"> * APR_FILE_ATTR_HIDDEN - make the file hidden</span> 00669 <span class="comment"> * </PRE></span> 00670 <span class="comment"> * @param attr_mask Mask of valid bits in attributes.</span> 00671 <span class="comment"> * @param pool the pool to use.</span> 00672 <span class="comment"> * @remark This function should be used in preference to explict manipulation</span> 00673 <span class="comment"> * of the file permissions, because the operations to provide these</span> 00674 <span class="comment"> * attributes are platform specific and may involve more than simply</span> 00675 <span class="comment"> * setting permission bits.</span> 00676 <span class="comment"> * @warning Platforms which do not implement this feature will return</span> 00677 <span class="comment"> * APR_ENOTIMPL.</span> 00678 <span class="comment"> */</span> 00679 APR_DECLARE(apr_status_t) apr_file_attrs_set(const <span class="keywordtype">char</span> *fname, 00680 apr_fileattrs_t attributes, 00681 apr_fileattrs_t attr_mask, 00682 apr_pool_t *pool); 00683 <span class="comment"></span> 00684 <span class="comment">/**</span> 00685 <span class="comment"> * Set the mtime of the specified file.</span> 00686 <span class="comment"> * @param fname The full path to the file (using / on all systems)</span> 00687 <span class="comment"> * @param mtime The mtime to apply to the file.</span> 00688 <span class="comment"> * @param pool The pool to use.</span> 00689 <span class="comment"> * @warning Platforms which do not implement this feature will return</span> 00690 <span class="comment"> * APR_ENOTIMPL.</span> 00691 <span class="comment"> */</span> 00692 APR_DECLARE(apr_status_t) apr_file_mtime_set(const <span class="keywordtype">char</span> *fname, 00693 apr_time_t mtime, 00694 apr_pool_t *pool); 00695 <span class="comment"></span> 00696 <span class="comment">/**</span> 00697 <span class="comment"> * Create a new directory on the file system.</span> 00698 <span class="comment"> * @param path the path for the directory to be created. (use / on all systems)</span> 00699 <span class="comment"> * @param perm Permissions for the new direcoty.</span> 00700 <span class="comment"> * @param pool the pool to use.</span> 00701 <span class="comment"> */</span> 00702 APR_DECLARE(apr_status_t) apr_dir_make(const <span class="keywordtype">char</span> *path, apr_fileperms_t perm, 00703 apr_pool_t *pool); 00704 <span class="comment"></span> 00705 <span class="comment">/** Creates a new directory on the file system, but behaves like</span> 00706 <span class="comment"> * 'mkdir -p'. Creates intermediate directories as required. No error</span> 00707 <span class="comment"> * will be reported if PATH already exists.</span> 00708 <span class="comment"> * @param path the path for the directory to be created. (use / on all systems)</span> 00709 <span class="comment"> * @param perm Permissions for the new direcoty.</span> 00710 <span class="comment"> * @param pool the pool to use.</span> 00711 <span class="comment"> */</span> 00712 APR_DECLARE(apr_status_t) apr_dir_make_recursive(const <span class="keywordtype">char</span> *path, 00713 apr_fileperms_t perm, 00714 apr_pool_t *pool); 00715 <span class="comment"></span> 00716 <span class="comment">/**</span> 00717 <span class="comment"> * Remove directory from the file system.</span> 00718 <span class="comment"> * @param path the path for the directory to be removed. (use / on all systems)</span> 00719 <span class="comment"> * @param pool the pool to use.</span> 00720 <span class="comment"> */</span> 00721 APR_DECLARE(apr_status_t) apr_dir_remove(const <span class="keywordtype">char</span> *path, apr_pool_t *pool); 00722 <span class="comment"></span> 00723 <span class="comment">/**</span> 00724 <span class="comment"> * get the specified file's stats.</span> 00725 <span class="comment"> * @param finfo Where to store the information about the file.</span> 00726 <span class="comment"> * @param wanted The desired apr_finfo_t fields, as a bit flag of APR_FINFO_ values </span> 00727 <span class="comment"> * @param thefile The file to get information about.</span> 00728 <span class="comment"> */</span> 00729 APR_DECLARE(apr_status_t) apr_file_info_get(<a class="code" href="structapr__finfo__t.html">apr_finfo_t</a> *finfo, 00730 apr_int32_t wanted, 00731 apr_file_t *thefile); 00732 00733 <span class="comment"></span> 00734 <span class="comment">/**</span> 00735 <span class="comment"> * Truncate the file's length to the specified offset</span> 00736 <span class="comment"> * @param fp The file to truncate</span> 00737 <span class="comment"> * @param offset The offset to truncate to.</span> 00738 <span class="comment"> */</span> 00739 APR_DECLARE(apr_status_t) apr_file_trunc(apr_file_t *fp, apr_off_t offset); 00740 <span class="comment"></span> 00741 <span class="comment">/**</span> 00742 <span class="comment"> * Retrieve the flags that were passed into apr_file_open()</span> 00743 <span class="comment"> * when the file was opened.</span> 00744 <span class="comment"> * @return apr_int32_t the flags</span> 00745 <span class="comment"> */</span> 00746 APR_DECLARE(apr_int32_t) apr_file_flags_get(apr_file_t *f); 00747 <span class="comment"></span> 00748 <span class="comment">/**</span> 00749 <span class="comment"> * Get the pool used by the file.</span> 00750 <span class="comment"> */</span> 00751 APR_POOL_DECLARE_ACCESSOR(file); 00752 <span class="comment"></span> 00753 <span class="comment">/**</span> 00754 <span class="comment"> * Set a file to be inherited by child processes.</span> 00755 <span class="comment"> *</span> 00756 <span class="comment"> */</span> 00757 APR_DECLARE_INHERIT_SET(file); 00758 <span class="comment"></span> 00759 <span class="comment">/**</span> 00760 <span class="comment"> * Unset a file from being inherited by child processes.</span> 00761 <span class="comment"> */</span> 00762 APR_DECLARE_INHERIT_UNSET(file); 00763 <span class="comment"></span> 00764 <span class="comment">/**</span> 00765 <span class="comment"> * Open a temporary file</span> 00766 <span class="comment"> * @param fp The apr file to use as a temporary file.</span> 00767 <span class="comment"> * @param templ The template to use when creating a temp file.</span> 00768 <span class="comment"> * @param flags The flags to open the file with. If this is zero,</span> 00769 <span class="comment"> * the file is opened with </span> 00770 <span class="comment"> * APR_CREATE | APR_READ | APR_WRITE | APR_EXCL | APR_DELONCLOSE</span> 00771 <span class="comment"> * @param p The pool to allocate the file out of.</span> 00772 <span class="comment"> * @remark </span> 00773 <span class="comment"> * This function generates a unique temporary file name from template. </span> 00774 <span class="comment"> * The last six characters of template must be XXXXXX and these are replaced </span> 00775 <span class="comment"> * with a string that makes the filename unique. Since it will be modified,</span> 00776 <span class="comment"> * template must not be a string constant, but should be declared as a character</span> 00777 <span class="comment"> * array. </span> 00778 <span class="comment"> *</span> 00779 <span class="comment"> */</span> 00780 APR_DECLARE(apr_status_t) apr_file_mktemp(apr_file_t **fp, <span class="keywordtype">char</span> *templ, 00781 apr_int32_t flags, apr_pool_t *p); 00782 00783 <span class="comment"></span> 00784 <span class="comment">/**</span> 00785 <span class="comment"> * Find an existing directory suitable as a temporary storage location.</span> 00786 <span class="comment"> * @param temp_dir The temp directory.</span> 00787 <span class="comment"> * @param p The pool to use for any necessary allocations.</span> 00788 <span class="comment"> * @remark </span> 00789 <span class="comment"> * This function uses an algorithm to search for a directory that an</span> 00790 <span class="comment"> * an application can use for temporary storage. Once such a</span> 00791 <span class="comment"> * directory is found, that location is cached by the library. Thus,</span> 00792 <span class="comment"> * callers only pay the cost of this algorithm once if that one time</span> 00793 <span class="comment"> * is successful.</span> 00794 <span class="comment"> *</span> 00795 <span class="comment"> */</span> 00796 APR_DECLARE(apr_status_t) apr_temp_dir_get(const <span class="keywordtype">char</span> **temp_dir, 00797 apr_pool_t *p); 00798 <span class="comment"></span> 00799 <span class="comment">/** @} */</span> 00800 00801 #ifdef __cplusplus 00802 } 00803 #endif 00804 00805 #endif <span class="comment">/* ! APR_FILE_IO_H */</span> </pre></div><hr size="1"><address style="align: right;"><small>Generated on Sun Mar 20 19:52:26 2005 for Apache Portable Runtime by <a href="http://www.doxygen.org/index.html"> <img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.3.9.1 </small></address> </body> </html>