FreeBSD/contrib/subversion/subversion/svnlook/svnlook.c
/* Prepare temporary files *TMPFILE1 and *TMPFILE2 for diffing
   PATH1@ROOT1 versus PATH2@ROOT2.  If either ROOT1 or ROOT2 is NULL,
   the temporary file for its path/root will be an empty one.
   Otherwise, its temporary file will contain the contents of that
   path/root in the repository.

   An exception to this is when either path/root has an svn:mime-type
   property set on it which indicates that the file contains
   non-textual data -- in this case, the *IS_BINARY flag is set and no
   temporary files are created.

   TMPFILE1 and TMPFILE2 will be removed when RESULT_POOL is destroyed.
 */
Prepare temporary files *TMPFILE1 and *TMPFILE2 for diffing
PATH1@ROOT1 versus PATH2@ROOT2.  If either ROOT1 or ROOT2 is NULL,
the temporary file for its path/root will be an empty one.
Otherwise, its temporary file will contain the contents of that
path/root in the repository.

An exception to this is when either path/root has an svn:mime-type
property set on it which indicates that the file contains
non-textual data -- in this case, the *IS_BINARY flag is set and no
temporary files are created.

TMPFILE1 and TMPFILE2 will be removed when RESULT_POOL is destroyed.
Prepare temporary files * TMPFILE1 and * TMPFILE2 for diffing PATH1@ROOT1 versus PATH2@ROOT2 . If either ROOT1 or ROOT2 is NULL the temporary file for its path / root will be an empty one . Otherwise its temporary file will contain the contents of that path / root in the repository . An exception to this is when either path / root has an svn : mime - type property set on it which indicates that the file contains non - textual data -- in this case the * IS_BINARY flag is set and no temporary files are created . TMPFILE1 and TMPFILE2 will be removed when RESULT_POOL is destroyed .
static svn_error_t *
prepare_tmpfiles(const char **tmpfile1,
                 const char **tmpfile2,
                 svn_boolean_t *is_binary,
                 svn_fs_root_t *root1,
                 const char *path1,
                 svn_fs_root_t *root2,
                 const char *path2,
                 apr_pool_t *result_pool,
                 apr_pool_t *scratch_pool)
{
  svn_string_t *mimetype;
  svn_stream_t *stream;
  *tmpfile1 = NULL;
  *tmpfile2 = NULL;
  *is_binary = FALSE;
  assert(path1 && path2);
  if (root1)
    {
      SVN_ERR(svn_fs_node_prop(&mimetype, root1, path1,
                               SVN_PROP_MIME_TYPE, scratch_pool));
      if (mimetype && svn_mime_type_is_binary(mimetype->data))
        {
          *is_binary = TRUE;
          return SVN_NO_ERROR;
        }
    }
  if (root2)
    {
      SVN_ERR(svn_fs_node_prop(&mimetype, root2, path2,
                               SVN_PROP_MIME_TYPE, scratch_pool));
      if (mimetype && svn_mime_type_is_binary(mimetype->data))
        {
          *is_binary = TRUE;
          return SVN_NO_ERROR;
        }
    }
  SVN_ERR(svn_stream_open_unique(&stream, tmpfile1, NULL,
                                 svn_io_file_del_on_pool_cleanup,
                                 result_pool, scratch_pool));
  SVN_ERR(dump_contents(stream, root1, path1, scratch_pool));
  SVN_ERR(svn_stream_open_unique(&stream, tmpfile2, NULL,
                                 svn_io_file_del_on_pool_cleanup,
                                 result_pool, scratch_pool));
  SVN_ERR(dump_contents(stream, root2, path2, scratch_pool));
  return SVN_NO_ERROR;
}
static svn_error_t * prepare_tmpfiles ( const char * * tmpfile1 , const char * * tmpfile2 , svn_boolean_t * is_binary , svn_fs_root_t * root1 , const char * path1 , svn_fs_root_t * root2 , const char * path2 , apr_pool_t * result_pool , apr_pool_t * scratch_pool ) { svn_string_t * mimetype ; svn_stream_t * stream ; * tmpfile1 = NULL ; * tmpfile2 = NULL ; * is_binary = FALSE ; assert ( path1 && path2 ) ; if ( root1 ) { SVN_ERR ( svn_fs_node_prop ( & mimetype , root1 , path1 , SVN_PROP_MIME_TYPE , scratch_pool ) ) ; if ( mimetype && svn_mime_type_is_binary ( mimetype -> data ) ) { * is_binary = TRUE ; return SVN_NO_ERROR ; } } if ( root2 ) { SVN_ERR ( svn_fs_node_prop ( & mimetype , root2 , path2 , SVN_PROP_MIME_TYPE , scratch_pool ) ) ; if ( mimetype && svn_mime_type_is_binary ( mimetype -> data ) ) { * is_binary = TRUE ; return SVN_NO_ERROR ; } } SVN_ERR ( svn_stream_open_unique ( & stream , tmpfile1 , NULL , svn_io_file_del_on_pool_cleanup , result_pool , scratch_pool ) ) ; SVN_ERR ( dump_contents ( stream , root1 , path1 , scratch_pool ) ) ; SVN_ERR ( svn_stream_open_unique ( & stream , tmpfile2 , NULL , svn_io_file_del_on_pool_cleanup , result_pool , scratch_pool ) ) ; SVN_ERR ( dump_contents ( stream , root2 , path2 , scratch_pool ) ) ; return SVN_NO_ERROR ; }
Prepare temporary files *TMPFILE1 and *TMPFILE2 for diffing
PATH1@ROOT1 versus PATH2@ROOT2.
Prepare temporary files * TMPFILE1 and * TMPFILE2 for diffing PATH1@ROOT1 versus PATH2@ROOT2 .
/* Init the return values. */ /* Check for binary mimetypes.  If either file has a binary
     mimetype, get outta here.  */ /* Now, prepare the two temporary files, each of which will either
     be empty, or will have real contents.  */