Example #1
0
/* Remove a temporary file F, which is of type apr_file_t *.  First, try
   to close the file, ignoring any errors.  Return an error if the remove
   fails. */
static apr_status_t
cleanup_tempfile (void *f)
{
  apr_file_t *file = f;
  apr_status_t apr_err;
  const char *fname;

  /* the file may or may not have been closed; try it */
  apr_file_close (file);

  apr_err = apr_file_name_get (&fname, file);
  if (apr_err == APR_SUCCESS)
    apr_err = apr_file_remove (fname, apr_file_pool_get (file));

  return apr_err;
}
Example #2
0
static apr_status_t file_bucket_setaside(apr_bucket *data, apr_pool_t *reqpool)
{
    apr_bucket_file *a = data->data;
    apr_file_t *fd = NULL;
    apr_file_t *f = a->fd;
    apr_pool_t *curpool = apr_file_pool_get(f);

    if (apr_pool_is_ancestor(curpool, reqpool)) {
        return APR_SUCCESS;
    }

    if (!apr_pool_is_ancestor(a->readpool, reqpool)) {
        a->readpool = reqpool;
    }

    apr_file_setaside(&fd, f, reqpool);
    a->fd = fd;
    return APR_SUCCESS;
}