本来想跳过去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项目中统一性。