diff options
Diffstat (limited to 'winsup/cygwin/fhandler_disk_file.cc')
-rw-r--r-- | winsup/cygwin/fhandler_disk_file.cc | 34 |
1 files changed, 15 insertions, 19 deletions
diff --git a/winsup/cygwin/fhandler_disk_file.cc b/winsup/cygwin/fhandler_disk_file.cc index 5b873a045..e687efc63 100644 --- a/winsup/cygwin/fhandler_disk_file.cc +++ b/winsup/cygwin/fhandler_disk_file.cc @@ -593,7 +593,7 @@ fhandler_disk_file::opendir (path_conv& real_name) fd = this; fd->set_nohandle (true); dir->__d_dirent->d_fd = fd; - dir->__d_u.__d_data.__fh = this; + dir->__fh = this; /* FindFirstFile doesn't seem to like duplicate /'s. */ len = strlen (dir->__d_dirname); if (len == 0 || isdirsep (dir->__d_dirname[len - 1])) @@ -601,7 +601,7 @@ fhandler_disk_file::opendir (path_conv& real_name) else strcat (dir->__d_dirname, "\\*"); /**/ dir->__d_cookie = __DIRENT_COOKIE; - dir->__d_u.__d_data.__handle = INVALID_HANDLE_VALUE; + dir->__handle = INVALID_HANDLE_VALUE; dir->__d_position = 0; dir->__d_dirhash = get_namehash (); @@ -622,25 +622,25 @@ fhandler_disk_file::readdir (DIR *dir) HANDLE handle; struct dirent *res = NULL; - if (dir->__d_u.__d_data.__handle == INVALID_HANDLE_VALUE + if (dir->__handle == INVALID_HANDLE_VALUE && dir->__d_position == 0) { handle = FindFirstFileA (dir->__d_dirname, &buf); DWORD lasterr = GetLastError (); - dir->__d_u.__d_data.__handle = handle; + dir->__handle = handle; if (handle == INVALID_HANDLE_VALUE && (lasterr != ERROR_NO_MORE_FILES)) { seterrno_from_win_error (__FILE__, __LINE__, lasterr); return res; } } - else if (dir->__d_u.__d_data.__handle == INVALID_HANDLE_VALUE) + else if (dir->__handle == INVALID_HANDLE_VALUE) return res; - else if (!FindNextFileA (dir->__d_u.__d_data.__handle, &buf)) + else if (!FindNextFileA (dir->__handle, &buf)) { DWORD lasterr = GetLastError (); - (void) FindClose (dir->__d_u.__d_data.__handle); - dir->__d_u.__d_data.__handle = INVALID_HANDLE_VALUE; + (void) FindClose (dir->__handle); + dir->__handle = INVALID_HANDLE_VALUE; /* POSIX says you shouldn't set errno when readdir can't find any more files; so, if another error we leave it set. */ if (lasterr != ERROR_NO_MORE_FILES) @@ -697,10 +697,10 @@ fhandler_disk_file::seekdir (DIR *dir, _off64_t loc) void fhandler_disk_file::rewinddir (DIR *dir) { - if (dir->__d_u.__d_data.__handle != INVALID_HANDLE_VALUE) + if (dir->__handle != INVALID_HANDLE_VALUE) { - (void) FindClose (dir->__d_u.__d_data.__handle); - dir->__d_u.__d_data.__handle = INVALID_HANDLE_VALUE; + (void) FindClose (dir->__handle); + dir->__handle = INVALID_HANDLE_VALUE; } dir->__d_position = 0; } @@ -709,8 +709,8 @@ int fhandler_disk_file::closedir (DIR *dir) { int res = 0; - if (dir->__d_u.__d_data.__handle != INVALID_HANDLE_VALUE && - FindClose (dir->__d_u.__d_data.__handle) == 0) + if (dir->__handle != INVALID_HANDLE_VALUE && + FindClose (dir->__handle) == 0) { __seterrno (); res = -1; @@ -728,14 +728,10 @@ fhandler_cygdrive::fhandler_cygdrive (int unit) : void fhandler_cygdrive::set_drives () { - const int len = 1 + 26 * DRVSZ; - char *p = (char *) crealloc ((void *) win32_path_name, - sizeof (".") + sizeof ("..") + len); + const int len = 2 + 26 * DRVSZ; + char *p = (char *) crealloc ((void *) win32_path_name, len); win32_path_name = pdrive = p; - strcpy (p, "."); - strcpy (p + sizeof ("."), ".."); - p += sizeof (".") + sizeof (".."); ndrives = GetLogicalDriveStrings (len, p) / DRVSZ; } |