]> CyberLeo.Net >> Repos - FreeBSD/releng/10.0.git/blob - contrib/subversion/subversion/include/private/svn_fspath.h
- Copy stable/10 (r259064) to releng/10.0 as part of the
[FreeBSD/releng/10.0.git] / contrib / subversion / subversion / include / private / svn_fspath.h
1 /**
2  * @copyright
3  * ====================================================================
4  *    Licensed to the Apache Software Foundation (ASF) under one
5  *    or more contributor license agreements.  See the NOTICE file
6  *    distributed with this work for additional information
7  *    regarding copyright ownership.  The ASF licenses this file
8  *    to you under the Apache License, Version 2.0 (the
9  *    "License"); you may not use this file except in compliance
10  *    with the License.  You may obtain a copy of the License at
11  *
12  *      http://www.apache.org/licenses/LICENSE-2.0
13  *
14  *    Unless required by applicable law or agreed to in writing,
15  *    software distributed under the License is distributed on an
16  *    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17  *    KIND, either express or implied.  See the License for the
18  *    specific language governing permissions and limitations
19  *    under the License.
20  * ====================================================================
21  * @endcopyright
22  *
23  * @file svn_fspath.h
24  * @brief Implementation of path manipulation functions similar to
25  *        those in svn_dirent_uri.h (which see for details) but for
26  *        the private fspath class of paths.
27  */
28
29 #ifndef SVN_FSPATH_H
30 #define SVN_FSPATH_H
31
32 #include <apr.h>
33 #include <apr_pools.h>
34
35 #include "svn_types.h"
36
37 #ifdef __cplusplus
38 extern "C" {
39 #endif /* __cplusplus */
40
41
42 /** Return TRUE iff @a fspath is canonical.
43  * @a fspath need not be canonical, of course.
44  *
45  * @since New in 1.7.
46  */
47 svn_boolean_t
48 svn_fspath__is_canonical(const char *fspath);
49
50
51 /** This function is similar to svn_relpath_canonicalize(), except
52  * that it returns an fspath (which is essentially just a relpath
53  * tacked onto a leading forward slash).
54  *
55  * The returned fspath may be statically allocated or allocated from
56  * @a pool.
57  *
58  * This is similar to svn_fs__canonicalize_abspath() but also treats "."
59  * segments as special.
60  *
61  * @since New in 1.7.
62  */
63 const char *
64 svn_fspath__canonicalize(const char *fspath,
65                          apr_pool_t *pool);
66
67 /** Return the dirname of @a fspath, defined as the path with its basename
68  * removed.  If @a fspath is "/", return "/".
69  *
70  * Allocate the result in @a pool.
71  *
72  * @since New in 1.7.
73  */
74 const char *
75 svn_fspath__dirname(const char *fspath,
76                     apr_pool_t *pool);
77
78 /** Return the last component of @a fspath.  The returned value will have no
79  * slashes in it.  If @a fspath is "/", return "".
80  *
81  * If @a pool is NULL, return a pointer to within @a fspath, else allocate
82  * the result in @a pool.
83  *
84  * @since New in 1.7.
85  */
86 const char *
87 svn_fspath__basename(const char *fspath,
88                      apr_pool_t *pool);
89
90 /** Divide the canonical @a fspath into @a *dirpath and @a
91  * *base_name, allocated in @a pool.
92  *
93  * If @a dirpath or @a base_name is NULL, then don't set that one.
94  *
95  * Either @a dirpath or @a base_name may be @a fspath's own address, but they
96  * may not both be the same address, or the results are undefined.
97  *
98  * If @a fspath has two or more components, the separator between @a dirpath
99  * and @a base_name is not included in either of the new names.
100  *
101  * @since New in 1.7.
102  */
103 void
104 svn_fspath__split(const char **dirpath,
105                   const char **base_name,
106                   const char *fspath,
107                   apr_pool_t *result_pool);
108
109 /** Return the fspath composed of @a fspath with @a relpath appended.
110  * Allocate the result in @a result_pool.
111  *
112  * @since New in 1.7.
113  */
114 char *
115 svn_fspath__join(const char *fspath,
116                  const char *relpath,
117                  apr_pool_t *result_pool);
118
119
120 /** Return TRUE if @a fspath (with length @a len) is the root
121  * directory; return FALSE otherwise.
122  *
123  * @since New in 1.7.
124  */
125 svn_boolean_t
126 svn_fspath__is_root(const char *fspath,
127                     apr_size_t len);
128
129 /** Return the relative path part of @a child_fspath that is below
130  * @a parent_fspath, or just "" if @a parent_fspath is equal to
131  * @a child_fspath. If @a child_fspath is not below @a parent_fspath
132  * or equal to it, return @c NULL.
133  *
134  * @since New in 1.7.
135  */
136 const char *
137 svn_fspath__skip_ancestor(const char *parent_fspath,
138                           const char *child_fspath);
139
140 /** Return the longest common path shared by two fspaths, @a fspath1 and
141  * @a fspath2.  If there's no common ancestor, return "/".
142  *
143  * @since New in 1.7.
144  */
145 char *
146 svn_fspath__get_longest_ancestor(const char *fspath1,
147                                  const char *fspath2,
148                                  apr_pool_t *result_pool);
149
150
151
152 \f
153 /** A faux fspath API used by the DAV modules to help us distinguish
154  * between real URI-decoded fspaths and URI-encoded URL path-portions.
155  */
156 #define svn_urlpath__basename             svn_fspath__basename
157 #define svn_urlpath__dirname              svn_fspath__dirname
158 #define svn_urlpath__get_longest_ancestor svn_fspath__get_longest_ancestor
159 #define svn_urlpath__is_canonical         svn_fspath__is_canonical
160 #define svn_urlpath__is_root              svn_fspath__is_root
161 #define svn_urlpath__join                 svn_fspath__join
162 #define svn_urlpath__skip_ancestor        svn_fspath__skip_ancestor
163 #define svn_urlpath__split                svn_fspath__split
164
165 /* Like svn_fspath__canonicalize(), but this one accepts both full
166    URLs and URL path-portions. */
167 const char *
168 svn_urlpath__canonicalize(const char *uri, apr_pool_t *pool);
169
170
171 #ifdef __cplusplus
172 }
173 #endif /* __cplusplus */
174
175 #endif /* SVN_FSPATH_H */