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 <direct.h>
    char * _getdcwd( int drive, char *buffer,
                     size_t maxlen );
    wchar_t *_wgetdcwd( int drive, wchar_t *buffer,
                        size_t maxlen );

Description:
    The _getdcwd function returns the name of the current working directory
    on the specified drive.  Drive 0 corresponds to "A:", drive 1
    corresponds to "B:", etc.  The buffer address is either NULL or is the
    location at which a string containing the name of the current working
    directory is placed.  In the latter case, the value of maxlen is the
    length (including the delimiting '\0' character) which can be be used to
    store this name.

    The maximum size that might be required for buffer is  PATH_MAX + 1
    bytes.

    Extension:  When buffer has a value of NULL, a string is allocated using
     malloc to contain the name of the current working directory.  This
    string may be freed using the  free function.  The _wgetdcwd function is
    identical to _getdcwd except that it returns the name of the current
    working directory as a wide-character string (which is twice as long).

Returns:
    The _getdcwd function returns the address of the string containing the
    name of the current working directory, unless an error occurs, in which
    case NULL is returned.

Errors:
    When an error has occurred,  errno contains a value indicating the type
    of error that has been detected.

    Constant     Meaning

EINVAL
    The argument size is negative.

ENOMEM
    Not enough memory to allocate a buffer.

ERANGE
    The buffer is too small (specified by size) to contain the name of the
    current working directory.


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

    void main()
      {
        char *cwd;

        cwd = _getdcwd( 3, NULL, 0 );
        if( cwd != NULL ) {
          printf( "The current directory on drive C is %s\n",
                  cwd );
          free( cwd );
        }
      }

    produces the following:

    The current directory on drive C is C:\PROJECT\C

Classification:
    WATCOM

Systems:
     _getdcwd - DOS, Windows, Win386, Win32, OS/2 1.x(all), OS/2-32

    _wgetdcwd - DOS, Windows, Win386, Win32, OS/2 1.x(all), OS/2-32

See Also:
    chdir, chmod, getcwd, mkdir, rmdir

See Also:

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