On Oct 2, 2008, at 11:58 PM, Bojan Smojver wrote:

On Thu, 2008-10-02 at 23:40 -0700, Tim Bray wrote:

    status = apr_file_open(&fp, tempname, APR_FOPEN_WRITE |
APR_FOPEN_CREATE, PERMS, pool);

Where does the tempname come from?

static char * dir_of(apr_pool_t * pool, char * path) {
    char * s;
    s = apr_pstrdup(pool, path);
    *(rindex(s, '/')) = 0;
    return s;
}

/* make a temp filename for 'filename' */
static char * temp_filename(apr_pool_t * pool, char * filename) {
    char * tempname = dir_of(pool, filename);
    return apr_psprintf(pool, "%s/%s%ld-%ld", tempname,
                        TEMP_PREFIX, arandom(), arandom());
}

i.e. a randomized name in the same directory.
Here's an example: filename is /wf1/data/m-a/a/pub/e/entries/ collection.atom and tempname is /wf1/data/m-a/a/pub/e/entries/T. 493459176-1261197826

-Tim

Reply via email to