如何解决如何使用apr_file_open创建文件
|| 我对Apache可移植运行时库(版本1.4)进行了以下调用:result = apr_file_open(
&file,// new file handle
pathname,// file name
APR_FOPEN_CREATE | // create file if not there
APR_FOPEN_EXCL | // error if file was there already
APR_FOPEN_APPEND | // move to end of file on open
APR_FOPEN_BINARY | // binary mode (ignored on UNIX)
APR_FOPEN_XTHREAD | // allow multiple threads to use file
0,// flags
APR_OS_DEFAULT |
0,// permissions
pool // memory pool to use
);
if ( APR_SUCCESS != result ) {
fprintf(
stderr,\"could not create file \\\"%s\\\": %s\",pathname,apr_errorstr( result )
);
}
pathname
包含字符串/tmp/tempfile20110614091201
。
我不断收到错误“权限被拒绝”(结果代码为3),但我具有对4进行读/写的权限-这是什么引起的?
解决方法
我需要ѭ5标志。我错误地认为ѭ6标志已足够。
因此,有效的呼叫是:
result = apr_file_open(
&file,// new file handle
pathname,// file name
APR_FOPEN_CREATE | // create file if not there
APR_FOPEN_EXCL | // error if file was there already
APR_FOPEN_WRITE | // open for writing
APR_FOPEN_APPEND | // move to end of file on open
APR_FOPEN_BINARY | // binary mode (ignored on UNIX)
APR_FOPEN_XTHREAD | // allow multiple threads to use file
0,// flags
APR_OS_DEFAULT |
0,// permissions
pool // memory pool to use
);
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。