]>
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 | ||
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 | int path_translate_to_os( char const *, string * file ); | |
51 | ||
52 | /* Given a path, returns an object containing an equivalent path in canonical | |
53 | * format that can be used as a unique key for that path. Equivalent paths such | |
54 | * as a/b, A\B, and a\B on NT all yield the same key. | |
55 | */ | |
56 | OBJECT * path_as_key( OBJECT * path ); | |
57 | ||
58 | /* Called as an optimization when we know we have a path that is already in its | |
59 | * canonical/long/key form. Avoids the need for some subsequent path_as_key() | |
60 | * call to do a potentially expensive path conversion requiring access to the | |
61 | * actual underlying file system. | |
62 | */ | |
63 | void path_register_key( OBJECT * canonic_path ); | |
64 | ||
65 | /* Returns a static pointer to the system dependent path to the temporary | |
66 | * directory. NOTE: Does *not* include a trailing path separator. | |
67 | */ | |
68 | string const * path_tmpdir( void ); | |
69 | ||
70 | /* Returns a new temporary name. */ | |
71 | OBJECT * path_tmpnam( void ); | |
72 | ||
73 | /* Returns a new temporary path. */ | |
74 | OBJECT * path_tmpfile( void ); | |
75 | ||
76 | /* Give the first argument to 'main', return a full path to our executable. | |
77 | * Returns null in the unlikely case it cannot be determined. Caller is | |
78 | * responsible for freeing the string. | |
79 | * | |
80 | * Implemented in jam.c | |
81 | */ | |
82 | char * executable_path( char const * argv0 ); | |
83 | ||
84 | void path_done( void ); | |
85 | ||
86 | #endif |