| iMatix home page
| << | < | > | >>
Version 2.11



#include "sfldir.h"
char *
get_curdir (void)


Returns a buffer containing the current working directory. This buffer is allocated using the mem_alloc() function and should be freed using mem_free() when no longer needed. Returns NULL if there was insufficient memory to allocate the buffer, or if the system does not provide the current working directory information. Under Windows, replaces backslash characters by the UNIX-like slash. Under OpenVMS, returns directory name in POSIX format. Note that the directory name always ends in a slash (e.g. 'C:/' or 'C:/subdir/').

Source Code - (sfldir.c)

        *curdir;                        /*  String we get from the OS        */

    curdir = mem_alloc (PATH_MAX + 1);

#if (defined (__UNIX__) || defined (__OS2__))
    getcwd (curdir, PATH_MAX);

#elif (defined (__VMS__))
    getcwd (curdir, PATH_MAX, 0);

#elif (defined (WIN32))
    GetCurrentDirectory (PATH_MAX, curdir);
    strconvch (curdir, '\\', '/');

#elif (defined (MSDOS_FILESYSTEM))
    getcwd (curdir, PATH_MAX);
    strconvch (curdir, '\\', '/');

    strclr (curdir);

    /*  The directory must always end in a slash                             */
    if (strlast (curdir) != '/')
        strcat (curdir, "/");

    return (curdir);

| << | < | > | >> iMatix Copyright © 1996-2000 iMatix Corporation