| iMatix home page | << | < | > | >> |
SFL Version 2.11 |
#include "sfldir.h" int remove_dir ( const char *path)
remove a directory. Returns 0 if the directory could be removed; -1 if there was an error. Under MS-DOS and OpenVMS accepts a directory name in UNIX format, i.e. containing '/' delimiters. The directory must be empty to be removed.
{ #if (defined (__UNIX__) || defined (__VMS_XOPEN) || defined (__OS2__)) /* Check that directory exists */ if (!file is directory (path)) return (-1); return (rmdir (path)); #elif (defined (MSDOS_FILESYSTEM)) int rc = 0; char *copy_path; /* Check that directory exists */ if (!file is directory (path)) return (-1); copy_path = mem_strdup (path); if (copy_path) { strconvch (copy_path, '/', '\\'); # if (defined (WIN32)) if (RemoveDirectory (copy_path)) rc = 0; else { LPVOID lpMsgBuf; FormatMessage( FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, NULL, GetLastError(), MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language (LPTSTR) &lpMsgBuf, 0, NULL ); coprintf (lpMsgBuf); rc = -1; } # else rc = rmdir (copy_path); # endif mem_strfree (©_path); } return (rc); #else return (-1); #endif }
| << | < | > | >> | Copyright © 1996-2000 iMatix Corporation |