2 * Copyright 1993-2002 Christopher Seiwald and Perforce Software, Inc.
4 * This file is part of Jam - see jam.c for Copyright information.
8 * pathsys.h - PATHNAME struct
12 * PATHNAME - a name of a file, broken into <grist>dir/base/suffix(member)
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.
17 * (member) - archive member name: the syntax is arbitrary, but must agree in
18 * path_parse(), path_build() and the Jambase.
21 #ifndef PATHSYS_VP_20020211_H
22 #define PATHSYS_VP_20020211_H
28 typedef struct _pathpart
34 typedef struct _pathname
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 ]
47 void path_build( PATHNAME *, string * file );
48 void path_parse( char const * file, PATHNAME * );
49 void path_parent( PATHNAME * );
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.
55 OBJECT * path_as_key( OBJECT * path );
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.
62 void path_register_key( OBJECT * canonic_path );
64 /* Returns a static pointer to the system dependent path to the temporary
65 * directory. NOTE: Does *not* include a trailing path separator.
67 string const * path_tmpdir( void );
69 /* Returns a new temporary name. */
70 OBJECT * path_tmpnam( void );
72 /* Returns a new temporary path. */
73 OBJECT * path_tmpfile( void );
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.
79 * Implemented in jam.c
81 char * executable_path( char const * argv0 );
83 void path_done( void );