Imported Upstream version 1.57.0
[platform/upstream/boost.git] / tools / build / src / engine / pathsys.h
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
7 /*
8  * pathsys.h - PATHNAME struct
9  */
10
11 /*
12  * PATHNAME - a name of a file, broken into <grist>dir/base/suffix(member)
13  *
14  * <grist> - salt to distinguish between targets that would otherwise have the
15  * same name - it never appears in the bound name of a target.
16  *
17  * (member) - archive member name: the syntax is arbitrary, but must agree in
18  * path_parse(), path_build() and the Jambase.
19  */
20
21 #ifndef PATHSYS_VP_20020211_H
22 #define PATHSYS_VP_20020211_H
23
24 #include "object.h"
25 #include "strings.h"
26
27
28 typedef struct _pathpart
29 {
30     char const * ptr;
31     int len;
32 } PATHPART;
33
34 typedef struct _pathname
35 {
36     PATHPART part[ 6 ];
37
38 #define f_grist   part[ 0 ]
39 #define f_root    part[ 1 ]
40 #define f_dir     part[ 2 ]
41 #define f_base    part[ 3 ]
42 #define f_suffix  part[ 4 ]
43 #define f_member  part[ 5 ]
44 } PATHNAME;
45
46
47 void path_build( PATHNAME *, string * file );
48 void path_parse( char const * file, PATHNAME * );
49 void path_parent( PATHNAME * );
50
51 /* Given a path, returns an object containing an equivalent path in canonical
52  * format that can be used as a unique key for that path. Equivalent paths such
53  * as a/b, A\B, and a\B on NT all yield the same key.
54  */
55 OBJECT * path_as_key( OBJECT * path );
56
57 /* Called as an optimization when we know we have a path that is already in its
58  * canonical/long/key form. Avoids the need for some subsequent path_as_key()
59  * call to do a potentially expensive path conversion requiring access to the
60  * actual underlying file system.
61  */
62 void path_register_key( OBJECT * canonic_path );
63
64 /* Returns a static pointer to the system dependent path to the temporary
65  * directory. NOTE: Does *not* include a trailing path separator.
66  */
67 string const * path_tmpdir( void );
68
69 /* Returns a new temporary name. */
70 OBJECT * path_tmpnam( void );
71
72 /* Returns a new temporary path. */
73 OBJECT * path_tmpfile( void );
74
75 /* Give the first argument to 'main', return a full path to our executable.
76  * Returns null in the unlikely case it cannot be determined. Caller is
77  * responsible for freeing the string.
78  *
79  * Implemented in jam.c
80  */
81 char * executable_path( char const * argv0 );
82
83 void path_done( void );
84
85 #endif