Opens file in read-only mode with caching support.
(LPSZ lpsz)
| 185 | * Opens file in read-only mode with caching support. |
| 186 | */ |
| 187 | public synchronized long openROCached(LPSZ lpsz) { |
| 188 | final FdCacheRecord holder = getFdCacheRecord(lpsz); |
| 189 | if (holder == null) { |
| 190 | // Failed to open |
| 191 | return -1; |
| 192 | } |
| 193 | |
| 194 | holder.count++; |
| 195 | |
| 196 | // find a unique key even if the index generator wrapped over |
| 197 | long uniqROFd; |
| 198 | int keyIndex; |
| 199 | do { |
| 200 | uniqROFd = Numbers.encodeLowHighInts(nextIndex(), holder.osFd); |
| 201 | keyIndex = openFdMapByFd.keyIndex(uniqROFd); |
| 202 | } while (keyIndex < 0); |
| 203 | |
| 204 | openFdMapByFd.putAt(keyIndex, uniqROFd, holder); |
| 205 | |
| 206 | return uniqROFd; |
| 207 | } |
| 208 | |
| 209 | /** |
| 210 | * Removes file path from cache when file is deleted. |
no test coverage detected