Apache源码分析——APR(2) 可移植性

本来想跳过去Apache中了windows的其他系统的,但还是来看一下,以便后面阅读时更顺利。


可移植性体现在apr_portable.h中,里面定义的函数来抹去各种不同平台下的文件、目录、网络、进程、时间、线程、管道、编码的差异。


/**
 * convert the file from apr type to os specific type.
 * @param thefile The os specific file we are converting to
 * @param file The apr file to convert.
 * @remark On Unix, it is only possible to get a file descriptor from 
 *         an apr file type.
 */
APR_DECLARE(apr_status_t) apr_os_file_get(apr_os_file_t *thefile,
                                          apr_file_t *file);

则是将apr文件类型转换成相应操作系统的文件类型。


/**
 * convert the file from os specific type to apr type.
 * @param file The apr file we are converting to.
 * @param thefile The os specific file to convert
 * @param flags The flags that were used to open this file.
 * @param cont The pool to use if it is needed.
 * @remark On Unix, it is only possible to put a file descriptor into
 *         an apr file type.
 */
APR_DECLARE(apr_status_t) apr_os_file_put(apr_file_t **file,
                                          apr_os_file_t *thefile,
                                          apr_int32_t flags, apr_pool_t *cont); 

则是将指定的操作系统文件类型转换成apr中定义的文件类型。


其他的也和文件类型的转换一样,都有这配对的转换函数。

这些函数是把常用的操作系统内核类型都做了和apr类型的转换,来实现对不同平台的可移植性。

设计也是巧妙,体现了Apache项目中统一性。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值