apache 读取文件通过 自定义的数据结构 apr_file_t ,结构体申明如下:
struct apr_file_t {
apr_pool_t *pool;
HFILE filedes;
char * fname;
int isopen;
int buffered;
int eof_hit;
apr_int32_t flags;
int timeout;
int pipe;
HEV pipeSem;
enum { BLK_UNKNOWN, BLK_OFF, BLK_ON } blocking;
/* Stuff for buffered mode */
char *buffer;
apr_size_t bufsize; /* Read/Write position in buffer */
apr_size_t bufpos; /* Read/Write position in buffer */
unsigned long dataRead; /* amount of valid data read into buffer */
int direction; /* buffer being used for 0 = read, 1 = write */
unsigned long filePtr; /* position in file of handle */
apr_thread_mutex_t *mutex; /* mutex semaphore, must be owned to access
the above fields */
};
文件相应的操作接口有:
apr_file_open();
apr_file_close();
apr_file_read();
ap_file_write();
apr_file_read_full();
apr_file_write_full()
等,这些操作与c语言文件操作基本类似
可以从 apr_file_io.h中得到文件操作定义的相关接口