Alien-SVN
view release on metacpan or search on metacpan
src/subversion/subversion/libsvn_client/patch.c view on Meta::CPAN
numbytes = 1;
}
}
}
else
{
if (str == NULL)
str = svn_stringbuf_create_ensure(80, result_pool);
svn_stringbuf_appendbyte(str, c);
}
if (*eol_str)
break;
}
if (eof)
*eof = found_eof;
*line = str;
return SVN_NO_ERROR;
}
/* Return in *OFFSET the current byte offset for reading from the
* unpatched file content accessed via BATON.
* Use SCRATCH_POOL for temporary allocations. */
static svn_error_t *
tell_file(void *baton, apr_off_t *offset, apr_pool_t *scratch_pool)
{
apr_file_t *file = (apr_file_t *)baton;
*offset = 0;
SVN_ERR(svn_io_file_seek(file, APR_CUR, offset, scratch_pool));
return SVN_NO_ERROR;
}
/* Seek to the specified by OFFSET in the unpatched file content accessed
* via BATON. Use SCRATCH_POOL for temporary allocations. */
static svn_error_t *
seek_file(void *baton, apr_off_t offset, apr_pool_t *scratch_pool)
{
apr_file_t *file = (apr_file_t *)baton;
SVN_ERR(svn_io_file_seek(file, APR_SET, &offset, scratch_pool));
return SVN_NO_ERROR;
}
/* Write LEN bytes from BUF into the patched file content accessed
* via BATON. Use SCRATCH_POOL for temporary allocations. */
static svn_error_t *
write_file(void *baton, const char *buf, apr_size_t len,
apr_pool_t *scratch_pool)
{
apr_file_t *file = (apr_file_t *)baton;
SVN_ERR(svn_io_file_write_full(file, buf, len, &len, scratch_pool));
return SVN_NO_ERROR;
}
/* Handling symbolic links:
*
* In Subversion, symlinks can be represented on disk in two distinct ways.
* On systems which support symlinks, a symlink is created on disk.
* On systems which do not support symlink, a file is created on disk
* which contains the "normal form" of the symlink, which looks like:
* link TARGET
* where TARGET is the file the symlink points to.
*
* When reading symlinks (i.e. the link itself, not the file the symlink
* is pointing to) through the svn_subst_create_specialfile() function
* into a buffer, the buffer always contains the "normal form" of the symlink.
* Due to this representation symlinks always contain a single line of text.
*
* The functions below are needed to deal with the case where a patch
* wants to change the TARGET that a symlink points to.
*/
/* Baton for the (readline|tell|seek|write)_symlink functions. */
struct symlink_baton_t
{
/* The path to the symlink on disk (not the path to the target of the link) */
const char *local_abspath;
/* Indicates whether the "normal form" of the symlink has been read. */
svn_boolean_t at_eof;
};
/* Allocate *STRINGBUF in RESULT_POOL, and store into it the "normal form"
* of the symlink accessed via BATON.
*
* Otherwise behaves like readline_file(), which see.
*/
static svn_error_t *
readline_symlink(void *baton, svn_stringbuf_t **line, const char **eol_str,
svn_boolean_t *eof, apr_pool_t *result_pool,
apr_pool_t *scratch_pool)
{
struct symlink_baton_t *sb = baton;
if (eof)
*eof = TRUE;
if (eol_str)
*eol_str = NULL;
if (sb->at_eof)
{
*line = NULL;
}
else
{
svn_string_t *dest;
SVN_ERR(svn_io_read_link(&dest, sb->local_abspath, scratch_pool));
*line = svn_stringbuf_createf(result_pool, "link %s", dest->data);
sb->at_eof = TRUE;
}
return SVN_NO_ERROR;
}
/* Set *OFFSET to 1 or 0 depending on whether the "normal form" of
* the symlink has already been read. */
static svn_error_t *
tell_symlink(void *baton, apr_off_t *offset, apr_pool_t *scratch_pool)
{
( run in 0.786 second using v1.01-cache-2.11-cpan-cdf2f3d4e48 )