| iMatix home page | << | < | > | >> |
![]() Version 1.91 |
#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.
{ 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); }
| << | < | > | >> |
![]() |