Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/jquery-ui/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/google-sheets/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C 如何使用apr\u file\u open()创建文件_C_Apr_Apache Portable Runtime - Fatal编程技术网

C 如何使用apr\u file\u open()创建文件

C 如何使用apr\u file\u open()创建文件,c,apr,apache-portable-runtime,C,Apr,Apache Portable Runtime,我正在对Apache便携式运行库(1.4版)进行以下调用: 而pathname包含字符串/tmp/tempfile20110614091201 我一直收到错误“权限被拒绝”(结果代码APR\u EACCES),但我有权限读取/写入/tmp——这可能是什么原因?我需要APR\u FOPEN\u write标志。我错误地认为,APR\u FOPEN\u APPEND标志就足够了 因此,有效的方法是: result = apr_file_open( &file, // new

我正在对Apache便携式运行库(1.4版)进行以下调用:

pathname
包含字符串
/tmp/tempfile20110614091201


我一直收到错误“权限被拒绝”(结果代码
APR\u EACCES
),但我有权限读取/写入
/tmp
——这可能是什么原因?

我需要
APR\u FOPEN\u write
标志。我错误地认为,
APR\u FOPEN\u APPEND
标志就足够了

因此,有效的方法是:


    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
    );

结果=apr\u文件\u打开(
&文件,//新文件句柄
路径名,//文件名
APR_FOPEN_CREATE |//如果不存在,则创建文件
APR_FOPEN_EXCL |//如果文件已经存在,则出错
APR_FOPEN_WRITE |//开放供书写
APR_FOPEN_APPEND |//打开时移到文件末尾
APR_FOPEN_BINARY |//二进制模式(在UNIX上被忽略)
APR_FOPEN_XTHREAD |//允许多个线程使用文件
0,//标志
APR\u OS\u默认值|
0,//权限
池//要使用的内存池
);

我创建了这个问题和答案,因为我自己在互联网上搜索了一段时间,没有找到答案。您好。您能告诉我,在这一步之后,如何将HTTP请求的参数及其值附加到文件中?

    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
    );