home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 10 Tools
/
10-Tools.zip
/
LIBSRC.ZOO
/
libsrc
/
local
/
closedir.c
< prev
next >
Wrap
Text File
|
1992-04-06
|
831b
|
38 lines
#define INCL_DOSFILEMGR
#include <os2.h>
#define __DIRENT_PRIVATE__
#ifdef DEBUG
#include <stdio.h>
#endif
#include <dirent.h>
#include <errno.h>
ULONG Dos32FindClose() asm ("Dos32FindClose");
int closedir(dir)
DIR *dir;
{
ULONG ret;
/* This function frees allocated memory even if it is going to */
/* return an error code (e.g.: if DosFindClose fails). If a */
/* program tries to correct the problem and call closedir() */
/* again, a memory error will result. What is the correct */
/* behavior? */
#ifdef DEBUG
fprintf(stderr, "closedir: calling findclose\n");
#endif
ret = Dos32FindClose(dir->dirhandle);
free(dir->searchname);
free(dir);
if (ret != 0) {
errno = EBADF;
return -1;
} else
return 0;
}