Update.
[glibc.git] / db2 / os / db_os_abs.c
blob8795205839e0337f4f5bb04d892d9eb3045b8e40
1 /*-
2 * See the file LICENSE for redistribution information.
4 * Copyright (c) 1997
5 * Sleepycat Software. All rights reserved.
6 */
8 #include "config.h"
10 #ifndef lint
11 static const char sccsid[] = "@(#)db_os_abs.c 10.5 (Sleepycat) 7/5/97";
12 #endif /* not lint */
14 #ifndef NO_SYSTEM_INCLUDES
15 #include <string.h>
16 #endif
18 #include "db_int.h"
19 #include "os_ext.h"
22 * __db_abspath --
23 * Return if a path is an absolute path.
25 * PUBLIC: int __db_abspath __P((const char *));
27 int
28 __db_abspath(path)
29 const char *path;
31 #ifdef _WIN32
33 * !!!
34 * Check for drive specifications, e.g., "C:". In addition, the path
35 * separator used by the win32 DB (PATH_SEPARATOR) is \; look for both
36 * / and \ since these are user-input paths.
38 if (isalpha(path[0]) && path[1] == ':')
39 path += 2;
40 return (path[0] == '/' || path[0] == '\\');
41 #else
42 #ifdef macintosh
44 * !!!
45 * Absolute pathnames always start with a volume name, which must be
46 * followed by a colon, thus they are of the form:
47 * volume: or volume:dir1:dir2:file
49 * Relative pathnames are either a single name without colons or a
50 * path starting with a colon, thus of the form:
51 * file or :file or :dir1:dir2:file
53 return (strchr(path, ':') != NULL && path[0] != ':');
54 #else
55 return (path[0] == '/');
56 #endif
57 #endif
61 * __db_rpath --
62 * Return the last path separator in the path or NULL if none found.
64 * PUBLIC: char *__db_rpath __P((const char *));
66 char *
67 __db_rpath(path)
68 const char *path;
70 const char *s, *last;
72 last = NULL;
73 if (PATH_SEPARATOR[1] != '\0') {
74 for (s = path; s[0] != '\0'; ++s)
75 if (strchr(PATH_SEPARATOR, s[0]) != NULL)
76 last = s;
77 } else
78 for (s = path; s[0] != '\0'; ++s)
79 if (s[0] == PATH_SEPARATOR[0])
80 last = s;
81 return ((char *)last);