2 Copyright © 1995-2008, The AROS Development Team. All rights reserved.
5 Returns a pointer to the first char of the filename in the give file part.
8 # include "dos_intern.h"
10 # define AROS_LH1(t,fn,a1,bt,bn,o,lib) t fn (a1)
11 # define AROS_LHA(t,n,r) t n
12 # define AROS_LIBFUNC_INIT
13 # define AROS_LIBFUNC_EXIT
14 # include <exec/types.h>
15 # define CLIB_DOS_PROTOS_H
20 /*****************************************************************************
23 #include <proto/dos.h>
25 AROS_LH1(STRPTR
, FilePart
,
28 AROS_LHA(CONST_STRPTR
, path
, D1
),
31 struct DosLibrary
*, DOSBase
, 145, Dos
)
34 Get a pointer to the last component of a path, which is normally the
38 path - pointer AmigaDOS path string
39 May be relative to the current directory or the current disk.
42 A pointer to the first char of the filename!
47 FilePart("xxx:yyy/zzz/qqq") returns a pointer to the first 'q'.
48 FilePart("xxx:yyy") returns a pointer to the first 'y'.
49 FilePart("yyy") returns a pointer to the first 'y'.
58 Goes from the last char of the pathname back until it finds a ':',
59 a '/' or until the first char reached.
61 *****************************************************************************/
69 /* set i to last char of path */
71 if (!*path
) /* path == "" ? */
74 i
= path
+ strlen (path
) -1; /* set i to the \0-byte */
76 /* decrease pointer as long as there is no ':', no '/' or till
77 the first char anyway. hope this works in all situations */
78 while ((*i
!= ':') && (*i
!= '/') && (i
!= path
))
87 return NULL
; /* if no path is given, return NULL pointer (shouldn't happen) */
96 int main (int argc
, char ** argv
)
99 CONST_STRPTR s
, fileptr
;
104 fileptr
= FilePart(s
);
106 printf("Pfad: %s\nDatei: %s\n", s
, fileptr
);