1 /* Licensed to the Apache Software Foundation (ASF) under one or more
2 * contributor license agreements. See the NOTICE file distributed with
3 * this work for additional information regarding copyright ownership.
4 * The ASF licenses this file to You under the Apache License, Version 2.0
5 * (the "License"); you may not use this file except in compliance with
6 * the License. You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
18 #include "apr_arch_file_io.h"
19 #include "apr_strings.h"
21 apr_status_t filepath_root_case(char **rootpath, char *root, apr_pool_t *p)
23 /* See the Windows code to figure out what to do here.
24 It probably checks to make sure that the root exists
25 and case it correctly according to the file system.
27 *rootpath = apr_pstrdup(p, root);
31 apr_status_t filepath_has_drive(const char *rootpath, int only, apr_pool_t *p)
36 s = strchr (rootpath, ':');
38 /* Test if the path only has a drive/volume and nothing else
40 return (s && (s != rootpath) && !s[1]);
42 /* Test if the path includes a drive/volume
44 return (s && (s != rootpath));
49 apr_status_t filepath_compare_drive(const char *path1, const char *path2, apr_pool_t *p)
54 s1 = strchr (path1, ':');
55 s2 = strchr (path2, ':');
57 /* Make sure that they both have a drive/volume delimiter
58 and are the same size. Then see if they match.
60 if (s1 && s2 && ((s1-path1) == (s2-path2))) {
61 return strnicmp (s1, s2, s1-path1);
67 APR_DECLARE(apr_status_t) apr_filepath_get(char **rootpath, apr_int32_t flags,
70 char path[APR_PATH_MAX];
73 /* use getcwdpath to make sure that we get the volume name*/
74 if (!getcwdpath(path, NULL, 0)) {
76 return APR_ENAMETOOLONG;
80 /* Strip off the server name if there is one*/
81 ptr = strpbrk(path, "\\/:");
88 *rootpath = apr_pstrdup(p, ptr);
89 if (!(flags & APR_FILEPATH_NATIVE)) {
90 for (ptr = *rootpath; *ptr; ++ptr) {
98 APR_DECLARE(apr_status_t) apr_filepath_set(const char *rootpath,
101 if (chdir2(rootpath) != 0)