Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Turbo C - <b>fnsplit() split a full path name into its components</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
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 *)

See Also: fnmerge()

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson