You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by ju...@apache.org on 2011/10/10 11:26:07 UTC
svn commit: r1180839 - in /subversion/branches/tree-read-api/subversion:
include/svn_io.h include/svn_ra.h include/svn_types.h libsvn_ra/ra_loader.c
libsvn_subr/io.c
Author: julianfoad
Date: Mon Oct 10 09:26:07 2011
New Revision: 1180839
URL: http://svn.apache.org/viewvc?rev=1180839&view=rev
Log:
On the 'tree-read-api' branch: Add a 'svn_kind_t' that supports symlink,
and rev two functions to make use of it.
* subversion/include/svn_types.h
(svn_kind_t): New type.
* subversion/include/svn_io.h
(svn_io_check_path2): New function.
* subversion/include/svn_ra.h,
subversion/libsvn_ra/ra_loader.c
(svn_ra_check_path2): New function (not implemented properly).
* subversion/libsvn_subr/io.c
(map_apr_finfo_to_kind, io_check_path2, svn_io_check_path2): New functions.
Modified:
subversion/branches/tree-read-api/subversion/include/svn_io.h
subversion/branches/tree-read-api/subversion/include/svn_ra.h
subversion/branches/tree-read-api/subversion/include/svn_types.h
subversion/branches/tree-read-api/subversion/libsvn_ra/ra_loader.c
subversion/branches/tree-read-api/subversion/libsvn_subr/io.c
Modified: subversion/branches/tree-read-api/subversion/include/svn_io.h
URL: http://svn.apache.org/viewvc/subversion/branches/tree-read-api/subversion/include/svn_io.h?rev=1180839&r1=1180838&r2=1180839&view=diff
==============================================================================
--- subversion/branches/tree-read-api/subversion/include/svn_io.h (original)
+++ subversion/branches/tree-read-api/subversion/include/svn_io.h Mon Oct 10 09:26:07 2011
@@ -155,6 +155,12 @@ svn_io_check_path(const char *path,
svn_node_kind_t *kind,
apr_pool_t *pool);
+/* */
+svn_error_t *
+svn_io_check_path2(const char *path,
+ svn_kind_t *kind,
+ apr_pool_t *pool);
+
/**
* Like svn_io_check_path(), but also set *is_special to @c TRUE if
* the path is not a normal file.
Modified: subversion/branches/tree-read-api/subversion/include/svn_ra.h
URL: http://svn.apache.org/viewvc/subversion/branches/tree-read-api/subversion/include/svn_ra.h?rev=1180839&r1=1180838&r2=1180839&view=diff
==============================================================================
--- subversion/branches/tree-read-api/subversion/include/svn_ra.h (original)
+++ subversion/branches/tree-read-api/subversion/include/svn_ra.h Mon Oct 10 09:26:07 2011
@@ -1481,6 +1481,15 @@ svn_ra_get_log(svn_ra_session_t *session
void *receiver_baton,
apr_pool_t *pool);
+/* Like svn_ra_check_path() but returning svn_kind_t (includes symlink kind).
+ * @since New in 1.8.
+ */
+svn_error_t *
+svn_ra_check_path2(svn_ra_session_t *session,
+ const char *path,
+ svn_revnum_t revision,
+ svn_kind_t *kind,
+ apr_pool_t *scratch_pool);
/**
* Set @a *kind to the node kind associated with @a path at @a revision.
* If @a path does not exist under @a revision, set @a *kind to
Modified: subversion/branches/tree-read-api/subversion/include/svn_types.h
URL: http://svn.apache.org/viewvc/subversion/branches/tree-read-api/subversion/include/svn_types.h?rev=1180839&r1=1180838&r2=1180839&view=diff
==============================================================================
--- subversion/branches/tree-read-api/subversion/include/svn_types.h (original)
+++ subversion/branches/tree-read-api/subversion/include/svn_types.h Mon Oct 10 09:26:07 2011
@@ -204,6 +204,28 @@ typedef enum svn_node_kind_t
svn_node_unknown
} svn_node_kind_t;
+/* A node kind.
+ *
+ * @since New in 1.8. Replaces svn_node_kind_t.
+ */
+typedef enum svn_kind_t
+{
+ /** absent */
+ svn_kind_none,
+
+ /** regular file */
+ svn_kind_file,
+
+ /** directory */
+ svn_kind_dir,
+
+ /** symbolic link */
+ svn_kind_symlink,
+
+ /** something's here, but we don't know what */
+ svn_kind_unknown
+} svn_kind_t;
+
/** Return a constant string expressing @a kind as an English word, e.g.,
* "file", "dir", etc. The string is not localized, as it may be used for
* client<->server communications. If the kind is not recognized, return
Modified: subversion/branches/tree-read-api/subversion/libsvn_ra/ra_loader.c
URL: http://svn.apache.org/viewvc/subversion/branches/tree-read-api/subversion/libsvn_ra/ra_loader.c?rev=1180839&r1=1180838&r2=1180839&view=diff
==============================================================================
--- subversion/branches/tree-read-api/subversion/libsvn_ra/ra_loader.c (original)
+++ subversion/branches/tree-read-api/subversion/libsvn_ra/ra_loader.c Mon Oct 10 09:26:07 2011
@@ -902,6 +902,38 @@ svn_error_t *svn_ra_get_log2(svn_ra_sess
receiver, receiver_baton, pool);
}
+svn_error_t *
+svn_ra_check_path2(svn_ra_session_t *session,
+ const char *path,
+ svn_revnum_t revision,
+ svn_kind_t *kind,
+ apr_pool_t *scratch_pool)
+{
+ svn_node_kind_t node_kind;
+
+ SVN_ERR(svn_ra_check_path(session, path, revision,
+ &node_kind, scratch_pool));
+ switch (node_kind)
+ {
+ case svn_node_file:
+ if (FALSE /* ### special */)
+ *kind = svn_kind_symlink;
+ else
+ *kind = svn_kind_file;
+ break;
+ case svn_node_dir:
+ *kind = svn_kind_dir;
+ break;
+ case svn_node_none:
+ *kind = svn_kind_none;
+ break;
+ case svn_node_unknown:
+ *kind = svn_kind_unknown;
+ break;
+ }
+ return SVN_NO_ERROR;
+}
+
svn_error_t *svn_ra_check_path(svn_ra_session_t *session,
const char *path,
svn_revnum_t revision,
Modified: subversion/branches/tree-read-api/subversion/libsvn_subr/io.c
URL: http://svn.apache.org/viewvc/subversion/branches/tree-read-api/subversion/libsvn_subr/io.c?rev=1180839&r1=1180838&r2=1180839&view=diff
==============================================================================
--- subversion/branches/tree-read-api/subversion/libsvn_subr/io.c (original)
+++ subversion/branches/tree-read-api/subversion/libsvn_subr/io.c Mon Oct 10 09:26:07 2011
@@ -226,6 +226,20 @@ map_apr_finfo_to_node_kind(svn_node_kind
*kind = svn_node_unknown;
}
+static void
+map_apr_finfo_to_kind(svn_kind_t *kind,
+ apr_finfo_t *finfo)
+{
+ if (finfo->filetype == APR_REG)
+ *kind = svn_kind_file;
+ else if (finfo->filetype == APR_DIR)
+ *kind = svn_kind_dir;
+ else if (finfo->filetype == APR_LNK)
+ *kind = svn_kind_symlink;
+ else
+ *kind = svn_kind_unknown;
+}
+
/* Helper for svn_io_check_path() and svn_io_check_resolved_path();
essentially the same semantics as those two, with the obvious
interpretation for RESOLVE_SYMLINKS. */
@@ -267,6 +281,43 @@ io_check_path(const char *path,
return SVN_NO_ERROR;
}
+/* Helper for svn_io_check_path() and svn_io_check_resolved_path();
+ essentially the same semantics as those two, with the obvious
+ interpretation for RESOLVE_SYMLINKS. */
+static svn_error_t *
+io_check_path2(const char *path,
+ svn_boolean_t resolve_symlinks,
+ svn_kind_t *kind,
+ apr_pool_t *pool)
+{
+ apr_int32_t flags;
+ apr_finfo_t finfo;
+ apr_status_t apr_err;
+ const char *path_apr;
+
+ if (path[0] == '\0')
+ path = ".";
+
+ /* Not using svn_io_stat() here because we want to check the
+ apr_err return explicitly. */
+ SVN_ERR(cstring_from_utf8(&path_apr, path, pool));
+
+ flags = resolve_symlinks ? APR_FINFO_MIN : (APR_FINFO_MIN | APR_FINFO_LINK);
+ apr_err = apr_stat(&finfo, path_apr, flags, pool);
+
+ if (APR_STATUS_IS_ENOENT(apr_err))
+ *kind = svn_node_none;
+ else if (SVN__APR_STATUS_IS_ENOTDIR(apr_err))
+ *kind = svn_node_none;
+ else if (apr_err)
+ return svn_error_wrap_apr(apr_err, _("Can't check path '%s'"),
+ svn_dirent_local_style(path, pool));
+ else
+ map_apr_finfo_to_kind(kind, &finfo);
+
+ return SVN_NO_ERROR;
+}
+
/* Wrapper for apr_file_open(), taking an APR-encoded filename. */
static apr_status_t
@@ -306,6 +357,14 @@ svn_io_check_path(const char *path,
}
svn_error_t *
+svn_io_check_path2(const char *path,
+ svn_kind_t *kind,
+ apr_pool_t *pool)
+{
+ return io_check_path2(path, FALSE, kind, pool);
+}
+
+svn_error_t *
svn_io_check_special_path(const char *path,
svn_node_kind_t *kind,
svn_boolean_t *is_special,