2 |
7u83 |
1 |
/*
|
6 |
7u83 |
2 |
* Copyright (c) 2002-2006 The TenDRA Project <http://www.tendra.org/>.
|
|
|
3 |
* All rights reserved.
|
|
|
4 |
*
|
|
|
5 |
* Redistribution and use in source and binary forms, with or without
|
|
|
6 |
* modification, are permitted provided that the following conditions are met:
|
|
|
7 |
*
|
|
|
8 |
* 1. Redistributions of source code must retain the above copyright notice,
|
|
|
9 |
* this list of conditions and the following disclaimer.
|
|
|
10 |
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
|
11 |
* this list of conditions and the following disclaimer in the documentation
|
|
|
12 |
* and/or other materials provided with the distribution.
|
|
|
13 |
* 3. Neither the name of The TenDRA Project nor the names of its contributors
|
|
|
14 |
* may be used to endorse or promote products derived from this software
|
|
|
15 |
* without specific, prior written permission.
|
|
|
16 |
*
|
|
|
17 |
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS
|
|
|
18 |
* IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
|
|
19 |
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
|
20 |
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR
|
|
|
21 |
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
|
|
22 |
* EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
|
|
23 |
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
|
|
24 |
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
|
|
25 |
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
|
|
26 |
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
|
|
27 |
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
28 |
*
|
|
|
29 |
* $Id$
|
|
|
30 |
*/
|
|
|
31 |
/*
|
2 |
7u83 |
32 |
Crown Copyright (c) 1997
|
6 |
7u83 |
33 |
|
2 |
7u83 |
34 |
This TenDRA(r) Computer Program is subject to Copyright
|
|
|
35 |
owned by the United Kingdom Secretary of State for Defence
|
|
|
36 |
acting through the Defence Evaluation and Research Agency
|
|
|
37 |
(DERA). It is made available to Recipients with a
|
|
|
38 |
royalty-free licence for its use, reproduction, transfer
|
|
|
39 |
to other parties and amendment for any purpose not excluding
|
|
|
40 |
product development provided that any such use et cetera
|
|
|
41 |
shall be deemed to be acceptance of the following conditions:-
|
6 |
7u83 |
42 |
|
2 |
7u83 |
43 |
(1) Its Recipients shall ensure that this Notice is
|
|
|
44 |
reproduced upon any copies or amended versions of it;
|
6 |
7u83 |
45 |
|
2 |
7u83 |
46 |
(2) Any amended version of it shall be clearly marked to
|
|
|
47 |
show both the nature of and the organisation responsible
|
|
|
48 |
for the relevant amendment or amendments;
|
6 |
7u83 |
49 |
|
2 |
7u83 |
50 |
(3) Its onward transfer from a recipient to another
|
|
|
51 |
party shall be deemed to be that party's acceptance of
|
|
|
52 |
these conditions;
|
6 |
7u83 |
53 |
|
2 |
7u83 |
54 |
(4) DERA gives no warranty or assurance as to its
|
|
|
55 |
quality or suitability for any purpose and DERA accepts
|
|
|
56 |
no liability whatsoever in relation to any use to which
|
|
|
57 |
it may be put.
|
|
|
58 |
*/
|
|
|
59 |
|
|
|
60 |
|
|
|
61 |
/**** file-name.h --- File name manipulation routines.
|
|
|
62 |
*
|
|
|
63 |
** Author: Steve Folkes <smf@hermes.mod.uk>
|
|
|
64 |
*
|
|
|
65 |
**** Commentary:
|
|
|
66 |
*
|
|
|
67 |
***=== INTRODUCTION =========================================================
|
|
|
68 |
*
|
|
|
69 |
* This file defines some file name manipulation routines. It should be
|
|
|
70 |
* replaced on operating systems with a different file name syntax to that
|
|
|
71 |
* used here ('/' seperated path names).
|
|
|
72 |
*
|
|
|
73 |
***=== FUNCTIONS ============================================================
|
|
|
74 |
*
|
6 |
7u83 |
75 |
** Function: CStringP file_name_basename(CStringP path)
|
2 |
7u83 |
76 |
** Exceptions: XX_dalloc_no_memory
|
|
|
77 |
*
|
|
|
78 |
* This function returns a dynamically allocated copy of the file name
|
|
|
79 |
* component of the specifed path.
|
|
|
80 |
*
|
6 |
7u83 |
81 |
** Function: CStringP file_name_dirname(CStringP path)
|
2 |
7u83 |
82 |
** Exceptions: XX_dalloc_no_memory
|
|
|
83 |
*
|
|
|
84 |
* This function returns a dynamically allocated copy of the directory name
|
|
|
85 |
* component of the specifed path.
|
|
|
86 |
*
|
6 |
7u83 |
87 |
** Function: CStringP file_name_expand(CStringP dir, CStringP name,
|
|
|
88 |
* CStringP suffix)
|
2 |
7u83 |
89 |
** Exceptions: XX_dalloc_no_memory
|
|
|
90 |
*
|
|
|
91 |
* This function returns a dynamically allocated copy of the path name
|
|
|
92 |
* obtained by expanding the specified name in the specified dir. If the
|
|
|
93 |
* suffix is non nil, it is also appended to the path name, following the
|
|
|
94 |
* suffix seperator character.
|
|
|
95 |
*
|
6 |
7u83 |
96 |
** Function: CStringP file_name_is_basename(CStringP path)
|
2 |
7u83 |
97 |
** Exceptions:
|
|
|
98 |
*
|
|
|
99 |
* This function returns true if the specified path has no directory
|
|
|
100 |
* component.
|
|
|
101 |
*
|
6 |
7u83 |
102 |
** Function: CStringP file_name_is_absolute(CStringP path)
|
2 |
7u83 |
103 |
** Exceptions:
|
|
|
104 |
*
|
|
|
105 |
* This function returns true if the specified path is an absolute path name.
|
|
|
106 |
*
|
6 |
7u83 |
107 |
** Function: void file_name_populate(CStringP path)
|
2 |
7u83 |
108 |
** Exceptions:
|
|
|
109 |
*
|
|
|
110 |
* This function tries to create all of the directories on the specified path.
|
|
|
111 |
* The final component of the path is considered to be a file, and is not
|
|
|
112 |
* created as a directory. There is no confirmation of whether the function
|
|
|
113 |
* succeeds or not - this must be determined in another manner.
|
|
|
114 |
*
|
|
|
115 |
**** Change Log:
|
|
|
116 |
* $Log: file-name.h,v $
|
|
|
117 |
* Revision 1.1.1.1 1998/01/17 15:57:18 release
|
|
|
118 |
* First version to be checked into rolling release.
|
|
|
119 |
*
|
|
|
120 |
* Revision 1.2 1994/12/12 11:45:39 smf
|
|
|
121 |
* Performing changes for 'CR94_178.sid+tld-update' - bringing in line with
|
|
|
122 |
* OSSG C Coding Standards.
|
|
|
123 |
*
|
|
|
124 |
* Revision 1.1.1.1 1994/07/25 16:06:14 smf
|
|
|
125 |
* Initial import of os-interface shared files.
|
|
|
126 |
*
|
|
|
127 |
**/
|
|
|
128 |
|
|
|
129 |
/****************************************************************************/
|
|
|
130 |
|
|
|
131 |
#ifndef H_FILE_NAME
|
|
|
132 |
#define H_FILE_NAME
|
|
|
133 |
|
|
|
134 |
#include "os-interface.h"
|
|
|
135 |
#include "dalloc.h"
|
|
|
136 |
|
|
|
137 |
/*--------------------------------------------------------------------------*/
|
|
|
138 |
|
|
|
139 |
extern CStringP file_name_basename
|
6 |
7u83 |
140 |
(CStringP);
|
2 |
7u83 |
141 |
extern CStringP file_name_dirname
|
6 |
7u83 |
142 |
(CStringP);
|
2 |
7u83 |
143 |
extern CStringP file_name_expand
|
6 |
7u83 |
144 |
(CStringP, CStringP, CStringP);
|
2 |
7u83 |
145 |
extern BoolT file_name_is_basename
|
6 |
7u83 |
146 |
(CStringP);
|
2 |
7u83 |
147 |
extern BoolT file_name_is_absolute
|
6 |
7u83 |
148 |
(CStringP);
|
2 |
7u83 |
149 |
extern void file_name_populate
|
6 |
7u83 |
150 |
(CStringP);
|
2 |
7u83 |
151 |
|
|
|
152 |
#endif /* !defined (H_FILE_NAME) */
|