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. */
30 if(*s
== '\\') return FALSE
;
32 /* remove superflous paths (ie paths that are followed by '\') */
33 s1
= strstr(s
, "\\\\");
39 if (s2
[-1] == '\\') break;
43 memmove(s2
,s1
+2,strlen(s1
+1));
46 /* strip trailing slash */
47 len
= strlen(filename
);
48 if (len
&& (filename
[len
-1] == '\\'))
54 /* Validate file name */
55 ULONG
validate(char *filename
)
65 if ((*s
== '/') || (!*s
)) {
66 D(bug("[emul] Bad file name, contains dots-only component\n"));
67 return ERROR_INVALID_COMPONENT_NAME
;
72 D(bug("[emul] Bad file name, contains backslash\n"));
73 return ERROR_INVALID_COMPONENT_NAME
;
76 } while ((*s
!= '/') && *s
);
84 /* Append file name to an existing path */
85 char *append(char *c
, char *filename
)
91 /* We are on Windows, so we have to revert slashes while copying filename */
92 for (s
= filename
; *s
; s
++)
93 *c
++ = (*s
== '/') ? '\\' : *s
;
98 /* Find start position of the file name in path string */
99 long startpos(char *name
, long i
)
101 /* look for the first '\' in the filename starting at the end */
102 while (i
!= 0 && name
[i
] != '\\')
108 /* Copy file name with possible conversion */
109 void copyname(char *result
, char *name
, long i
)
113 /* We want to get AROS filename, so we revert slashes back */
114 for (c
= 0; c
< i
; c
++)
115 result
[c
] = (name
[c
] == '\\') ? '/' : name
[c
];
120 /* Go to next part in path string */
121 char *nextpart(char *sp
)
125 for(sp_end
= sp
+ 1; sp_end
[0] != '\0' && sp_end
[0] != '\\'; sp_end
++);