Thanks to Annatar for noticing this problem.
Showing the changes to src (1 of 1 file). Show all
Unified · Split
| @@ -142,7 +142,6 @@ static int8_t findFirst(fileEntry_t *searchRec) · 141 unmodified lines | |||
| 142 | #else | 142 | #else |
| 143 | struct dirent *fData; | 143 | struct dirent *fData; |
| 144 | struct stat st; | 144 | struct stat st; |
| 145 | int64_t fSize; | ||
| 146 | #endif | 145 | #endif |
| 147 | 146 | ||
| 148 | searchRec->nameU = NULL; // this one must be initialized | 147 | searchRec->nameU = NULL; // this one must be initialized |
| @@ -172,26 +171,12 @@ static int8_t findFirst(fileEntry_t *searchRec) · 23 unmodified lines | |||
| 172 | return LFF_SKIP; | 171 | return LFF_SKIP; |
| 173 | 172 | ||
| 174 | searchRec->filesize = 0; | 173 | searchRec->filesize = 0; |
| 175 | searchRec->isDir = (fData->d_type == DT_DIR) ? true : false; | 174 | searchRec->isDir = false; |
| 176 | 175 | ||
| 177 | if (fData->d_type == DT_UNKNOWN || fData->d_type == DT_LNK) | 176 | if (stat(fData->d_name, &st) == 0) |
| 178 | { | 177 | { |
| 179 | if (stat(fData->d_name, &st) == 0) | 178 | searchRec->isDir = !!(st.st_mode & S_IFDIR); |
| 180 | { | 179 | searchRec->filesize = ((int64_t)st.st_size > INT32_MAX) ? -1 : (int32_t)st.st_size; |
| 181 | fSize = (int64_t)st.st_size; | ||
| 182 | searchRec->filesize = (fSize > INT32_MAX) ? -1 : (fSize & 0xFFFFFFFF); | ||
| 183 | |||
| 184 | if ((st.st_mode & S_IFMT) == S_IFDIR) | ||
| 185 | searchRec->isDir = true; | ||
| 186 | } | ||
| 187 | } | ||
| 188 | else if (!searchRec->isDir) | ||
| 189 | { | ||
| 190 | if (stat(fData->d_name, &st) == 0) | ||
| 191 | { | ||
| 192 | fSize = (int64_t)st.st_size; | ||
| 193 | searchRec->filesize = (fSize > INT32_MAX) ? -1 : (fSize & 0xFFFFFFFF); | ||
| 194 | } | ||
| 195 | } | 180 | } |
| 196 | #endif | 181 | #endif |
| 197 | 182 | ||
| @@ -226,7 +211,6 @@ static int8_t findNext(fileEntry_t *searchRec) · 28 unmodified lines | |||
| 226 | #else | 211 | #else |
| 227 | struct dirent *fData; | 212 | struct dirent *fData; |
| 228 | struct stat st; | 213 | struct stat st; |
| 229 | int64_t fSize; | ||
| 230 | #endif | 214 | #endif |
| 231 | 215 | ||
| 232 | searchRec->nameU = NULL; // important | 216 | searchRec->nameU = NULL; // important |
| @@ -252,26 +236,12 @@ static int8_t findNext(fileEntry_t *searchRec) · 19 unmodified lines | |||
| 252 | return LFF_SKIP; | 236 | return LFF_SKIP; |
| 253 | 237 | ||
| 254 | searchRec->filesize = 0; | 238 | searchRec->filesize = 0; |
| 255 | searchRec->isDir = (fData->d_type == DT_DIR) ? true : false; | 239 | searchRec->isDir = false; |
| 256 | 240 | ||
| 257 | if (fData->d_type == DT_UNKNOWN || fData->d_type == DT_LNK) | 241 | if (stat(fData->d_name, &st) == 0) |
| 258 | { | 242 | { |
| 259 | if (stat(fData->d_name, &st) == 0) | 243 | searchRec->isDir = !!(st.st_mode & S_IFDIR); |
| 260 | { | 244 | searchRec->filesize = ((int64_t)st.st_size > INT32_MAX) ? -1 : (int32_t)st.st_size; |
| 261 | fSize = (int64_t)st.st_size; | ||
| 262 | searchRec->filesize = (fSize > INT32_MAX) ? -1 : (fSize & 0xFFFFFFFF); | ||
| 263 | |||
| 264 | if ((st.st_mode & S_IFMT) == S_IFDIR) | ||
| 265 | searchRec->isDir = true; | ||
| 266 | } | ||
| 267 | } | ||
| 268 | else if (!searchRec->isDir) | ||
| 269 | { | ||
| 270 | if (stat(fData->d_name, &st) == 0) | ||
| 271 | { | ||
| 272 | fSize = (int64_t)st.st_size; | ||
| 273 | searchRec->filesize = (fSize > INT32_MAX) ? -1 : (fSize & 0xFFFFFFFF); | ||
| 274 | } | ||
| 275 | } | 245 | } |
| 276 | #endif | 246 | #endif |
| 277 | 247 | ||