]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | /* |
2 | * Copyright 1993-2002 Christopher Seiwald and Perforce Software, Inc. | |
3 | * | |
4 | * This file is part of Jam - see jam.c for Copyright information. | |
5 | */ | |
6 | ||
20effc67 TL |
7 | /* |
8 | Copyright 2020 René Ferdinand Rivera Morell | |
9 | Distributed under the Boost Software License, Version 1.0. | |
10 | (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt) | |
11 | */ | |
12 | ||
13 | ||
7c673cae FG |
14 | /* |
15 | * pathsys.h - PATHNAME struct | |
16 | */ | |
17 | ||
18 | /* | |
19 | * PATHNAME - a name of a file, broken into <grist>dir/base/suffix(member) | |
20 | * | |
21 | * <grist> - salt to distinguish between targets that would otherwise have the | |
22 | * same name - it never appears in the bound name of a target. | |
23 | * | |
24 | * (member) - archive member name: the syntax is arbitrary, but must agree in | |
20effc67 | 25 | * path_parse(), path_build(). |
7c673cae FG |
26 | */ |
27 | ||
28 | #ifndef PATHSYS_VP_20020211_H | |
29 | #define PATHSYS_VP_20020211_H | |
30 | ||
92f5a8d4 | 31 | #include "config.h" |
7c673cae | 32 | #include "object.h" |
f67539c2 | 33 | #include "jam_strings.h" |
7c673cae | 34 | |
20effc67 TL |
35 | #include <string> |
36 | ||
7c673cae FG |
37 | |
38 | typedef struct _pathpart | |
39 | { | |
40 | char const * ptr; | |
41 | int len; | |
42 | } PATHPART; | |
43 | ||
44 | typedef struct _pathname | |
45 | { | |
46 | PATHPART part[ 6 ]; | |
47 | ||
48 | #define f_grist part[ 0 ] | |
49 | #define f_root part[ 1 ] | |
50 | #define f_dir part[ 2 ] | |
51 | #define f_base part[ 3 ] | |
52 | #define f_suffix part[ 4 ] | |
53 | #define f_member part[ 5 ] | |
54 | } PATHNAME; | |
55 | ||
56 | ||
57 | void path_build( PATHNAME *, string * file ); | |
58 | void path_parse( char const * file, PATHNAME * ); | |
59 | void path_parent( PATHNAME * ); | |
60 | int path_translate_to_os( char const *, string * file ); | |
61 | ||
62 | /* Given a path, returns an object containing an equivalent path in canonical | |
63 | * format that can be used as a unique key for that path. Equivalent paths such | |
64 | * as a/b, A\B, and a\B on NT all yield the same key. | |
65 | */ | |
66 | OBJECT * path_as_key( OBJECT * path ); | |
67 | ||
68 | /* Called as an optimization when we know we have a path that is already in its | |
69 | * canonical/long/key form. Avoids the need for some subsequent path_as_key() | |
70 | * call to do a potentially expensive path conversion requiring access to the | |
71 | * actual underlying file system. | |
72 | */ | |
73 | void path_register_key( OBJECT * canonic_path ); | |
74 | ||
75 | /* Returns a static pointer to the system dependent path to the temporary | |
76 | * directory. NOTE: Does *not* include a trailing path separator. | |
77 | */ | |
78 | string const * path_tmpdir( void ); | |
79 | ||
80 | /* Returns a new temporary name. */ | |
81 | OBJECT * path_tmpnam( void ); | |
82 | ||
83 | /* Returns a new temporary path. */ | |
84 | OBJECT * path_tmpfile( void ); | |
85 | ||
86 | /* Give the first argument to 'main', return a full path to our executable. | |
87 | * Returns null in the unlikely case it cannot be determined. Caller is | |
88 | * responsible for freeing the string. | |
89 | * | |
90 | * Implemented in jam.c | |
91 | */ | |
92 | char * executable_path( char const * argv0 ); | |
93 | ||
94 | void path_done( void ); | |
95 | ||
20effc67 TL |
96 | namespace b2 |
97 | { | |
98 | namespace paths | |
99 | { | |
100 | inline bool is_rooted(const std::string &p) | |
101 | { | |
102 | #if NT | |
103 | return | |
104 | (p.size() >= 1 && (p[0] == '/' || p[0] == '\\')) || | |
105 | (p.size() >= 3 && p[1] == ':' && (p[2] == '/' || p[2] == '\\')); | |
106 | #else | |
107 | return | |
108 | (p.size() >= 1 && (p[0] == '/' || p[0] == '\\')); | |
109 | #endif | |
110 | } | |
111 | std::string normalize(const std::string &p); | |
112 | } | |
113 | } | |
114 | ||
7c673cae | 115 | #endif |