FreeBSD/contrib/subversion/subversion/libsvn_fs_fs/rev_file.c
/* Core implementation of svn_fs_fs__open_pack_or_rev_file working on an
 * existing, initialized FILE structure.  If WRITABLE is TRUE, give write
 * access to the file - temporarily resetting the r/o state if necessary.
 */
Core implementation of svn_fs_fs__open_pack_or_rev_file working on an
existing, initialized FILE structure.  If WRITABLE is TRUE, give write
access to the file - temporarily resetting the r/o state if necessary.
Core implementation of svn_fs_fs__open_pack_or_rev_file working on an existing initialized FILE structure . If WRITABLE is TRUE give write access to the file - temporarily resetting the r / o state if necessary .
static svn_error_t *
open_pack_or_rev_file(svn_fs_fs__revision_file_t *file,
                      svn_fs_t *fs,
                      svn_revnum_t rev,
                      svn_boolean_t writable,
                      apr_pool_t *result_pool,
                      apr_pool_t *scratch_pool)
{
  fs_fs_data_t *ffd = fs->fsap_data;
  svn_error_t *err;
  svn_boolean_t retry = FALSE;
  do
    {
      const char *path = svn_fs_fs__path_rev_absolute(fs, rev, scratch_pool);
      apr_file_t *apr_file;
      apr_int32_t flags = writable
                        ? APR_READ | APR_WRITE | APR_BUFFERED
                        : APR_READ | APR_BUFFERED;
      err = writable ? auto_make_writable(path, result_pool, scratch_pool)
                     : SVN_NO_ERROR;
      if (!err)
        err = svn_io_file_open(&apr_file, path, flags, APR_OS_DEFAULT,
                               result_pool);
      if (!err)
        {
          file->file = apr_file;
          file->stream = svn_stream_from_aprfile2(apr_file, TRUE,
                                                  result_pool);
          file->is_packed = svn_fs_fs__is_packed_rev(fs, rev);
          return SVN_NO_ERROR;
        }
      if (err && APR_STATUS_IS_ENOENT(err->apr_err))
        {
          if (ffd->format >= SVN_FS_FS__MIN_PACKED_FORMAT)
            {
              svn_error_clear(err);
              if (retry)
                return svn_error_createf(SVN_ERR_FS_NO_SUCH_REVISION, NULL,
                                         _("No such revision %ld"), rev);
              SVN_ERR(svn_fs_fs__update_min_unpacked_rev(fs, scratch_pool));
              file->start_revision = svn_fs_fs__packed_base_rev(fs, rev);
              retry = TRUE;
            }
          else
            {
              svn_error_clear(err);
              return svn_error_createf(SVN_ERR_FS_NO_SUCH_REVISION, NULL,
                                       _("No such revision %ld"), rev);
            }
        }
      else
        {
          retry = FALSE;
        }
    }
  while (retry);
  return svn_error_trace(err);
}
static svn_error_t * open_pack_or_rev_file ( svn_fs_fs__revision_file_t * file , svn_fs_t * fs , svn_revnum_t rev , svn_boolean_t writable , apr_pool_t * result_pool , apr_pool_t * scratch_pool ) { fs_fs_data_t * ffd = fs -> fsap_data ; svn_error_t * err ; svn_boolean_t retry = FALSE ; do { const char * path = svn_fs_fs__path_rev_absolute ( fs , rev , scratch_pool ) ; apr_file_t * apr_file ; apr_int32_t flags = writable ? APR_READ | APR_WRITE | APR_BUFFERED : APR_READ | APR_BUFFERED ; err = writable ? auto_make_writable ( path , result_pool , scratch_pool ) : SVN_NO_ERROR ; if ( ! err ) err = svn_io_file_open ( & apr_file , path , flags , APR_OS_DEFAULT , result_pool ) ; if ( ! err ) { file -> file = apr_file ; file -> stream = svn_stream_from_aprfile2 ( apr_file , TRUE , result_pool ) ; file -> is_packed = svn_fs_fs__is_packed_rev ( fs , rev ) ; return SVN_NO_ERROR ; } if ( err && APR_STATUS_IS_ENOENT ( err -> apr_err ) ) { if ( ffd -> format >= SVN_FS_FS__MIN_PACKED_FORMAT ) { svn_error_clear ( err ) ; if ( retry ) return svn_error_createf ( SVN_ERR_FS_NO_SUCH_REVISION , NULL , _ ( " " ) , rev ) ; SVN_ERR ( svn_fs_fs__update_min_unpacked_rev ( fs , scratch_pool ) ) ; file -> start_revision = svn_fs_fs__packed_base_rev ( fs , rev ) ; retry = TRUE ; } else { svn_error_clear ( err ) ; return svn_error_createf ( SVN_ERR_FS_NO_SUCH_REVISION , NULL , _ ( " " ) , rev ) ; } } else { retry = FALSE ; } } while ( retry ) ; return svn_error_trace ( err ) ; }
Core implementation of svn_fs_fs__open_pack_or_rev_file working on an
 existing, initialized FILE structure.
Core implementation of svn_fs_fs__open_pack_or_rev_file working on an existing initialized FILE structure .
/* We may have to *temporarily* enable write access. */ /* open the revision file in buffered r/o or r/w mode */ /* Could not open the file. This may happen if the
               * file once existed but got packed later. */ /* if that was our 2nd attempt, leave it at that. */ /* We failed for the first time. Refresh cache & retry. */