summaryrefslogtreecommitdiffstats
path: root/winsup/cygwin/fhandler_disk_file.cc
diff options
context:
space:
mode:
authorChristopher Faylor <me@cgf.cx>2005-08-23 22:22:52 +0000
committerChristopher Faylor <me@cgf.cx>2005-08-23 22:22:52 +0000
commitdb7f135b03afa5f8ee870f87d1727d69dade30ce (patch)
tree17ec52d3aad780d64dac155f9b1a338237f3bb79 /winsup/cygwin/fhandler_disk_file.cc
parent3e4aef50dc96d628dc637693c2546c06e4771be8 (diff)
downloadcygnal-db7f135b03afa5f8ee870f87d1727d69dade30ce.tar.gz
cygnal-db7f135b03afa5f8ee870f87d1727d69dade30ce.tar.bz2
cygnal-db7f135b03afa5f8ee870f87d1727d69dade30ce.zip
* sigproc.h (set_signal_mask): Remove default on second parameter and make pass
by reference. * signal.cc (abort): Accommodate change to set_signal_mask. * select.cc (pselect): Ditto. * exceptions.cc (handle_sigsuspend): Ditto. (ctrl_c_handler): Ditto. (sighold): Ditto. (sigrelse): Ditto. (set_process_mask_delta): Ditto. (_cygtls::call_signal_handler): Ditto. * fhandler_disk_file.cc (fhandler_disk_file::readdir): Return ENMFILE if __handle is not set. Set __handle to NULL when out of files. (fhandler_disk_file::rewinddir): Don't close handle if it's NULL. (fhandler_disk_file::closedir): Ditto.
Diffstat (limited to 'winsup/cygwin/fhandler_disk_file.cc')
-rw-r--r--winsup/cygwin/fhandler_disk_file.cc19
1 files changed, 11 insertions, 8 deletions
diff --git a/winsup/cygwin/fhandler_disk_file.cc b/winsup/cygwin/fhandler_disk_file.cc
index f0d58de73..70939a8aa 100644
--- a/winsup/cygwin/fhandler_disk_file.cc
+++ b/winsup/cygwin/fhandler_disk_file.cc
@@ -1355,6 +1355,11 @@ fhandler_disk_file::readdir (DIR *dir, dirent *de)
HANDLE handle;
int res;
+ if (!dir->__handle)
+ {
+ res = ENMFILE;
+ goto out;
+ }
if (dir->__handle == INVALID_HANDLE_VALUE && dir->__d_position == 0)
{
handle = FindFirstFileA (dir->__d_dirname, &buf);
@@ -1399,11 +1404,8 @@ fhandler_disk_file::readdir (DIR *dir, dirent *de)
else
{
res = geterrno_from_win_error ();
- if (res != ENMFILE)
- {
- FindClose (dir->__handle);
- dir->__handle = INVALID_HANDLE_VALUE;
- }
+ FindClose (dir->__handle);
+ dir->__handle = NULL;
goto out;
}
}
@@ -1469,7 +1471,8 @@ fhandler_disk_file::rewinddir (DIR *dir)
{
if (dir->__handle != INVALID_HANDLE_VALUE)
{
- FindClose (dir->__handle);
+ if (dir->__handle)
+ FindClose (dir->__handle);
dir->__handle = INVALID_HANDLE_VALUE;
}
dir->__d_position = 0;
@@ -1479,8 +1482,8 @@ int
fhandler_disk_file::closedir (DIR *dir)
{
int res = 0;
- if (dir->__handle != INVALID_HANDLE_VALUE &&
- FindClose (dir->__handle) == 0)
+ if (dir->__handle && dir->__handle != INVALID_HANDLE_VALUE
+ && FindClose (dir->__handle) == 0)
{
__seterrno ();
res = -1;