Wrapper around java.nio.channels.FileChannel.
Wrapper around java.nio.channels.FileChannel.
(file-channel p & opts)Opens a FileChannel at p (a Path) with the given opts
(StandardOpenOption constants).
Examples: (file-channel p opt-read) (file-channel p opt-write opt-create opt-truncate)
Opens a FileChannel at `p` (a Path) with the given `opts` (StandardOpenOption constants). Examples: (file-channel p opt-read) (file-channel p opt-write opt-create opt-truncate)
(force! ch metadata?)Forces any updates to the file to be written to storage.
If metadata? is true, file metadata (timestamps etc.) is
also flushed. Returns ch.
Forces any updates to the file to be written to storage. If `metadata?` is true, file metadata (timestamps etc.) is also flushed. Returns `ch`.
(force-map! buf)Flushes changes in a read-write mapped region to storage.
No-op for read-only or copy-on-write mappings. Returns buf.
Flushes changes in a read-write mapped region to storage. No-op for read-only or copy-on-write mappings. Returns `buf`.
(load! buf)Loads the mapped region into physical memory where possible.
Returns buf.
Loads the mapped region into physical memory where possible. Returns `buf`.
(loaded? buf)Returns true if the mapped region is likely to be resident in physical memory. This is only a hint and not guarantee.
Returns true if the mapped region is likely to be resident in physical memory. This is only a hint and not guarantee.
(lock! ch)Acquires an exclusive lock on the entire file. Blocks until the lock is available. Returns a FileLock. Throws OverlappingFileLockException if the JVM already holds a lock that overlaps this region.
Acquires an exclusive lock on the entire file. Blocks until the lock is available. Returns a FileLock. Throws OverlappingFileLockException if the JVM already holds a lock that overlaps this region.
(lock-region! ch pos size shared?)Acquires a lock on a region of the file. Blocks until available.
pos — starting byte position
size — number of bytes to lock
shared? — true for a shared lock, false for exclusive.
Acquires a lock on a region of the file. Blocks until available. `pos` — starting byte position `size` — number of bytes to lock `shared?` — true for a shared lock, false for exclusive.
(lock-valid? lock)Returns true if lock is valid.
A lock object remains valid until it is released
or the associated file channel is closed,
whichever comes first.
Returns true if `lock` is valid. A lock object remains valid until it is released or the associated file channel is closed, whichever comes first.
(mmap ch mode pos size)Maps a region of ch into memory. mode is one of:
map-mode-read-only — shared read-only mapping
map-mode-read-write — shared read-write mapping
map-mode-private — private (copy on write) mapping
pos is the starting file position, size is the region size
in bytes. Returns a MappedByteBuffer. All easy-nio.buffer
functions apply to it directly.
Maps a region of `ch` into memory. `mode` is one of: map-mode-read-only — shared read-only mapping map-mode-read-write — shared read-write mapping map-mode-private — private (copy on write) mapping `pos` is the starting file position, `size` is the region size in bytes. Returns a MappedByteBuffer. All easy-nio.buffer functions apply to it directly.
(mmap-private ch pos size)Maps size bytes of ch starting at pos as a copy-on-write
mapping. Writes affect only the in-memory copy, not the file.
Maps `size` bytes of `ch` starting at `pos` as a copy-on-write mapping. Writes affect only the in-memory copy, not the file.
(mmap-read ch pos size)Maps size bytes of ch starting at pos as a read-only mapping.
Maps `size` bytes of `ch` starting at `pos` as a read-only mapping.
(mmap-read-write ch pos size)Maps size bytes of ch starting at pos as a read-write mapping.
Maps `size` bytes of `ch` starting at `pos` as a read-write mapping.
(path first & more)Constructs a Path from first and optional more path segments.
Constructs a Path from `first` and optional `more` path segments.
(position ch)Returns the current file position.
Returns the current file position.
(read! ch buf)Reads bytes from ch into buf at the channel's current position.
Advances the position. Returns bytes read, or -1 at end-of-file.
Reads bytes from `ch` into `buf` at the channel's current position. Advances the position. Returns bytes read, or -1 at end-of-file.
(read-at! ch buf pos)Reads bytes from ch into buf starting at absolute file position
pos. Does not affect the channel's current position.
Reads bytes from `ch` into `buf` starting at absolute file position `pos`. Does not affect the channel's current position.
(release-lock! lock)Releases lock. Returns nil.
Releases `lock`. Returns nil.
(set-position! ch pos)Sets the file position to pos. Returns ch.
Sets the file position to `pos`. Returns `ch`.
(shared-lock? lock)Returns true if lock is a shared.
Returns true if `lock` is a shared.
(size ch)Returns the current size of the file in bytes.
Returns the current size of the file in bytes.
(transfer-from! ch src pos count)Transfers bytes from src (a ReadableByteChannel) into ch.
Writes up to count bytes starting at pos in ch.
May transfer fewer bytes than requested.
Returns bytes transferred.
Transfers bytes from `src` (a ReadableByteChannel) into `ch`. Writes up to `count` bytes starting at `pos` in `ch`. May transfer fewer bytes than requested. Returns bytes transferred.
(transfer-to! ch pos count dst)Transfers bytes from ch to dst (a WritableByteChannel).
Reads count bytes starting at pos in ch.
May transfer fewer bytes than requested.
Returns bytes transferred.
Transfers bytes from `ch` to `dst` (a WritableByteChannel). Reads `count` bytes starting at `pos` in `ch`. May transfer fewer bytes than requested. Returns bytes transferred.
(truncate! ch size)Truncates the file to size bytes. If the current position
exceeds size it is set to size. Returns ch.
Truncates the file to `size` bytes. If the current position exceeds `size` it is set to `size`. Returns `ch`.
(try-lock! ch)Attempts to acquire an exclusive lock on the entire file without blocking. Returns a FileLock if successful, nil if the lock is unavailable. Throws OverlappingFileLockException if the JVM already holds an overlapping lock.
Attempts to acquire an exclusive lock on the entire file without blocking. Returns a FileLock if successful, nil if the lock is unavailable. Throws OverlappingFileLockException if the JVM already holds an overlapping lock.
(try-lock-region! ch pos size shared?)Attempts to acquire a lock on a region of the file without blocking.
pos — starting byte position
size — number of bytes to lock
shared? — true for a shared lock, false for exclusive.
Returns a FileLock if successful, nil if unavailable.
Attempts to acquire a lock on a region of the file without blocking. `pos` — starting byte position `size` — number of bytes to lock `shared?` — true for a shared lock, false for exclusive. Returns a FileLock if successful, nil if unavailable.
(write! ch buf)Writes bytes from buf to ch at the channel's current position.
Advances the position. Returns bytes written.
Writes bytes from `buf` to `ch` at the channel's current position. Advances the position. Returns bytes written.
(write-at! ch buf pos)Writes bytes from buf to ch at absolute file position pos.
Does not affect the channel's current position.
Writes bytes from `buf` to `ch` at absolute file position `pos`. Does not affect the channel's current position.
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |