home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Zodiac Super OZ
/
MEDIADEPOT.ISO
/
FILES
/
16
/
FREEDOS.ZIP
/
FD_A4PRE.ZIP
/
SOURCE
/
MICROC.ZIP
/
FSPLIT.C
< prev
next >
Wrap
Text File
|
1995-05-21
|
1KB
|
67 lines
#define ERROR 0x01
#define EXTENSION 0x02
#define FILENAME 0x04
#define DIRECTORY 0x08
#define DRIVE 0x10
int fnsplit (char *filename, char *drive, char *dir, char *name, char *ext)
{
int i;
char buf[MAX_STR];
strcpy (buf, filename);
if (strchr (buf, ':'))
{
strncpy (drive, buf, 1);
drive[1] = '\0';
strcat (drive, ":");
strcpy (buf, strchr(buf, ':') + 1);
}
else
strcpy (drive, "\0");
if (strchr (buf, '.'))
{
strcpy (ext, strchr (buf, '.'));
buf[strcspn (buf, ".")] = '\0';
}
else
strcpy (ext, "\0");
if ((strchr (buf, '\\')) || (strchr (buf, '/')))
{
strrev (buf);
strcpy (dir, strpbrk (buf, "/\\"));
buf[strcspn (buf, "/\\")] = '\0';
strrev (dir);
strrev (buf);
}
else
strcpy (dir, "\0");
strcpy (name, buf);
return (i);
}
#ifdef TEST
main (int argc, char **argv)
{
char drive[80], path[80], name[80], ext[80];
fnsplit (argv[1], drive, path, name, ext);
printf ("Expanding %s...\n", argv[1]);
printf ("drive = %s %04x %d\n", drive, drive[0], drive[0]);
printf ("path = %s %04x %d\n", path, path[0], path[0]);
printf ("name = %s %04x %d\n", name, name[0], name[0]);
printf ("ext = %s %04x %d\n", ext, ext[0], ext[0]);
}
#endif