Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Watcom C/C++ v10.0 : C library - <b>synopsis:</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
Synopsis:
    #include <stdlib.h>
    void _splitpath( const char *path,
                           char *drive,
                           char *dir,
                           char *fname,
                           char *ext );

Description:
    The _splitpath function splits up a full pathname into four components
    consisting of a drive letter, directory path, file name and file name
    extension.  The argument path points to a buffer containing the full
    pathname to be split up.

    The maximum size required for each buffer is specified by the manifest
    constants  _MAX_PATH,  _MAX_DRIVE,  _MAX_DIR,  _MAX_FNAME, and  _MAX_EXT
    which are defined in <stdlib.h>.

    drive
        The drive argument points to a buffer that will be filled in with
        the drive letter (e.g., A, B, C, etc.) followed by a colon if a
        drive is specified in the full pathname (filled in by _splitpath).

    dir
        The dir argument points to a buffer that will be filled in with the
        pathname including the trailing slash.  Either forward slashes (/)
        or backslashes (\) may be used.

    fname
        The fname argument points to a buffer that will be filled in with
        the base name of the file without any extension (suffix) if a file
        name is specified in the full pathname (filled in by _splitpath).

    ext
        The ext argument points to a buffer that will be filled in with the
        filename extension (suffix) including the leading period if an
        extension is specified in the full pathname (filled in by
        _splitpath).

    The arguments drive, dir, fname and ext will not be filled in if they
    are NULL pointers.

    For each component of the full pathname that is not present, its
    corresponding buffer will be set to an empty string.

Returns:
    The _splitpath function returns no value.

See Also:
    _fullpath, _makepath, _splitpath2

Example:
    #include <stdio.h>
    #include <stdlib.h>

    void main()
      {
        char full_path[ _MAX_PATH ];
        char drive[ _MAX_DRIVE ];
        char dir[ _MAX_DIR ];
        char fname[ _MAX_FNAME ];
        char ext[ _MAX_EXT ];

        _makepath(full_path,"c","watcomc\\h\\","stdio","h");
        printf( "Full path is: %s\n\n", full_path );
        _splitpath( full_path, drive, dir, fname, ext );
        printf( "Components after _splitpath\n" );
        printf( "drive: %s\n", drive );
        printf( "dir:   %s\n", dir );
        printf( "fname: %s\n", fname );
        printf( "ext:   %s\n", ext );
      }

    produces the following:

    Full path is: c:watcomc\h\stdio.h

    Components after _splitpath
    drive: c:
    dir:   watcomc\h\
    fname: stdio
    ext:   .h

    Note the use of two adjacent backslash characters (\) within
    character-string constants to signify a single backslash.

Classification:
    WATCOM

Systems:
    All

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