3

Apache Portable Runtime ライブラリ (バージョン 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

「許可が拒否されました」というエラー (結果コードAPR_EACCES) が表示され続けますが、読み取り/書き込みの許可が/tmpあります。何が原因でしょうか?

4

1 に答える 1

4

APR_FOPEN_WRITE旗が必要でした。APR_FOPEN_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
    );
于 2011-06-14T09:53:53.257 に答える