Main Page | Data Structures | Directories | File List | Data Fields | Globals

lcn_directory.h

Go to the documentation of this file.
00001 /* Copyright 2005 The Apache Software Foundation or its licensors, as
00002  * applicable.
00003  *
00004  * Licensed under the Apache License, Version 2.0 (the "License");
00005  * you may not use this file except in compliance with the License.
00006  * 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 /**
00018  * @file lcn_directory.h
00019  * @brief Routines for working with various types of directories
00020  */
00021 
00022 #ifndef _LCN_DIRECTORY_H
00023 #define _LCN_DIRECTORY_H
00024 
00025 #include "lcn_types.h"
00026 #include "lcn_istream.h"
00027 
00028 #include <apr_hash.h>
00029 #include <apr_tables.h>
00030 #include <apr_time.h>
00031 
00032 #ifdef __cplusplus
00033 extern "C" {
00034 #endif /* __cplusplus */
00035 
00036 /** An opaque directory object. */
00037 typedef struct lcn_directory_t lcn_directory_t;
00038 
00039 /** An entry in a ram-based directory. */
00040 typedef struct {
00041   const char *bytes; /**< The actual contents of the file */
00042   apr_size_t len;    /**< The length of the contents in bytes */
00043   apr_time_t mtime;  /**< The time the file was last modified on */
00044 } lcn_directory_entry_t;
00045 
00046 /** Open a new ram-backed directory @a dir, allocated within @a pool.
00047  *
00048  * @a contents maps from <tt>const char *</tt> filenames to pointers to
00049  * @c lcn_directory_entry_t objects.
00050  */
00051 lcn_error_t *
00052 lcn_ram_directory_open (lcn_directory_t **dir,
00053                         apr_hash_t *contents,
00054                         apr_pool_t *pool);
00055 
00056 /** Open a new directory object @a dir which corresponds to the filesystem
00057  * directory located at @a path, all allocation is done within @a pool.
00058  */
00059 lcn_error_t *
00060 lcn_fs_directory_open (lcn_directory_t **dir,
00061                        const char *path,
00062                        apr_pool_t *pool);
00063 
00064 /** Open an new compound file stream directory @a dir, using the stream
00065  * @a cfsfile for the backing store, all allocation is done within @a pool.
00066  */
00067 lcn_error_t *
00068 lcn_cfs_directory_open (lcn_directory_t **dir,
00069                         lcn_istream_t *cfsfile,
00070                         apr_pool_t *pool);
00071 
00072 /** Return in @a contents a list of the files within directory @a d, allocated
00073  * in @a pool.
00074  *
00075  * @a contents will contain <tt>const char *</tt> filenames.
00076  */
00077 lcn_error_t *
00078 lcn_directory_list (apr_array_header_t **contents,
00079                     const lcn_directory_t *d,
00080                     apr_pool_t *pool);
00081 
00082 /** If file @a name exists in directory @a d return @c TRUE in @a result,
00083  * otherwise return @c FALSE in @a result.
00084  *
00085  * @a pool is used for all temporary allocations.
00086  */
00087 lcn_error_t *
00088 lcn_directory_file_exists (lcn_boolean_t *result,
00089                            const lcn_directory_t *d,
00090                            const char *name,
00091                            apr_pool_t *pool);
00092 
00093 /** Return the time file @a name in directory @a d was modified in @a result,
00094  * using @a pool for temporary allocations.
00095  */
00096 lcn_error_t *
00097 lcn_directory_file_modified (apr_time_t *result,
00098                              const lcn_directory_t *d,
00099                              const char *name,
00100                              apr_pool_t *pool);
00101 
00102 /** Update the modification time for file @a name in directory @a d, using
00103  * @a pool for any temporary allocations.
00104  */
00105 lcn_error_t *
00106 lcn_directory_touch_file (lcn_directory_t *d,
00107                           const char *name,
00108                           apr_pool_t *pool);
00109 
00110 /** Delete file @a name in directory @a d, using @a pool for any temporary
00111  * allocations.
00112  */
00113 lcn_error_t *
00114 lcn_directory_delete_file (lcn_directory_t *d,
00115                            const char *name,
00116                            apr_pool_t *pool);
00117 
00118 /** Rename file @a from to @a to within directory @a d, using @a pool for
00119  * temporary allocations.
00120  */
00121 lcn_error_t *
00122 lcn_directory_rename_file (lcn_directory_t *d,
00123                            const char *from,
00124                            const char *to,
00125                            apr_pool_t *pool);
00126 
00127 #ifdef NOTYET
00128 lcn_error_t *
00129 lcn_directory_create_file (lcn_ostream_t **result,
00130                            lcn_directory_t *d,
00131                            const char *name,
00132                            apr_pool_t *pool);
00133 #endif
00134 
00135 /** Open file @a name in directory @a d for reading, returning a corresponding
00136  * stream in @a result, using @a pool for all allocation.
00137  */
00138 lcn_error_t *
00139 lcn_directory_open_file (lcn_istream_t **result,
00140                          const lcn_directory_t *d,
00141                          const char *name,
00142                          apr_pool_t *pool);
00143 
00144 #ifdef NOTYET
00145 lcn_error_t *
00146 lcn_directory_make_lock (lcn_lock_t **lock,
00147                          lcn_directory_t *d,
00148                          const char *name,
00149                          apr_pool_t *pool);
00150 #endif
00151 
00152 /** Close directory @a d, using @a pool for any temporary allocation.
00153  *
00154  * @note This isn't strictly necessary, you can just let pool cleanups clean
00155  * up the directory for you if you want.
00156  */
00157 lcn_error_t *
00158 lcn_directory_close (lcn_directory_t *d, apr_pool_t *pool);
00159 
00160 #ifdef __cplusplus
00161 }
00162 #endif /* __cplusplus */
00163 
00164 #endif

Generated on Sat Mar 26 08:12:11 2005 for Lucene4c by  doxygen 1.4.0