fnsplit()                Split a Full Path Name into Its Components
 
 #include   <dir.h>
 
 int        fnsplit(path,drive,dir,name,ext);
 char       *path;                       Full name
 char       *drive;                      Drive
 char       *dir;                        Directory/subdirectory
 char       *name;                       File name
 char       *ext;                        File extension
 
    fnsplit() splits 'path' into its four components.  'path' is a string
    in the form:
 
                     X:\DIR\SUBDIR\NAME.EXT
 
    fnsplit() then stores the components in the strings 'drive', 'dir',
    'name', and 'ext'.   The maximum sizes for these strings are given by
    the following constants (defined in <dir.h>):
 
                MAXPATH       80   path
                MAXDRIVE       3   drive (includes colon)
                MAXDIR        66   dir (includes leading and
                                   trailing backslashes)
                MAXFILE        9   name
                MAXEXT         5   ext (includes leading dot)
 
    Each size includes space for the null-terminator.  Each component is
    required but can be NULL.  This means the corresponding component
    will be parsed but not stored.  fnsplit() assumes there is enough
    space to store each non-NULL component.
 
    When fnsplit() splits 'path', it treats the punctuation as follows:
 
                'drive'       keeps the colon attached (A:)
                'dir'         keeps the leading and trailing
                              backslashes (\turboc\lib\)
                'ext'         keeps the dot preceding the extension (.c)
 
    Returns:    An integer composed of five flags (defined in <dir.h>)
                indicating which of the path name components were present
                in 'path'.  The flags and the components they represent
                are:
 
                EXTENSION     an extension
                FILENAME      a filename
                DIRECTORY     a directory (and possibly subdirectories)
                DRIVE         a drive specification
                WILDCARD      wildcards (? or *)

Seealso:



This page last updated on Fri Nov 30 10:48:32 MSK 2001
Copyright © 1992-2001, Vitaly Filatov, Moscow, Russia
Webmaster