Mercurial > hg > octave-lojdl > gnulib-hg
annotate lib/xconcat-filename.c @ 10391:f0a681493fa6
New module 'xconcat-filename', split off from module 'concat-filename'.
author | Bruno Haible <bruno@clisp.org> |
---|---|
date | Tue, 02 Sep 2008 01:34:21 +0200 |
parents | |
children | e8d2c6fc33ad |
rev | line source |
---|---|
10391
f0a681493fa6
New module 'xconcat-filename', split off from module 'concat-filename'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
1 /* Construct a full filename from a directory and a relative filename. |
f0a681493fa6
New module 'xconcat-filename', split off from module 'concat-filename'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
2 Copyright (C) 2001-2004, 2006-2008 Free Software Foundation, Inc. |
f0a681493fa6
New module 'xconcat-filename', split off from module 'concat-filename'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
3 |
f0a681493fa6
New module 'xconcat-filename', split off from module 'concat-filename'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
4 This program is free software: you can redistribute it and/or modify it |
f0a681493fa6
New module 'xconcat-filename', split off from module 'concat-filename'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
5 under the terms of the GNU General Public License as published by the |
f0a681493fa6
New module 'xconcat-filename', split off from module 'concat-filename'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
6 Free Software Foundation; either version 3 of the License, or any |
f0a681493fa6
New module 'xconcat-filename', split off from module 'concat-filename'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
7 later version. |
f0a681493fa6
New module 'xconcat-filename', split off from module 'concat-filename'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
8 |
f0a681493fa6
New module 'xconcat-filename', split off from module 'concat-filename'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
9 This program is distributed in the hope that it will be useful, |
f0a681493fa6
New module 'xconcat-filename', split off from module 'concat-filename'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
10 but WITHOUT ANY WARRANTY; without even the implied warranty of |
f0a681493fa6
New module 'xconcat-filename', split off from module 'concat-filename'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
f0a681493fa6
New module 'xconcat-filename', split off from module 'concat-filename'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
12 GNU General Public License for more details. |
f0a681493fa6
New module 'xconcat-filename', split off from module 'concat-filename'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
13 |
f0a681493fa6
New module 'xconcat-filename', split off from module 'concat-filename'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
14 You should have received a copy of the GNU General Public License |
f0a681493fa6
New module 'xconcat-filename', split off from module 'concat-filename'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
15 along with this program. If not, see <http://www.gnu.org/licenses/>. */ |
f0a681493fa6
New module 'xconcat-filename', split off from module 'concat-filename'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
16 |
f0a681493fa6
New module 'xconcat-filename', split off from module 'concat-filename'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
17 /* Written by Bruno Haible <haible@clisp.cons.org>. */ |
f0a681493fa6
New module 'xconcat-filename', split off from module 'concat-filename'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
18 |
f0a681493fa6
New module 'xconcat-filename', split off from module 'concat-filename'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
19 #include <config.h> |
f0a681493fa6
New module 'xconcat-filename', split off from module 'concat-filename'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
20 |
f0a681493fa6
New module 'xconcat-filename', split off from module 'concat-filename'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
21 /* Specification. */ |
f0a681493fa6
New module 'xconcat-filename', split off from module 'concat-filename'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
22 #include "concat-filename.h" |
f0a681493fa6
New module 'xconcat-filename', split off from module 'concat-filename'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
23 |
f0a681493fa6
New module 'xconcat-filename', split off from module 'concat-filename'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
24 #include "xalloc.h" |
f0a681493fa6
New module 'xconcat-filename', split off from module 'concat-filename'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
25 |
f0a681493fa6
New module 'xconcat-filename', split off from module 'concat-filename'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
26 /* Concatenate a directory filename, a relative filename and an optional |
f0a681493fa6
New module 'xconcat-filename', split off from module 'concat-filename'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
27 suffix. The directory may end with the directory separator. The second |
f0a681493fa6
New module 'xconcat-filename', split off from module 'concat-filename'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
28 argument may not start with the directory separator (it is relative). |
f0a681493fa6
New module 'xconcat-filename', split off from module 'concat-filename'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
29 Return a freshly allocated filename. */ |
f0a681493fa6
New module 'xconcat-filename', split off from module 'concat-filename'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
30 char * |
f0a681493fa6
New module 'xconcat-filename', split off from module 'concat-filename'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
31 xconcatenated_filename (const char *directory, const char *filename, |
f0a681493fa6
New module 'xconcat-filename', split off from module 'concat-filename'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
32 const char *suffix) |
f0a681493fa6
New module 'xconcat-filename', split off from module 'concat-filename'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
33 { |
f0a681493fa6
New module 'xconcat-filename', split off from module 'concat-filename'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
34 char *result; |
f0a681493fa6
New module 'xconcat-filename', split off from module 'concat-filename'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
35 |
f0a681493fa6
New module 'xconcat-filename', split off from module 'concat-filename'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
36 result = concatenated_filename (directory, filename, suffix); |
f0a681493fa6
New module 'xconcat-filename', split off from module 'concat-filename'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
37 if (result == NULL) |
f0a681493fa6
New module 'xconcat-filename', split off from module 'concat-filename'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
38 xalloc_die (); |
f0a681493fa6
New module 'xconcat-filename', split off from module 'concat-filename'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
39 |
f0a681493fa6
New module 'xconcat-filename', split off from module 'concat-filename'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
40 return result; |
f0a681493fa6
New module 'xconcat-filename', split off from module 'concat-filename'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
41 } |