1153 (dirp->path[2] == '\0' ||
1154 (dirp->path[2] == '\\' && dirp->path[3] == '\0'))) {
1155 // No '\\' needed for cases like "Z:" or "Z:\"
1156 strcat(dirp->path, "*.*");
1157 } else {
1158 strcat(dirp->path, "\\*.*");
1159 }
1160
1161 dirp->handle = FindFirstFile(dirp->path, &dirp->find_data);
1162 if (dirp->handle == INVALID_HANDLE_VALUE) {
1163 if (GetLastError() != ERROR_FILE_NOT_FOUND) {
1164 free(dirp->path);
1165 free(dirp);
1166 errno = EACCES;
1167 return 0;
1168 }
1169 }
1170 return dirp;
1171 }
1172
1173 // parameter dbuf unused on Windows
1174 struct dirent * os::readdir(DIR *dirp, dirent *dbuf) {
1175 assert(dirp != NULL, "just checking"); // hotspot change
1176 if (dirp->handle == INVALID_HANDLE_VALUE) {
1177 return 0;
1178 }
1179
1180 strcpy(dirp->dirent.d_name, dirp->find_data.cFileName);
1181
1182 if (!FindNextFile(dirp->handle, &dirp->find_data)) {
1183 if (GetLastError() == ERROR_INVALID_HANDLE) {
1184 errno = EBADF;
1185 return 0;
1186 }
1187 FindClose(dirp->handle);
1188 dirp->handle = INVALID_HANDLE_VALUE;
1189 }
1190
1191 return &dirp->dirent;
1192 }
1193
1194 int os::closedir(DIR *dirp) {
1195 assert(dirp != NULL, "just checking"); // hotspot change
1196 if (dirp->handle != INVALID_HANDLE_VALUE) {
1197 if (!FindClose(dirp->handle)) {
1198 errno = EBADF;
1199 return -1;
1200 }
1201 dirp->handle = INVALID_HANDLE_VALUE;
1202 }
1203 free(dirp->path);
1204 free(dirp);
1205 return 0;
|
1153 (dirp->path[2] == '\0' ||
1154 (dirp->path[2] == '\\' && dirp->path[3] == '\0'))) {
1155 // No '\\' needed for cases like "Z:" or "Z:\"
1156 strcat(dirp->path, "*.*");
1157 } else {
1158 strcat(dirp->path, "\\*.*");
1159 }
1160
1161 dirp->handle = FindFirstFile(dirp->path, &dirp->find_data);
1162 if (dirp->handle == INVALID_HANDLE_VALUE) {
1163 if (GetLastError() != ERROR_FILE_NOT_FOUND) {
1164 free(dirp->path);
1165 free(dirp);
1166 errno = EACCES;
1167 return 0;
1168 }
1169 }
1170 return dirp;
1171 }
1172
1173 struct dirent * os::readdir(DIR *dirp) {
1174 assert(dirp != NULL, "just checking"); // hotspot change
1175 if (dirp->handle == INVALID_HANDLE_VALUE) {
1176 return NULL;
1177 }
1178
1179 strcpy(dirp->dirent.d_name, dirp->find_data.cFileName);
1180
1181 if (!FindNextFile(dirp->handle, &dirp->find_data)) {
1182 if (GetLastError() == ERROR_INVALID_HANDLE) {
1183 errno = EBADF;
1184 return NULL;
1185 }
1186 FindClose(dirp->handle);
1187 dirp->handle = INVALID_HANDLE_VALUE;
1188 }
1189
1190 return &dirp->dirent;
1191 }
1192
1193 int os::closedir(DIR *dirp) {
1194 assert(dirp != NULL, "just checking"); // hotspot change
1195 if (dirp->handle != INVALID_HANDLE_VALUE) {
1196 if (!FindClose(dirp->handle)) {
1197 errno = EBADF;
1198 return -1;
1199 }
1200 dirp->handle = INVALID_HANDLE_VALUE;
1201 }
1202 free(dirp->path);
1203 free(dirp);
1204 return 0;
|