Fix file descriptor unlimited growth.
This commit is contained in:
committed by
Zalim Bashorov
parent
5fc0d85b3c
commit
51e862e793
+3
-1
@@ -31,7 +31,9 @@ fun File.map(mode: FileChannel.MapMode = FileChannel.MapMode.READ_ONLY,
|
||||
if (mode == FileChannel.MapMode.READ_ONLY) "r" else "rw")
|
||||
val fileSize = if (mode == FileChannel.MapMode.READ_ONLY)
|
||||
file.length() else size.also { assert(size != -1L) }
|
||||
return file.channel.map(mode, start, fileSize) // Shall we .also { file.close() }?
|
||||
val channel = file.channel
|
||||
return channel.map(mode, start, fileSize)
|
||||
.also { channel.close() } // Channel close closes the file also.
|
||||
}
|
||||
|
||||
class CombinedIrFileReader(file: File) {
|
||||
|
||||
Reference in New Issue
Block a user