Renames file in the filesystem and updates cache. @param oldName Old file name @param newName New file name @return 0 on success, -1 on failure
(LPSZ oldName, LPSZ newName)
| 223 | * @return 0 on success, -1 on failure |
| 224 | */ |
| 225 | public synchronized int rename(LPSZ oldName, LPSZ newName) { |
| 226 | int keyIndex = openFdMapByPath.keyIndex(oldName); |
| 227 | int result = Files.rename(oldName.ptr(), newName.ptr()); |
| 228 | if (result == 0 && keyIndex < 0) { |
| 229 | FdCacheRecord record = openFdMapByPath.valueAt(keyIndex); |
| 230 | openFdMapByPath.removeAt(keyIndex); |
| 231 | Utf8String path = Utf8String.newInstance(newName); |
| 232 | openFdMapByPath.put(path, record); |
| 233 | record.path = path; |
| 234 | } |
| 235 | return result; |
| 236 | } |
| 237 | |
| 238 | /** |
| 239 | * Retrieves memory map cache key for given file descriptor. |