• Main Page
  • Related Pages
  • Modules
  • Data Structures
  • Files

apr_file_info.h

Go to the documentation of this file.
00001 /* Licensed to the Apache Software Foundation (ASF) under one or more
00002  * contributor license agreements.  See the NOTICE file distributed with
00003  * this work for additional information regarding copyright ownership.
00004  * The ASF licenses this file to You under the Apache License, Version 2.0
00005  * (the "License"); you may not use this file except in compliance with
00006  * the License.  You may obtain a copy of the License at
00007  *
00008  *     http://www.apache.org/licenses/LICENSE-2.0
00009  *
00010  * Unless required by applicable law or agreed to in writing, software
00011  * distributed under the License is distributed on an "AS IS" BASIS,
00012  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00013  * See the License for the specific language governing permissions and
00014  * limitations under the License.
00015  */
00016 
00017 #ifndef APR_FILE_INFO_H
00018 #define APR_FILE_INFO_H
00019 
00020 /**
00021  * @file apr_file_info.h
00022  * @brief APR File Information
00023  */
00024 
00025 #include "apr.h"
00026 #include "apr_user.h"
00027 #include "apr_pools.h"
00028 #include "apr_tables.h"
00029 #include "apr_time.h"
00030 #include "apr_errno.h"
00031 
00032 #if APR_HAVE_SYS_UIO_H
00033 #include <sys/uio.h>
00034 #endif
00035 
00036 #ifdef __cplusplus
00037 extern "C" {
00038 #endif /* __cplusplus */
00039 
00040 /**
00041  * @defgroup apr_file_info File Information
00042  * @ingroup APR 
00043  * @{
00044  */
00045 
00046 /* Many applications use the type member to determine the
00047  * existance of a file or initialization of the file info,
00048  * so the APR_NOFILE value must be distinct from APR_UNKFILE.
00049  */
00050 
00051 /** apr_filetype_e values for the filetype member of the 
00052  * apr_file_info_t structure
00053  * @warning: Not all of the filetypes below can be determined.
00054  * For example, a given platform might not correctly report 
00055  * a socket descriptor as APR_SOCK if that type isn't 
00056  * well-identified on that platform.  In such cases where
00057  * a filetype exists but cannot be described by the recognized
00058  * flags below, the filetype will be APR_UNKFILE.  If the
00059  * filetype member is not determined, the type will be APR_NOFILE.
00060  */
00061 
00062 typedef enum {
00063     APR_NOFILE = 0,     /**< no file type determined */
00064     APR_REG,            /**< a regular file */
00065     APR_DIR,            /**< a directory */
00066     APR_CHR,            /**< a character device */
00067     APR_BLK,            /**< a block device */
00068     APR_PIPE,           /**< a FIFO / pipe */
00069     APR_LNK,            /**< a symbolic link */
00070     APR_SOCK,           /**< a [unix domain] socket */
00071     APR_UNKFILE = 127   /**< a file of some other unknown type */
00072 } apr_filetype_e; 
00073 
00074 /**
00075  * @defgroup apr_file_permissions File Permissions flags 
00076  * @{
00077  */
00078 
00079 #define APR_FPROT_USETID      0x8000 /**< Set user id */
00080 #define APR_FPROT_UREAD       0x0400 /**< Read by user */
00081 #define APR_FPROT_UWRITE      0x0200 /**< Write by user */
00082 #define APR_FPROT_UEXECUTE    0x0100 /**< Execute by user */
00083 
00084 #define APR_FPROT_GSETID      0x4000 /**< Set group id */
00085 #define APR_FPROT_GREAD       0x0040 /**< Read by group */
00086 #define APR_FPROT_GWRITE      0x0020 /**< Write by group */
00087 #define APR_FPROT_GEXECUTE    0x0010 /**< Execute by group */
00088 
00089 #define APR_FPROT_WSTICKY     0x2000 /**< Sticky bit */
00090 #define APR_FPROT_WREAD       0x0004 /**< Read by others */
00091 #define APR_FPROT_WWRITE      0x0002 /**< Write by others */
00092 #define APR_FPROT_WEXECUTE    0x0001 /**< Execute by others */
00093 
00094 #define APR_FPROT_OS_DEFAULT  0x0FFF /**< use OS's default permissions */
00095 
00096 /* additional permission flags for apr_file_copy  and apr_file_append */
00097 #define APR_FPROT_FILE_SOURCE_PERMS 0x1000 /**< Copy source file's permissions */
00098     
00099 /* backcompat */
00100 #define APR_USETID     APR_FPROT_USETID     /**< @deprecated @see APR_FPROT_USETID     */
00101 #define APR_UREAD      APR_FPROT_UREAD      /**< @deprecated @see APR_FPROT_UREAD      */
00102 #define APR_UWRITE     APR_FPROT_UWRITE     /**< @deprecated @see APR_FPROT_UWRITE     */
00103 #define APR_UEXECUTE   APR_FPROT_UEXECUTE   /**< @deprecated @see APR_FPROT_UEXECUTE   */
00104 #define APR_GSETID     APR_FPROT_GSETID     /**< @deprecated @see APR_FPROT_GSETID     */
00105 #define APR_GREAD      APR_FPROT_GREAD      /**< @deprecated @see APR_FPROT_GREAD      */
00106 #define APR_GWRITE     APR_FPROT_GWRITE     /**< @deprecated @see APR_FPROT_GWRITE     */
00107 #define APR_GEXECUTE   APR_FPROT_GEXECUTE   /**< @deprecated @see APR_FPROT_GEXECUTE   */
00108 #define APR_WSTICKY    APR_FPROT_WSTICKY    /**< @deprecated @see APR_FPROT_WSTICKY    */
00109 #define APR_WREAD      APR_FPROT_WREAD      /**< @deprecated @see APR_FPROT_WREAD      */
00110 #define APR_WWRITE     APR_FPROT_WWRITE     /**< @deprecated @see APR_FPROT_WWRITE     */
00111 #define APR_WEXECUTE   APR_FPROT_WEXECUTE   /**< @deprecated @see APR_FPROT_WEXECUTE   */
00112 #define APR_OS_DEFAULT APR_FPROT_OS_DEFAULT /**< @deprecated @see APR_FPROT_OS_DEFAULT */
00113 #define APR_FILE_SOURCE_PERMS APR_FPROT_FILE_SOURCE_PERMS /**< @deprecated @see APR_FPROT_FILE_SOURCE_PERMS */
00114     
00115 /** @} */
00116 
00117 
00118 /**
00119  * Structure for referencing directories.
00120  */
00121 typedef struct apr_dir_t          apr_dir_t;
00122 /**
00123  * Structure for determining file permissions.
00124  */
00125 typedef apr_int32_t               apr_fileperms_t;
00126 #if (defined WIN32) || (defined NETWARE)
00127 /**
00128  * Structure for determining the device the file is on.
00129  */
00130 typedef apr_uint32_t              apr_dev_t;
00131 #else
00132 /**
00133  * Structure for determining the device the file is on.
00134  */
00135 typedef dev_t                     apr_dev_t;
00136 #endif
00137 
00138 /**
00139  * @defgroup apr_file_stat Stat Functions
00140  * @{
00141  */
00142 /** file info structure */
00143 typedef struct apr_finfo_t        apr_finfo_t;
00144 
00145 #define APR_FINFO_LINK   0x00000001 /**< Stat the link not the file itself if it is a link */
00146 #define APR_FINFO_MTIME  0x00000010 /**< Modification Time */
00147 #define APR_FINFO_CTIME  0x00000020 /**< Creation or inode-changed time */
00148 #define APR_FINFO_ATIME  0x00000040 /**< Access Time */
00149 #define APR_FINFO_SIZE   0x00000100 /**< Size of the file */
00150 #define APR_FINFO_CSIZE  0x00000200 /**< Storage size consumed by the file */
00151 #define APR_FINFO_DEV    0x00001000 /**< Device */
00152 #define APR_FINFO_INODE  0x00002000 /**< Inode */
00153 #define APR_FINFO_NLINK  0x00004000 /**< Number of links */
00154 #define APR_FINFO_TYPE   0x00008000 /**< Type */
00155 #define APR_FINFO_USER   0x00010000 /**< User */
00156 #define APR_FINFO_GROUP  0x00020000 /**< Group */
00157 #define APR_FINFO_UPROT  0x00100000 /**< User protection bits */
00158 #define APR_FINFO_GPROT  0x00200000 /**< Group protection bits */
00159 #define APR_FINFO_WPROT  0x00400000 /**< World protection bits */
00160 #define APR_FINFO_ICASE  0x01000000 /**< if dev is case insensitive */
00161 #define APR_FINFO_NAME   0x02000000 /**< ->name in proper case */
00162 
00163 #define APR_FINFO_MIN    0x00008170 /**< type, mtime, ctime, atime, size */
00164 #define APR_FINFO_IDENT  0x00003000 /**< dev and inode */
00165 #define APR_FINFO_OWNER  0x00030000 /**< user and group */
00166 #define APR_FINFO_PROT   0x00700000 /**<  all protections */
00167 #define APR_FINFO_NORM   0x0073b170 /**<  an atomic unix apr_stat() */
00168 #define APR_FINFO_DIRENT 0x02000000 /**<  an atomic unix apr_dir_read() */
00169 
00170 /**
00171  * The file information structure.  This is analogous to the POSIX
00172  * stat structure.
00173  */
00174 struct apr_finfo_t {
00175     /** Allocates memory and closes lingering handles in the specified pool */
00176     apr_pool_t *pool;
00177     /** The bitmask describing valid fields of this apr_finfo_t structure 
00178      *  including all available 'wanted' fields and potentially more */
00179     apr_int32_t valid;
00180     /** The access permissions of the file.  Mimics Unix access rights. */
00181     apr_fileperms_t protection;
00182     /** The type of file.  One of APR_REG, APR_DIR, APR_CHR, APR_BLK, APR_PIPE, 
00183      * APR_LNK or APR_SOCK.  If the type is undetermined, the value is APR_NOFILE.
00184      * If the type cannot be determined, the value is APR_UNKFILE.
00185      */
00186     apr_filetype_e filetype;
00187     /** The user id that owns the file */
00188     apr_uid_t user;
00189     /** The group id that owns the file */
00190     apr_gid_t group;
00191     /** The inode of the file. */
00192     apr_ino_t inode;
00193     /** The id of the device the file is on. */
00194     apr_dev_t device;
00195     /** The number of hard links to the file. */
00196     apr_int32_t nlink;
00197     /** The size of the file */
00198     apr_off_t size;
00199     /** The storage size consumed by the file */
00200     apr_off_t csize;
00201     /** The time the file was last accessed */
00202     apr_time_t atime;
00203     /** The time the file was last modified */
00204     apr_time_t mtime;
00205     /** The time the file was created, or the inode was last changed */
00206     apr_time_t ctime;
00207     /** The pathname of the file (possibly unrooted) */
00208     const char *fname;
00209     /** The file's name (no path) in filesystem case */
00210     const char *name;
00211     /** The file's handle, if accessed (can be submitted to apr_duphandle) */
00212     struct apr_file_t *filehand;
00213 };
00214 
00215 /**
00216  * get the specified file's stats.  The file is specified by filename, 
00217  * instead of using a pre-opened file.
00218  * @param finfo Where to store the information about the file, which is
00219  * never touched if the call fails.
00220  * @param fname The name of the file to stat.
00221  * @param wanted The desired apr_finfo_t fields, as a bit flag of APR_FINFO_
00222                  values 
00223  * @param pool the pool to use to allocate the new file. 
00224  *
00225  * @note If @c APR_INCOMPLETE is returned all the fields in @a finfo may
00226  *       not be filled in, and you need to check the @c finfo->valid bitmask
00227  *       to verify that what you're looking for is there.
00228  */ 
00229 APR_DECLARE(apr_status_t) apr_stat(apr_finfo_t *finfo, const char *fname,
00230                                    apr_int32_t wanted, apr_pool_t *pool);
00231 
00232 /** @} */
00233 /**
00234  * @defgroup apr_dir Directory Manipulation Functions
00235  * @{
00236  */
00237 
00238 /**
00239  * Open the specified directory.
00240  * @param new_dir a class="code" href="structapr__finfo__t.html">apr_finfo_t *finfo, const char *fname,
00230                                    apr_int32_t wanted, apr_pool_t *pool);
00231 
00232 /** @} */
00233 /**
00234  * @defgroup apr_dir Directory Manipulation Functions
00235  * @{
00236  */
00237 
00238 /**
00239  * Open the specified directory.
00240  * @param new_dir a class="code" href="structapr__finfo__t.html">apr_finfo_t *finfo, const char *fname,
00230                                    apr_int32_t wanted, apr_pool_t *pool);
00231 
00232 /** @} */
00233 /**
00234  * @defgroup apr_dir Directory Manipulation Functions
00235  * @{
00236  */
00237 
00238 /**
00239  * Open the specified directory.
00240  * @param new_dir a class="code" href="structapr__finfo__t.html">apr_finfo_t *finfo, const char *fname,
00230                                    apr_int32_t wanted, apr_pool_t *pool);
00231 
00232 /** @} */
00233 /**
00234  * @defgroup apr_dir Directory Manipulation Functions
00235  * @{
00236  */
00237 
00238 /**
00239  * Open the specified directory.
00240  * @param new_dir a class="code" href="structapr__finfo__t.html">apr_finfo_t *finfo, const char *fname,
00230                                    apr_int32_t wanted, apr_pool_t *pool);
00231 
00232 /** @} */
00233 /**
00234  * @defgroup apr_dir Directory Manipulation Functions
00235  * @{
00236  */
00237 
00238 /**
00239  * Open the specified directory.
00240  * @param new_dir a class="code" href="structapr__finfo__t.html">apr_finfo_t *finfo, const char *fname,
00230                                    apr_int32_t wanted, apr_pool_t *pool);
00231 
00232 /** @} */
00233 /**
00234  * @defgroup apr_dir Directory Manipulation Functions
00235  * @{
00236  */
00237 
00238 /**
00239  * Open the specified directory.
00240  * @param new_dir a class="code" href="structapr__finfo__t.html">apr_finfo_t *finfo, const char *fname,
00230                                    apr_int32_t wanted, apr_pool_t *pool);
00231 
00232 /** @} */
00233 /**
00234  * @defgroup apr_dir Directory Manipulation Functions
00235  * @{
00236  */
00237 
00238 /**
00239  * Open the specified directory.
00240  * @param new_dir a class="code" href="structapr__finfo__t.html">apr_finfo_t *finfo, const char *fname,
00230                                    apr_int32_t wanted, apr_pool_t *pool);
00231 
00232 /** @} */
00233 /**
00234  * @defgroup apr_dir Directory Manipulation Functions
00235  * @{
00236  */
00237 
00238 /**
00239  * Open the specified directory.
00240  * @param new_dir a class="code" href="structapr__finfo__t.html">apr_finfo_t *finfo, const char *fname,
00230                                    apr_int32_t wanted, apr_pool_t *pool);
00231 
00232 /** @} */
00233 /**
00234  * @defgroup apr_dir Directory Manipulation Functions
00235  * @{
00236  */
00237 
00238 /**
00239  * Open the specified directory.
00240  * @param new_dir a class="code" href="structapr__finfo__t.html">apr_finfo_t *finfo, const char *fname,
00230                                    apr_int32_t wanted, apr_pool_t *pool);
00231 
00232 /** @} */
00233 /**
00234  * @defgroup apr_dir Directory Manipulation Functions
00235  * @{
00236  */
00237 
00238 /**
00239  * Open the specified directory.
00240  * @param new_dir a class="code" href="structapr__finfo__t.html">apr_finfo_t *finfo, const char *fname,
00230                                    apr_int32_t wanted, apr_pool_t *pool);
00231 
00232 /** @} */
00233 /**
00234  * @defgroup apr_dir Directory Manipulation Functions
00235  * @{
00236  */
00237 
00238 /**
00239  * Open the specified directory.
00240  * @param new_dir a class="code" href="structapr__finfo__t.html">apr_finfo_t *finfo, const char *fname,
00230                                    apr_int32_t wanted, apr_pool_t *pool);
00231 
00232 /** @} */
00233 /**
00234  * @defgroup apr_dir Directory Manipulation Functions
00235  * @{
00236  */
00237 
00238 /**
00239  * Open the specified directory.
00240  * @param new_dir a class="code" href="structapr__finfo__t.html">apr_finfo_t *finfo, const char *fname,
00230                                    apr_int32_t wanted, apr_pool_t *pool);
00231 
00232 /** @} */
00233 /**
00234  * @defgroup apr_dir Directory Manipulation Functions
00235  * @{
00236  */
00237 
00238 /**
00239  * Open the specified directory.
00240  * @param new_dir a class="code" href="structapr__finfo__t.html">apr_finfo_t *finfo, const char *fname,
00230                                    apr_int32_t wanted, apr_pool_t *pool);
00231 
00232 /** @} */
00233 /**
00234  * @defgroup apr_dir Directory Manipulation Functions
00235  * @{
00236  */
00237 
00238 /**
00239  * Open the specified directory.
00240  * @param new_dir a class="code" href="structapr__finfo__t.html">apr_finfo_t *finfo, const char *fname,
00230                                    apr_int32_t wanted, apr_pool_t *pool);
00231 
00232 /** @} */
00233 /**
00234  * @defgroup apr_dir Directory Manipulation Functions
00235  * @{
00236  */
00237 
00238 /**
00239  * Open the specified directory.
00240  * @param new_dir a class="code" href="structapr__finfo__t.html">apr_finfo_t *finfo, const char *fname,
00230                                    apr_int32_t wanted, apr_pool_t *pool);
00231 
00232 /** @} */
00233 /**
00234  * @defgroup apr_dir Directory Manipulation Functions
00235  * @{
00236  */
00237 
00238 /**
00239  * Open the specified directory.
00240  * @param new_dir a class="code" href="structapr__finfo__t.html">apr_finfo_t *finfo, const char *fname,
00230                                    apr_int32_t wanted, apr_pool_t *pool);
00231 
00232 /** @} */
00233 /**
00234  * @defgroup apr_dir Directory Manipulation Functions
00235  * @{
00236  */
00237 
00238 /**
00239  * Open the specified directory.
00240  * @param new_dir a class="code" href="structapr__finfo__t.html">apr_finfo_t *finfo, const char *fname,
00230                                    apr_int32_t wanted, apr_pool_t *pool);
00231 
00232 /** @} */
00233 /**
00234  * @defgroup apr_dir Directory Manipulation Functions
00235  * @{
00236  */
00237 
00238 /**
00239  * Open the specified directory.
00240  * @param new_dir a class="code" href="structapr__finfo__t.html">apr_finfo_t *finfo, const char *fname,
00230                                    apr_int32_t wanted, apr_pool_t *pool);
00231 
00232 /** @} */
00233 /**
00234  * @defgroup apr_dir Directory Manipulation Functions
00235  * @{
00236  */
00237 
00238 /**
00239  * Open the specified directory.
00240  * @param new_dir a class="code" href="structapr__finfo__t.html">apr_finfo_t *finfo, const char *fname,
00230                                    apr_int32_t wanted, apr_pool_t *pool);
00231 
00232 /** @} */
00233 /**
00234  * @defgroup apr_dir Directory Manipulation Functions
00235  * @{
00236  */
00237 
00238 /**
00239  * Open the specified directory.
00240  * @param new_dir a class="code" href="structapr__finfo__t.html">apr_finfo_t *finfo, const char *fname,
00230                                    apr_int32_t wanted, apr_pool_t *pool);
00231 
00232 /** @} */
00233 /**
00234  * @defgroup apr_dir Directory Manipulation Functions
00235  * @{
00236  */
00237 
00238 /**
00239  * Open the specified directory.
00240  * @param new_dir a class="code" href="structapr__finfo__t.html">apr_finfo_t *finfo, const char *fname,
00230                                    apr_int32_t wanted, apr_pool_t *pool);
00231 
00232 /** @} */
00233 /**
00234  * @defgroup apr_dir Directory Manipulation Functions
00235  * @{
00236  */
00237 
00238 /**
00239  * Open the specified directory.
00240  * @param new_dir a class="code" href="structapr__finfo__t.html">apr_finfo_t *finfo, const char *fname,
00230                                    apr_int32_t wanted, apr_pool_t *pool);
00231 
00232 /** @} */
00233 /**
00234  * @defgroup apr_dir Directory Manipulation Functions
00235  * @{
00236  */
00237 
00238 /**
00239  * Open the specified directory.
00240  * @param new_dir a class="code" href="structapr__finfo__t.html">apr_finfo_t *finfo, const char *fname,
00230                                    apr_int32_t wanted, apr_pool_t *pool);
00231 
00232 /** @} */
00233 /**
00234  * @defgroup apr_dir Directory Manipulation Functions
00235  * @{
00236  */
00237 
00238 /**
00239  * Open the specified directory.
00240  * @param new_dir a class="code" href="structapr__finfo__t.html">apr_finfo_t *finfo, const char *fname,
00230                                    apr_int32_t wanted, apr_pool_t *pool);
00231 
00232 /** @} */</