I think, the functions rewinddir and closedir have to
be patched as follows:
// If the directory entry search (readdir) is in the middle of the
// directory (dir->num != 0) and it should be closed, then we have
// additionally to check, if there is an open LFN search handle
// and we have to close it before destroying the DIR-structure.
//
// rewinddir has also to be patched, so I decided to apply the
// patch into rewinddir and to use this function in closedir.
#include <dpmi.h>
int
closedir(DIR *dir)
{
rewinddir(dir); // rewinddir includes the test for
// unclosed LFN search handles
free(dir->name);
free(dir);
return 0;
}
void
rewinddir(DIR *dir)
{
__dpmi_regs r;
int use_lfn = _USE_LFN;
if(dir->num_read && use_lfn && (dir->ff.lfn_handle!=0))
{
r.x.bx = dir->ff.lfn_handle;
r.x.ax = 0x71a1;
__dpmi_int(0x21, &r);
}
dir->num_read = 0;
}
Womo.