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 Library Reference - <u>synopsis:</u> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
Synopsis:
    #include <stdlib.h>
    void _splitpath2( const char *inp,
                            char *outp,
                            char **drive,
                            char **dir,
                            char **fname,
                            char **ext );
    void _wsplitpath2( const wchar_t *inp,
                             wchar_t *outp,
                             wchar_t **drive,
                             wchar_t **dir,
                             wchar_t **fname,
                             wchar_t **ext );

Description:
    The _splitpath2 function splits up a full pathname into four components
    consisting of a drive letter, directory path, file name and file name
    extension.

    inp
        The argument inp points to a buffer containing the full pathname to
        be split up.

    outp
        The argument outp points to a buffer that will contain all the
        components of the path, each separated by a null character.  The
        maximum size required for this buffer is specified by the manifest
        constant  _MAX_PATH2 which is defined in <stdlib.h>.

    drive
        The drive argument is the location that is to contain the pointer to
        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 _splitpath2).

    dir
        The dir argument is the location that is to contain the pointer to
        the directory path including the trailing slash if a directory path
        is specified in the full pathname (filled in by _splitpath2).
         Either forward slashes (/) or backslashes (\) may be used.

    fname
        The fname argument is the location that is to contain the pointer to
        the base name of the file without any extension (suffix) if a file
        name is specified in the full pathname (filled in by _splitpath2).

    ext
        The ext argument is the location that is to contain the pointer to
        the filename extension (suffix) including the leading period if an
        extension is specified in the full pathname (filled in by
        _splitpath2).

    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 pointer will be set to point at a NULL string ('\0').

    This function reduces the amount of memory space required when compared
    to the  splitpath function.

    The _wsplitpath2 function is a wide-character version of _splitpath2
    that operates with wide-character strings.

Returns:
    The _splitpath2 function returns no value.

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

    void main()
      {
        char full_path[ _MAX_PATH ];
        char tmp_path[ _MAX_PATH2 ];
        char *drive;
        char *dir;
        char *fname;
        char *ext;

        _makepath(full_path,"c","watcomc\\h","stdio","h");
        printf( "Full path is: %s\n\n", full_path );
        _splitpath2( full_path, tmp_path,
                     &drive, &dir, &fname, &ext );
        printf( "Components after _splitpath2\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 _splitpath2
    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:
     _splitpath2 - All

    _wsplitpath2 - All

See Also:
    _fullpath, _makepath, _splitpath

See Also:

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