1 #if !defined(lint) && !defined(DOS)
2 static char rcsid
[] = "$Id: lstcmpnt.c 1074 2008-06-04 00:08:43Z hubert@u.washington.edu $";
6 * ========================================================================
7 * Copyright 2006-2008 University of Washington
8 * Copyright 2013-2021 Eduardo Chappa
10 * Licensed under the Apache License, Version 2.0 (the "License");
11 * you may not use this file except in compliance with the License.
12 * You may obtain a copy of the License at
14 * http://www.apache.org/licenses/LICENSE-2.0
16 * ========================================================================
23 #include "../../pith/charconv/filesys.h"
24 #include "canaccess.h"
40 /*----------------------------------------------------------------------
41 Return pointer to last component of pathname.
43 Args: filename -- The pathname.
45 Result: Returned pointer points to last component in the input argument.
48 last_cmpnt(char *filename
)
50 char *p
= NULL
, *q
= filename
;
55 while((q
= strchr(q
, FILE_SEP
)) != NULL
)
61 if(!p
&& isalpha((unsigned char) *filename
) && *(filename
+1) == ':' && *(filename
+2))
71 * Like our_mkdir but it makes subdirs as well as the final dir
74 our_mkpath(char *path
, mode_t mode
)
79 if(isalpha((unsigned char) q
[0]) && q
[1] == ':' && q
[2])
83 if(q
== path
&& q
[0] == FILE_SEP
)
86 while((q
= strchr(q
, FILE_SEP
)) != NULL
){
89 if(can_access(path
, ACCESS_EXISTS
) != 0)
90 if(our_mkdir(path
, mode
) != 0){
99 if(can_access(path
, ACCESS_EXISTS
) != 0 && our_mkdir(path
, mode
) != 0)