1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
|
// SPDX-License-Identifier: GPL-2.0-or-later
/** @file
* TODO: insert short description here
*//*
* Authors: see git history
*
* Copyright (C) 2016 Authors
* Released under GNU GPL v2+, read the file 'COPYING' for more information.
*/
#ifndef SEEN_DIR_UTIL_H
#define SEEN_DIR_UTIL_H
/*
* path-util.h
*
* here are functions sp_relative_path & cousins
* maybe they are already implemented in standard libs
*
*/
#include <cstdlib>
#include <string>
/**
* Returns a form of \a path relative to \a base if that is easy to construct (eg if \a path
* appears to be in the directory specified by \a base), otherwise returns \a path.
*
* @param path is expected to be an absolute path.
* @param base is expected to be either empty or the absolute path of a directory.
*
* @return a relative version of the path, if reasonable.
*
* @see inkscape_abs2rel for a more sophisticated version.
* @see prepend_current_dir_if_relative.
*/
std::string sp_relative_path_from_path(std::string const &path, std::string const &base);
char const *sp_extension_from_path(char const *path);
/**
* Convert a relative path name into absolute. If path is already absolute, does nothing except copying path to result.
*
* @param path relative path.
* @param base base directory (must be absolute path).
* @param result result buffer.
* @param size size of result buffer.
*
* @return != NULL: absolute path
* == NULL: error
*
* based on functions by Shigio Yamaguchi.
* FIXME:TODO: force it to also do path normalization of the entire resulting path,
* i.e. get rid of any .. and . in any place, even if 'path' is already absolute
* (now it returns it unchanged in this case)
*
*/
char *inkscape_rel2abs(char const *path, char const *base, char *result, size_t const size);
char *inkscape_abs2rel(char const *path, char const *base, char *result, size_t const size);
char *prepend_current_dir_if_relative(char const *filename);
#endif // !SEEN_DIR_UTIL_H
/*
Local Variables:
mode:c++
c-file-style:"stroustrup"
c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
indent-tabs-mode:nil
fill-column:99
End:
*/
// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
|