Fix for the (stupid) case of app (always) passing
[tangerine.git] / rom / dos / pathpart.c
blob5be6e14a2f2a840ebb570cefb77cd636e2aef521
1 /*
2 Copyright © 1995-2001, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: Return a pointer to after the directories in a path.
6 Lang: English
7 */
8 #ifndef TEST
9 # include "dos_intern.h"
10 #else
11 # define AROS_LH1(t,fn,a1,bt,bn,o,lib) t fn (a1)
12 # define AROS_LHA(t,n,r) t n
13 # define AROS_LIBFUNC_INIT
14 # define AROS_LIBBASE_EXT_DECL(bt,bn)
15 # define AROS_LIBFUNC_EXIT
16 # define CLIB_DOS_PROTOS_H
17 # include <exec/types.h>
18 #endif
20 /*****************************************************************************
22 NAME */
23 #include <proto/dos.h>
25 AROS_LH1(STRPTR, PathPart,
27 /* SYNOPSIS */
28 AROS_LHA(CONST_STRPTR, path, D1),
30 /* LOCATION */
31 struct DosLibrary *, DOSBase, 146, Dos)
33 /* FUNCTION
34 Returns a pointer to the character after the last
35 directory in path (see examples).
37 INPUTS
38 path - Search this path.
40 RESULT
41 A pointer to a character in path.
43 NOTES
45 EXAMPLE
46 PathPart("xxx:yyy/zzz/qqq") would return a pointer to the last '/'.
47 PathPart("xxx:yyy") would return a pointer to the first 'y').
49 BUGS
51 SEE ALSO
53 INTERNALS
55 *****************************************************************************/
57 AROS_LIBFUNC_INIT
58 AROS_LIBBASE_EXT_DECL(struct DosLibrary *,DOSBase)
60 const char *ptr;
62 /* '/' at the begining of the string really is part of the path */
63 while (*path == '/')
65 ++path;
68 ptr = path;
70 while (*ptr)
72 if (*ptr == '/')
74 path = ptr;
76 else if (*ptr == ':')
78 path = ptr + 1;
81 ptr++;
84 return path;
85 AROS_LIBFUNC_EXIT
86 } /* PathPart */
88 #ifdef TEST
90 # include <stdio.h>
92 int main (int argc, char ** argv)
94 UWORD i;
95 STRPTR s,fileptr;
97 while (--argc)
99 s = *++argv;
100 fileptr = PathPart(s);
102 printf("Pfad: %s\nErg.: %s\n", s, fileptr);
106 #endif /* TEST */