Mercurial > hg > octave-kai > gnulib-hg
annotate lib/mkdir.c @ 7296:33903d90fa2b
(argp_doc): Make sure NULL is not passed to dgettext
author | Sergey Poznyakoff <gray@gnu.org.ua> |
---|---|
date | Tue, 12 Sep 2006 09:06:40 +0000 |
parents | 96c32553b4c6 |
children | 8a1a9361108c |
rev | line source |
---|---|
3479 | 1 /* On some systems, mkdir ("foo/", 0700) fails because of the trailing |
2 slash. On those systems, this wrapper removes the trailing slash. | |
4665 | 3 |
4 Copyright (C) 2001, 2003 Free Software Foundation, Inc. | |
3479 | 5 |
6 This program is free software; you can redistribute it and/or modify | |
7 it under the terms of the GNU General Public License as published by | |
8 the Free Software Foundation; either version 2, or (at your option) | |
9 any later version. | |
10 | |
11 This program is distributed in the hope that it will be useful, | |
12 but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 GNU General Public License for more details. | |
15 | |
16 You should have received a copy of the GNU General Public License | |
17 along with this program; if not, write to the Free Software Foundation, | |
5848
a48fb0e98c8c
*** empty log message ***
Paul Eggert <eggert@cs.ucla.edu>
parents:
4665
diff
changeset
|
18 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ |
3479 | 19 |
20 /* written by Jim Meyering */ | |
21 | |
6259
96c32553b4c6
Use a consistent style for including <config.h>.
Paul Eggert <eggert@cs.ucla.edu>
parents:
5848
diff
changeset
|
22 #ifdef HAVE_CONFIG_H |
96c32553b4c6
Use a consistent style for including <config.h>.
Paul Eggert <eggert@cs.ucla.edu>
parents:
5848
diff
changeset
|
23 # include <config.h> |
96c32553b4c6
Use a consistent style for including <config.h>.
Paul Eggert <eggert@cs.ucla.edu>
parents:
5848
diff
changeset
|
24 #endif |
3479 | 25 |
26 /* Disable the definition of mkdir to rpl_mkdir (from config.h) in this | |
27 file. Otherwise, we'd get conflicting prototypes for rpl_mkdir on | |
28 most systems. */ | |
29 #undef mkdir | |
30 | |
31 #include <sys/types.h> | |
32 #include <sys/stat.h> | |
33 #include <stdio.h> | |
4665 | 34 #include <stdlib.h> |
35 #include <string.h> | |
3479 | 36 |
37 #include "dirname.h" | |
38 #include "xalloc.h" | |
39 | |
40 /* This function is required at least for NetBSD 1.5.2. */ | |
41 | |
42 int | |
43 rpl_mkdir (char const *dir, mode_t mode) | |
44 { | |
45 int ret_val; | |
46 char *tmp_dir; | |
47 size_t len = strlen (dir); | |
48 | |
49 if (len && dir[len - 1] == '/') | |
50 { | |
51 tmp_dir = xstrdup (dir); | |
52 strip_trailing_slashes (tmp_dir); | |
53 } | |
54 else | |
55 { | |
56 tmp_dir = (char *) dir; | |
57 } | |
58 | |
59 ret_val = mkdir (tmp_dir, mode); | |
60 | |
61 if (tmp_dir != dir) | |
62 free (tmp_dir); | |
63 | |
64 return ret_val; | |
65 } |