Subversion
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
svn_path.h
Go to the documentation of this file.
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_path.h
24  * @brief A path manipulation library
25  *
26  * All incoming and outgoing paths are non-NULL and in UTF-8, unless
27  * otherwise documented.
28  *
29  * No result path ever ends with a separator, no matter whether the
30  * path is a file or directory, because we always canonicalize() it.
31  *
32  * Nearly all the @c svn_path_xxx functions expect paths passed into
33  * them to be in canonical form as defined by the Subversion path
34  * library itself. The only functions which do *not* have such
35  * expectations are:
36  *
37  * - @c svn_path_canonicalize()
38  * - @c svn_path_is_canonical()
39  * - @c svn_path_internal_style()
40  * - @c svn_path_uri_encode()
41  *
42  * For the most part, we mean what most anyone would mean when talking
43  * about canonical paths, but to be on the safe side, you must run
44  * your paths through @c svn_path_canonicalize() before passing them to
45  * other functions in this API.
46  */
47 
48 #ifndef SVN_PATH_H
49 #define SVN_PATH_H
50 
51 #include <apr.h>
52 #include <apr_pools.h>
53 #include <apr_tables.h>
54 
55 #include "svn_types.h"
56 #include "svn_string.h"
57 #include "svn_dirent_uri.h"
58 
59 
60 #ifdef __cplusplus
61 extern "C" {
62 #endif /* __cplusplus */
63 
64 
65 
66 /** Convert @a path from the local style to the canonical internal style.
67  *
68  * @deprecated Provided for backward compatibility with the 1.6 API.
69  * New code should use svn_dirent_internal_style().
70  */
72 const char *
73 svn_path_internal_style(const char *path, apr_pool_t *pool);
74 
75 /** Convert @a path from the canonical internal style to the local style.
76  *
77  * @deprecated Provided for backward compatibility with the 1.6 API.
78  * New code should use svn_dirent_local_style().
79  */
81 const char *
82 svn_path_local_style(const char *path, apr_pool_t *pool);
83 
84 
85 /** Join a base path (@a base) with a component (@a component), allocating
86  * the result in @a pool. @a component need not be a single component: it
87  * can be any path, absolute or relative to @a base.
88  *
89  * If either @a base or @a component is the empty path, then the other
90  * argument will be copied and returned. If both are the empty path the
91  * empty path is returned.
92  *
93  * If the @a component is an absolute path, then it is copied and returned.
94  * Exactly one slash character ('/') is used to join the components,
95  * accounting for any trailing slash in @a base.
96  *
97  * Note that the contents of @a base are not examined, so it is possible to
98  * use this function for constructing URLs, or for relative URLs or
99  * repository paths.
100  *
101  * This function is NOT appropriate for native (local) file
102  * paths. Only for "internal" canonicalized paths, since it uses '/'
103  * for the separator. Further, an absolute path (for @a component) is
104  * based on a leading '/' character. Thus, an "absolute URI" for the
105  * @a component won't be detected. An absolute URI can only be used
106  * for the base.
107  *
108  * @deprecated Provided for backward compatibility with the 1.6 API.
109  * New code should use svn_dirent_join(), svn_relpath_join() or
110  * svn_fspath__join().
111  */
113 char *
114 svn_path_join(const char *base, const char *component, apr_pool_t *pool);
115 
116 /** Join multiple components onto a @a base path, allocated in @a pool. The
117  * components are terminated by a @c NULL.
118  *
119  * If any component is the empty string, it will be ignored.
120  *
121  * If any component is an absolute path, then it resets the base and
122  * further components will be appended to it.
123  *
124  * This function does not support URLs.
125  *
126  * See svn_path_join() for further notes about joining paths.
127  *
128  * @deprecated Provided for backward compatibility with the 1.6 API.
129  * For new code, consider using svn_dirent_join_many() or a sequence of
130  * calls to one of the *_join() functions.
131  */
133 char *
134 svn_path_join_many(apr_pool_t *pool, const char *base, ...);
135 
136 
137 /** Get the basename of the specified canonicalized @a path. The
138  * basename is defined as the last component of the path (ignoring any
139  * trailing slashes). If the @a path is root ("/"), then that is
140  * returned. Otherwise, the returned value will have no slashes in
141  * it.
142  *
143  * Example: svn_path_basename("/foo/bar") -> "bar"
144  *
145  * The returned basename will be allocated in @a pool.
146  *
147  * @note If an empty string is passed, then an empty string will be returned.
148  *
149  * @deprecated Provided for backward compatibility with the 1.6 API.
150  * New code should use svn_dirent_basename(), svn_uri_basename(),
151  * svn_relpath_basename() or svn_fspath__basename().
152  */
154 char *
155 svn_path_basename(const char *path, apr_pool_t *pool);
156 
157 /** Get the dirname of the specified canonicalized @a path, defined as
158  * the path with its basename removed. If @a path is root ("/"), it is
159  * returned unchanged.
160  *
161  * The returned dirname will be allocated in @a pool.
162  *
163  * @deprecated Provided for backward compatibility with the 1.6 API.
164  * New code should use svn_dirent_dirname(), svn_uri_dirname(),
165  * svn_relpath_dirname() or svn_fspath__dirname().
166  */
168 char *
169 svn_path_dirname(const char *path, apr_pool_t *pool);
170 
171 /** Split @a path into a root portion and an extension such that
172  * the root + the extension = the original path, and where the
173  * extension contains no period (.) characters. If not @c NULL, set
174  * @a *path_root to the root portion. If not @c NULL, set
175  * @a *path_ext to the extension (or "" if there is no extension
176  * found). Allocate both @a *path_root and @a *path_ext in @a pool.
177  *
178  * @since New in 1.5.
179  */
180 void
181 svn_path_splitext(const char **path_root, const char **path_ext,
182  const char *path, apr_pool_t *pool);
183 
184 /** Return the number of components in the canonicalized @a path.
185  *
186  * @since New in 1.1.
187 */
188 apr_size_t
189 svn_path_component_count(const char *path);
190 
191 /** Add a @a component (a NULL-terminated C-string) to the
192  * canonicalized @a path. @a component is allowed to contain
193  * directory separators.
194  *
195  * If @a path is non-empty, append the appropriate directory separator
196  * character, and then @a component. If @a path is empty, simply set it to
197  * @a component; don't add any separator character.
198  *
199  * If the result ends in a separator character, then remove the separator.
200  */
201 void
202 svn_path_add_component(svn_stringbuf_t *path, const char *component);
203 
204 /** Remove one component off the end of the canonicalized @a path. */
205 void
207 
208 /** Remove @a n components off the end of the canonicalized @a path.
209  * Equivalent to calling svn_path_remove_component() @a n times.
210  *
211  * @since New in 1.1.
212  */
213 void
214 svn_path_remove_components(svn_stringbuf_t *path, apr_size_t n);
215 
216 /** Divide the canonicalized @a path into @a *dirpath and @a
217  * *base_name, allocated in @a pool.
218  *
219  * If @a dirpath or @a base_name is NULL, then don't set that one.
220  *
221  * Either @a dirpath or @a base_name may be @a path's own address, but they
222  * may not both be the same address, or the results are undefined.
223  *
224  * If @a path has two or more components, the separator between @a dirpath
225  * and @a base_name is not included in either of the new names.
226  *
227  * examples:
228  * - <pre>"/foo/bar/baz" ==> "/foo/bar" and "baz"</pre>
229  * - <pre>"/bar" ==> "/" and "bar"</pre>
230  * - <pre>"/" ==> "/" and "/"</pre>
231  * - <pre>"X:/" ==> "X:/" and "X:/"</pre>
232  * - <pre>"bar" ==> "" and "bar"</pre>
233  * - <pre>"" ==> "" and ""</pre>
234  *
235  * @deprecated Provided for backward compatibility with the 1.6 API.
236  * New code should use svn_dirent_split(), svn_uri_split(),
237  * svn_relpath_split() or svn_fspath__split().
238  */
240 void
241 svn_path_split(const char *path,
242  const char **dirpath,
243  const char **base_name,
244  apr_pool_t *pool);
245 
246 
247 /** Return non-zero iff @a path is empty ("") or represents the current
248  * directory -- that is, if prepending it as a component to an existing
249  * path would result in no meaningful change.
250  */
251 int
252 svn_path_is_empty(const char *path);
253 
254 
255 #ifndef SVN_DIRENT_URI_H
256 /* This declaration has been moved to svn_dirent_uri.h, and remains
257  here only for compatibility reasons. */
259 svn_dirent_is_root(const char *dirent, apr_size_t len);
260 #endif /* SVN_DIRENT_URI_H */
261 
262 
263 /** Return a new path (or URL) like @a path, but transformed such that
264  * some types of path specification redundancies are removed.
265  *
266  * This involves collapsing redundant "/./" elements, removing
267  * multiple adjacent separator characters, removing trailing
268  * separator characters, and possibly other semantically inoperative
269  * transformations.
270  *
271  * Convert the scheme and hostname to lowercase (see issue #2475)
272  *
273  * The returned path may be statically allocated, equal to @a path, or
274  * allocated from @a pool.
275  *
276  * @deprecated Provided for backward compatibility with the 1.6 API.
277  * New code should use svn_dirent_canonicalize(), svn_uri_canonicalize(),
278  * svn_relpath_canonicalize() or svn_fspath__canonicalize().
279  */
281 const char *
282 svn_path_canonicalize(const char *path, apr_pool_t *pool);
283 
284 /** Return @c TRUE iff path is canonical. Use @a pool for temporary
285  * allocations.
286  *
287  * @since New in 1.5.
288  * @deprecated Provided for backward compatibility with the 1.6 API.
289  * New code should use svn_dirent_is_canonical(), svn_uri_is_canonical(),
290  * svn_relpath_is_canonical() or svn_fspath__is_canonical().
291  */
294 svn_path_is_canonical(const char *path, apr_pool_t *pool);
295 
296 
297 /** Return an integer greater than, equal to, or less than 0, according
298  * as @a path1 is greater than, equal to, or less than @a path2.
299  *
300  * This function works like strcmp() except that it orders children in
301  * subdirectories directly after their parents. This allows using the
302  * given ordering for a depth first walk.
303  */
304 int
305 svn_path_compare_paths(const char *path1, const char *path2);
306 
307 
308 /** Return the longest common path shared by two canonicalized paths,
309  * @a path1 and @a path2. If there's no common ancestor, return the
310  * empty path.
311  *
312  * @a path1 and @a path2 may be URLs. In order for two URLs to have
313  * a common ancestor, they must (a) have the same protocol (since two URLs
314  * with the same path but different protocols may point at completely
315  * different resources), and (b) share a common ancestor in their path
316  * component, i.e. 'protocol://' is not a sufficient ancestor.
317  *
318  * @deprecated Provided for backward compatibility with the 1.6 API.
319  * New code should use svn_dirent_get_longest_ancestor(),
320  * svn_uri_get_longest_ancestor(), svn_relpath_get_longest_ancestor() or
321  * svn_fspath__get_longest_ancestor().
322  */
324 char *
325 svn_path_get_longest_ancestor(const char *path1,
326  const char *path2,
327  apr_pool_t *pool);
328 
329 /** Convert @a relative canonicalized path to an absolute path and
330  * return the results in @a *pabsolute, allocated in @a pool.
331  *
332  * @a relative may be a URL, in which case no attempt is made to convert it,
333  * and a copy of the URL is returned.
334  *
335  * @deprecated Provided for backward compatibility with the 1.6 API.
336  * New code should use svn_dirent_get_absolute() on a non-URL input.
337  */
339 svn_error_t *
340 svn_path_get_absolute(const char **pabsolute,
341  const char *relative,
342  apr_pool_t *pool);
343 
344 /** Return the path part of the canonicalized @a path in @a
345  * *pdirectory, and the file part in @a *pfile. If @a path is a
346  * directory, set @a *pdirectory to @a path, and @a *pfile to the
347  * empty string. If @a path does not exist it is treated as if it is
348  * a file, since directories do not normally vanish.
349  *
350  * @deprecated Provided for backward compatibility with the 1.6 API.
351  * New code should implement the required logic directly; no direct
352  * replacement is provided.
353  */
355 svn_error_t *
356 svn_path_split_if_file(const char *path,
357  const char **pdirectory,
358  const char **pfile,
359  apr_pool_t *pool);
360 
361 /** Find the common prefix of the canonicalized paths in @a targets
362  * (an array of <tt>const char *</tt>'s), and remove redundant paths if @a
363  * remove_redundancies is TRUE.
364  *
365  * - Set @a *pcommon to the absolute path of the path or URL common to
366  * all of the targets. If the targets have no common prefix, or
367  * are a mix of URLs and local paths, set @a *pcommon to the
368  * empty string.
369  *
370  * - If @a pcondensed_targets is non-NULL, set @a *pcondensed_targets
371  * to an array of targets relative to @a *pcommon, and if
372  * @a remove_redundancies is TRUE, omit any paths/URLs that are
373  * descendants of another path/URL in @a targets. If *pcommon
374  * is empty, @a *pcondensed_targets will contain full URLs and/or
375  * absolute paths; redundancies can still be removed (from both URLs
376  * and paths). If @a pcondensed_targets is NULL, leave it alone.
377  *
378  * Else if there is exactly one target, then
379  *
380  * - Set @a *pcommon to that target, and
381  *
382  * - If @a pcondensed_targets is non-NULL, set @a *pcondensed_targets
383  * to an array containing zero elements. Else if
384  * @a pcondensed_targets is NULL, leave it alone.
385  *
386  * If there are no items in @a targets, set @a *pcommon and (if
387  * applicable) @a *pcondensed_targets to @c NULL.
388  *
389  * @note There is no guarantee that @a *pcommon is within a working
390  * copy.
391  *
392  * @deprecated Provided for backward compatibility with the 1.6 API.
393  * New code should use svn_dirent_condense_targets() or
394  * svn_uri_condense_targets().
395  */
397 svn_error_t *
398 svn_path_condense_targets(const char **pcommon,
399  apr_array_header_t **pcondensed_targets,
400  const apr_array_header_t *targets,
401  svn_boolean_t remove_redundancies,
402  apr_pool_t *pool);
403 
404 
405 /** Copy a list of canonicalized @a targets, one at a time, into @a
406  * pcondensed_targets, omitting any targets that are found earlier in
407  * the list, or whose ancestor is found earlier in the list. Ordering
408  * of targets in the original list is preserved in the condensed list
409  * of targets. Use @a pool for any allocations.
410  *
411  * How does this differ in functionality from svn_path_condense_targets()?
412  *
413  * Here's the short version:
414  *
415  * 1. Disclaimer: if you wish to debate the following, talk to Karl. :-)
416  * Order matters for updates because a multi-arg update is not
417  * atomic, and CVS users are used to, when doing 'cvs up targetA
418  * targetB' seeing targetA get updated, then targetB. I think the
419  * idea is that if you're in a time-sensitive or flaky-network
420  * situation, a user can say, "I really *need* to update
421  * wc/A/D/G/tau, but I might as well update my whole working copy if
422  * I can." So that user will do 'svn up wc/A/D/G/tau wc', and if
423  * something dies in the middles of the 'wc' update, at least the
424  * user has 'tau' up-to-date.
425  *
426  * 2. Also, we have this notion of an anchor and a target for updates
427  * (the anchor is where the update editor is rooted, the target is
428  * the actual thing we want to update). I needed a function that
429  * would NOT screw with my input paths so that I could tell the
430  * difference between someone being in A/D and saying 'svn up G' and
431  * being in A/D/G and saying 'svn up .' -- believe it or not, these
432  * two things don't mean the same thing. svn_path_condense_targets()
433  * plays with absolute paths (which is fine, so does
434  * svn_path_remove_redundancies()), but the difference is that it
435  * actually tweaks those targets to be relative to the "grandfather
436  * path" common to all the targets. Updates don't require a
437  * "grandfather path" at all, and even if it did, the whole
438  * conversion to an absolute path drops the crucial difference
439  * between saying "i'm in foo, update bar" and "i'm in foo/bar,
440  * update '.'"
441  */
442 svn_error_t *
443 svn_path_remove_redundancies(apr_array_header_t **pcondensed_targets,
444  const apr_array_header_t *targets,
445  apr_pool_t *pool);
446 
447 
448 /** Decompose the canonicalized @a path into an array of <tt>const
449  * char *</tt> components, allocated in @a pool. If @a path is
450  * absolute, the first component will be a lone dir separator (the
451  * root directory).
452  */
453 apr_array_header_t *
454 svn_path_decompose(const char *path, apr_pool_t *pool);
455 
456 /** Join an array of <tt>const char *</tt> components into a '/'
457  * separated path, allocated in @a pool. The joined path is absolute if
458  * the first component is a lone dir separator.
459  *
460  * Calling svn_path_compose() on the output of svn_path_decompose()
461  * will return the exact same path.
462  *
463  * @since New in 1.5.
464  */
465 const char *
466 svn_path_compose(const apr_array_header_t *components, apr_pool_t *pool);
467 
468 /** Test that @a name is a single path component, that is:
469  * - not @c NULL or empty.
470  * - not a `/'-separated directory path
471  * - not empty or `..'
472  */
474 svn_path_is_single_path_component(const char *name);
475 
476 
477 /**
478  * Test to see if a backpath, i.e. '..', is present in @a path.
479  * If not, return @c FALSE.
480  * If so, return @c TRUE.
481  *
482  * @since New in 1.1.
483  */
485 svn_path_is_backpath_present(const char *path);
486 
487 
488 /**
489  * Test to see if a dotpath, i.e. '.', is present in @a path.
490  * If not, return @c FALSE.
491  * If so, return @c TRUE.
492  *
493  * @since New in 1.6.
494  */
496 svn_path_is_dotpath_present(const char *path);
497 
498 
499 /** Test if @a path2 is a child of @a path1.
500  * If not, return @c NULL.
501  * If so, return a copy of the remainder path, allocated in @a pool.
502  * (The remainder is the component which, added to @a path1, yields
503  * @a path2. The remainder does not begin with a dir separator.)
504  *
505  * Both paths must be in canonical form, and must either be absolute,
506  * or contain no ".." components.
507  *
508  * If @a path2 is the same as @a path1, it is not considered a child, so the
509  * result is @c NULL; an empty string is never returned.
510  *
511  * @note In 1.5 this function has been extended to allow a @c NULL @a pool
512  * in which case a pointer into @a path2 will be returned to
513  * identify the remainder path.
514  *
515  * @deprecated Provided for backward compatibility with the 1.6 API.
516  * For replacement functionality, see svn_dirent_skip_ancestor(),
517  * svn_dirent_is_child(), svn_uri_skip_ancestor(), and
518  * svn_relpath_skip_ancestor().
519  */
521 const char *
522 svn_path_is_child(const char *path1, const char *path2, apr_pool_t *pool);
523 
524 /** Return TRUE if @a path1 is an ancestor of @a path2 or the paths are equal
525  * and FALSE otherwise.
526  *
527  * @since New in 1.3.
528  *
529  * @deprecated Provided for backward compatibility with the 1.6 API.
530  * For replacement functionality, see svn_dirent_skip_ancestor(),
531  * svn_uri_skip_ancestor(), and svn_relpath_skip_ancestor().
532  */
535 svn_path_is_ancestor(const char *path1, const char *path2);
536 
537 /**
538  * Check whether @a path is a valid Subversion path.
539  *
540  * A valid Subversion pathname is a UTF-8 string without control
541  * characters. "Valid" means Subversion can store the pathname in
542  * a repository. There may be other, OS-specific, limitations on
543  * what paths can be represented in a working copy.
544  *
545  * ASSUMPTION: @a path is a valid UTF-8 string. This function does
546  * not check UTF-8 validity.
547  *
548  * Return @c SVN_NO_ERROR if valid and @c SVN_ERR_FS_PATH_SYNTAX if
549  * invalid.
550  *
551  * @note Despite returning an @c SVN_ERR_FS_* error, this function has
552  * nothing to do with the versioned filesystem's concept of validity.
553  *
554  * @since New in 1.2.
555  */
556 svn_error_t *
557 svn_path_check_valid(const char *path, apr_pool_t *pool);
558 
559 
560 /** URI/URL stuff
561  *
562  * @defgroup svn_path_uri_stuff URI/URL conversion
563  * @{
564  */
565 
566 /** Return TRUE iff @a path looks like a valid absolute URL. */
568 svn_path_is_url(const char *path);
569 
570 /** Return @c TRUE iff @a path is URI-safe, @c FALSE otherwise. */
572 svn_path_is_uri_safe(const char *path);
573 
574 /** Return a URI-encoded copy of @a path, allocated in @a pool. (@a
575  path can be an arbitrary UTF-8 string and does not have to be a
576  canonical path.) */
577 const char *
578 svn_path_uri_encode(const char *path, apr_pool_t *pool);
579 
580 /** Return a URI-decoded copy of @a path, allocated in @a pool. */
581 const char *
582 svn_path_uri_decode(const char *path, apr_pool_t *pool);
583 
584 /** Extend @a url by @a component, URI-encoding that @a component
585  * before adding it to the @a url; return the new @a url, allocated in
586  * @a pool. If @a component is @c NULL, just return a copy of @a url,
587  * allocated in @a pool.
588  *
589  * @a component need not be a single path segment, but if it contains
590  * multiple segments, they must be separated by '/'. @a component
591  * should not begin with '/', however; if it does, the behavior is
592  * undefined.
593  *
594  * @a url must be in canonical format; it may not have a trailing '/'.
595  *
596  * @note To add a component that is already URI-encoded, use
597  * <tt>svn_path_join(url, component, pool)</tt> instead.
598  *
599  * @note gstein suggests this for when @a component begins with '/':
600  *
601  * "replace the path entirely
602  * https://example.com:4444/base/path joined with /leading/slash,
603  * should return: https://example.com:4444/leading/slash
604  * per the RFCs on combining URIs"
605  *
606  * We may implement that someday, which is why leading '/' is
607  * merely undefined right now.
608  *
609  * @since New in 1.6.
610  */
611 const char *
612 svn_path_url_add_component2(const char *url,
613  const char *component,
614  apr_pool_t *pool);
615 
616 /** Like svn_path_url_add_component2(), but allows path components that
617  * end with a trailing '/'
618  *
619  * @deprecated Provided for backward compatibility with the 1.5 API.
620  */
622 const char *
623 svn_path_url_add_component(const char *url,
624  const char *component,
625  apr_pool_t *pool);
626 
627 /**
628  * Convert @a iri (Internationalized URI) to an URI.
629  * The return value may be the same as @a iri if it was already
630  * a URI. Else, allocate the return value in @a pool.
631  *
632  * @since New in 1.1.
633  */
634 const char *
635 svn_path_uri_from_iri(const char *iri, apr_pool_t *pool);
636 
637 /**
638  * URI-encode certain characters in @a uri that are not valid in an URI, but
639  * doesn't have any special meaning in @a uri at their positions. If no
640  * characters need escaping, just return @a uri.
641  *
642  * @note Currently, this function escapes <, >, ", space, {, }, |, \, ^, and `.
643  * This may be extended in the future to do context-dependent escaping.
644  *
645  * @since New in 1.1.
646  */
647 const char *
648 svn_path_uri_autoescape(const char *uri, apr_pool_t *pool);
649 
650 /** @} */
651 
652 /** Charset conversion stuff
653  *
654  * @defgroup svn_path_charset_stuff Charset conversion
655  * @{
656  */
657 
658 /** Convert @a path_utf8 from UTF-8 to the internal encoding used by APR. */
659 svn_error_t *
660 svn_path_cstring_from_utf8(const char **path_apr,
661  const char *path_utf8,
662  apr_pool_t *pool);
663 
664 /** Convert @a path_apr from the internal encoding used by APR to UTF-8. */
665 svn_error_t *
666 svn_path_cstring_to_utf8(const char **path_utf8,
667  const char *path_apr,
668  apr_pool_t *pool);
669 
670 
671 /** @} */
672 
673 
674 /** Repository relative URLs
675  *
676  * @defgroup svn_path_repos_relative_urls Repository relative URLs
677  * @{
678  */
679 
680 /**
681  * Return @c TRUE iff @a path is a repository-relative URL: specifically
682  * that it starts with the characters "^/"
683  *
684  * @a path is in UTF-8 encoding.
685  *
686  * Does not check whether @a path is a properly URI-encoded, canonical, or
687  * valid in any other way.
688  *
689  * @since New in 1.8.
690  */
692 svn_path_is_repos_relative_url(const char *path);
693 
694 /**
695  * Set @a absolute_url to the absolute URL represented by @a relative_url
696  * relative to @a repos_root_url, preserving any peg revision
697  * specifier present in @a relative_url. Allocate @a absolute_url
698  * from @a pool.
699  *
700  * @a relative_url is in repository-relative syntax: "^/[REL-URL][@PEG]"
701  *
702  * @a repos_root_url is the absolute URL of the repository root.
703  *
704  * All strings are in UTF-8 encoding.
705  *
706  * @a repos_root_url and @a relative_url do not have to be properly
707  * URI-encoded, canonical, or valid in any other way. The caller is
708  * expected to perform canonicalization on @a absolute_url after the
709  * call to the function.
710  *
711  * @since New in 1.8.
712  */
713 svn_error_t *
714 svn_path_resolve_repos_relative_url(const char **absolute_url,
715  const char *relative_url,
716  const char *repos_root_url,
717  apr_pool_t *pool);
718 
719 /* Return a copy of @a path, allocated from @a pool, for which control
720  * characters have been escaped using the form \NNN (where NNN is the
721  * octal representation of the byte's ordinal value).
722  *
723  * @since New in 1.8. */
724 const char *
725 svn_path_illegal_path_escape(const char *path, apr_pool_t *pool);
726 
727 /** @} */
728 
729 #ifdef __cplusplus
730 }
731 #endif /* __cplusplus */
732 
733 
734 #endif /* SVN_PATH_H */
const char * svn_path_canonicalize(const char *path, apr_pool_t *pool)
Return a new path (or URL) like path, but transformed such that some types of path specification redu...
svn_error_t * svn_path_cstring_from_utf8(const char **path_apr, const char *path_utf8, apr_pool_t *pool)
Convert path_utf8 from UTF-8 to the internal encoding used by APR.
Counted-length strings for Subversion, plus some C string goodies.
svn_boolean_t svn_path_is_backpath_present(const char *path)
Test to see if a backpath, i.e.
const char * svn_path_compose(const apr_array_header_t *components, apr_pool_t *pool)
Join an array of const char * components into a &#39;/&#39; separated path, allocated in pool.
const char * svn_path_uri_decode(const char *path, apr_pool_t *pool)
Return a URI-decoded copy of path, allocated in pool.
const char * svn_path_url_add_component(const char *url, const char *component, apr_pool_t *pool)
Like svn_path_url_add_component2(), but allows path components that end with a trailing &#39;/&#39;...
const char * svn_path_internal_style(const char *path, apr_pool_t *pool)
Convert path from the local style to the canonical internal style.
char * svn_path_dirname(const char *path, apr_pool_t *pool)
Get the dirname of the specified canonicalized path, defined as the path with its basename removed...
svn_boolean_t svn_path_is_uri_safe(const char *path)
Return TRUE iff path is URI-safe, FALSE otherwise.
svn_error_t * svn_path_condense_targets(const char **pcommon, apr_array_header_t **pcondensed_targets, const apr_array_header_t *targets, svn_boolean_t remove_redundancies, apr_pool_t *pool)
Find the common prefix of the canonicalized paths in targets (an array of const char *&#39;s)...
svn_boolean_t svn_path_is_canonical(const char *path, apr_pool_t *pool)
Return TRUE iff path is canonical.
int svn_path_compare_paths(const char *path1, const char *path2)
Return an integer greater than, equal to, or less than 0, according as path1 is greater than...
char * svn_path_join(const char *base, const char *component, apr_pool_t *pool)
Join a base path (base) with a component (component), allocating the result in pool.
svn_boolean_t svn_path_is_repos_relative_url(const char *path)
Return TRUE iff path is a repository-relative URL: specifically that it starts with the characters &quot;^...
void svn_path_remove_component(svn_stringbuf_t *path)
Remove one component off the end of the canonicalized path.
Subversion error object.
Definition: svn_types.h:113
char * svn_path_basename(const char *path, apr_pool_t *pool)
Get the basename of the specified canonicalized path.
svn_error_t * svn_path_cstring_to_utf8(const char **path_utf8, const char *path_apr, apr_pool_t *pool)
Convert path_apr from the internal encoding used by APR to UTF-8.
void svn_path_remove_components(svn_stringbuf_t *path, apr_size_t n)
Remove n components off the end of the canonicalized path.
svn_boolean_t svn_dirent_is_root(const char *dirent, apr_size_t len)
Return TRUE if dirent is considered a root directory on the platform at hand.
svn_error_t * svn_path_get_absolute(const char **pabsolute, const char *relative, apr_pool_t *pool)
Convert relative canonicalized path to an absolute path and return the results in *pabsolute...
A library to manipulate URIs, relative paths and directory entries.
const char * svn_path_uri_encode(const char *path, apr_pool_t *pool)
Return a URI-encoded copy of path, allocated in pool.
const char * svn_path_is_child(const char *path1, const char *path2, apr_pool_t *pool)
Test if path2 is a child of path1.
Subversion&#39;s data types.
svn_error_t * svn_path_check_valid(const char *path, apr_pool_t *pool)
Check whether path is a valid Subversion path.
apr_array_header_t * svn_path_decompose(const char *path, apr_pool_t *pool)
Decompose the canonicalized path into an array of const char * components, allocated in pool...
#define SVN_DEPRECATED
Macro used to mark deprecated functions.
Definition: svn_types.h:59
svn_boolean_t svn_path_is_url(const char *path)
Return TRUE iff path looks like a valid absolute URL.
void svn_path_split(const char *path, const char **dirpath, const char **base_name, apr_pool_t *pool)
Divide the canonicalized path into *dirpath and *base_name, allocated in pool.
svn_error_t * svn_path_split_if_file(const char *path, const char **pdirectory, const char **pfile, apr_pool_t *pool)
Return the path part of the canonicalized path in *pdirectory, and the file part in *pfile...
const char * svn_path_uri_autoescape(const char *uri, apr_pool_t *pool)
URI-encode certain characters in uri that are not valid in an URI, but doesn&#39;t have any special meani...
const char * svn_path_url_add_component2(const char *url, const char *component, apr_pool_t *pool)
Extend url by component, URI-encoding that component before adding it to the url; return the new url...
svn_boolean_t svn_path_is_dotpath_present(const char *path)
Test to see if a dotpath, i.e.
const char * svn_path_local_style(const char *path, apr_pool_t *pool)
Convert path from the canonical internal style to the local style.
int svn_path_is_empty(const char *path)
Return non-zero iff path is empty (&quot;&quot;) or represents the current directory – that is...
svn_error_t * svn_path_remove_redundancies(apr_array_header_t **pcondensed_targets, const apr_array_header_t *targets, apr_pool_t *pool)
Copy a list of canonicalized targets, one at a time, into pcondensed_targets, omitting any targets th...
svn_boolean_t svn_path_is_single_path_component(const char *name)
Test that name is a single path component, that is:
int svn_boolean_t
YABT: Yet Another Boolean Type.
Definition: svn_types.h:94
apr_size_t svn_path_component_count(const char *path)
Return the number of components in the canonicalized path.
svn_error_t * svn_path_resolve_repos_relative_url(const char **absolute_url, const char *relative_url, const char *repos_root_url, apr_pool_t *pool)
Set absolute_url to the absolute URL represented by relative_url relative to repos_root_url, preserving any peg revision specifier present in relative_url.
void svn_path_splitext(const char **path_root, const char **path_ext, const char *path, apr_pool_t *pool)
Split path into a root portion and an extension such that the root + the extension = the original pat...
char * svn_path_get_longest_ancestor(const char *path1, const char *path2, apr_pool_t *pool)
Return the longest common path shared by two canonicalized paths, path1 and path2.
const char * svn_path_uri_from_iri(const char *iri, apr_pool_t *pool)
Convert iri (Internationalized URI) to an URI.
A buffered string, capable of appending without an allocation and copy for each append.
Definition: svn_string.h:104
void svn_path_add_component(svn_stringbuf_t *path, const char *component)
Add a component (a NULL-terminated C-string) to the canonicalized path.
char * svn_path_join_many(apr_pool_t *pool, const char *base,...)
Join multiple components onto a base path, allocated in pool.
svn_boolean_t svn_path_is_ancestor(const char *path1, const char *path2)
Return TRUE if path1 is an ancestor of path2 or the paths are equal and FALSE otherwise.