home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
World of A1200
/
World_Of_A1200.iso
/
programs
/
disk
/
directory
/
browser2.41
/
c
/
basename.c
< prev
next >
Wrap
C/C++ Source or Header
|
1995-02-27
|
970b
|
43 lines
/*
* BaseName.c - Copyright © 1992 by Devil's child.
*
* Created: 11 Sep 1992 18:00:25
* Modified: 16 Mar 1993 23:03:31
*
* Make>> sc <file>.c
* Make>> slink <file>.o SC SD ND BATCH NOICONS TO <file>
*/
long BaseName(void)
{
struct ExecBase *SysBase = *((struct ExecBase **)4L);
struct DosLibrary *DOSBase;
APTR UtilityBase;
struct RDArgs *RA;
char *Argv[] = { NULL, NULL, NULL };
UBYTE *s, *suffix;
long suflen, namelen, rc=20;
if (DOSBase = (struct DosLibrary *)OpenLibrary("dos.library", 37)) {
UtilityBase = DOSBase->dl_UtilityBase;
if (RA = ReadArgs("Path/A,Suffix", (long *)Argv, NULL)) {
s = FilePart(Argv[0]);
if (Argv[1] && (suflen = strlen(Argv[1])) < (namelen = strlen(s))) {
suffix = &s[namelen - suflen];
if (!Stricmp(suffix, Argv[1]))
*suffix = 0;
}
Printf("%s\n", s);
FreeArgs(RA);
rc = 0;
}
else
PrintFault(IoErr(), "BaseName");
CloseLibrary((struct Library *)DOSBase);
}
return rc;
}