* Find an entry by name. */
| 209 | * Find an entry by name. |
| 210 | */ |
| 211 | ZipEntry* ZipFile::getEntryByName(const char* fileName) const |
| 212 | { |
| 213 | /* |
| 214 | * Do a stupid linear string-compare search. |
| 215 | * |
| 216 | * There are various ways to speed this up, especially since it's rare |
| 217 | * to intermingle changes to the archive with "get by name" calls. We |
| 218 | * don't want to sort the mEntries vector itself, however, because |
| 219 | * it's used to recreate the Central Directory. |
| 220 | * |
| 221 | * (Hash table works, parallel list of pointers in sorted order is good.) |
| 222 | */ |
| 223 | int idx; |
| 224 | |
| 225 | for (idx = mEntries.size()-1; idx >= 0; idx--) { |
| 226 | ZipEntry* pEntry = mEntries[idx]; |
| 227 | if (!pEntry->getDeleted() && |
| 228 | strcmp(fileName, pEntry->getFileName()) == 0) |
| 229 | { |
| 230 | return pEntry; |
| 231 | } |
| 232 | } |
| 233 | |
| 234 | return NULL; |
| 235 | } |
| 236 | |
| 237 | /* |
| 238 | * Empty the mEntries vector. |
no test coverage detected