| iMatix home page
| << | < | > | >>
SFL Logo SFL
Version 1.91

 

get_curdir

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

Synopsis

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.

Source Code - (sfldir.c)

{
    static char
        curdir [PATH_MAX + 1];          /*  String we get from the OS        */
    char
        *allocated;                     /*  Re-allocated string              */

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

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

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

#else
    strclr (curdir);
#endif

    /*  Reallocate buffer using mem_strdup, so that any memory leaks are     */
    /*  correctly traced.                                                    */
    allocated = mem_strdup (curdir);
    return (allocated);
}

| << | < | > | >> iMatix Copyright © 1996-98 iMatix