2 Copyright © 1995-2014, The AROS Development Team. All rights reserved.
6 #include <aros/debug.h>
11 /*********************************************************************************************/
14 * Create a plain path out of the supplied filename.
15 * Eg 'path1/path2//path3/' becomes 'path1/path3'.
17 BOOL
shrink(char *filename
)
22 /* We skip the first slash because it separates volume root prefix and the actual pathname */
29 /* leading slashes? --> return FALSE. */
33 /* remove superflous paths (ie paths that are followed by '//') */
45 memmove(s2
, s1
+2, strlen(s1
+1));
48 /* strip trailing slash */
50 if (len
&& filename
[len
-1]=='/')
56 /* Validate file name */
57 ULONG
validate(char *filename
)
67 if ((*s
== '/') || (!*s
)) {
68 D(bug("[emul] Bad file name, contains dots-only component\n"));
69 return ERROR_INVALID_COMPONENT_NAME
;
74 } while ((*s
!= '/') && *s
);
82 /* Append file name to an existing path */
83 char *append(char *c
, char *filename
)
88 for (s
= filename
; *s
; s
++)
93 /* Find start position of the file name in path string */
94 long startpos(char *name
, long i
)
96 /* look for the first '/' in the filename starting at the end */
97 while (i
!= 0 && name
[i
] != '/')
103 /* Copy file name with possible conversion */
104 void copyname(char *result
, char *name
, long i
)
106 strncpy(result
, name
, i
);
109 /* Go to next part in path string */
110 char *nextpart(char *sp
)
114 for(sp_end
= sp
+ 1; sp_end
[0] != '\0' && sp_end
[0] != '/'; sp_end
++);