|
YAACC - UPNP Client and Server
|
A file of another app that is kept readable by holding its descriptor open. More...


Classes | |
| class | NotSeekableException |
| The descriptor does not support positional reads (pipe, socket, device, not a regular file). | |
Static Public Member Functions | |
| static boolean | isSeekable (FileDescriptor fd) |
Whether positional reads work on the descriptor: a regular file (fstat) on which lseek(SEEK_CUR) succeeds (it fails with ESPIPE for pipes and sockets). | |
| static HeldFileSource | open (AssetFileDescriptor afd) throws IOException |
| Holds the file behind the provider's descriptor. | |
Protected Member Functions | |
| int | readAtInternal (long position, byte[] buf, int off, int len) throws IOException |
| Reads from the backend. | |
| void | closeInternal () |
| Closes the backend. | |
Protected Member Functions inherited from de.yaacc.share.PositionalSource | |
| PositionalSource (long size) | |
Additional Inherited Members | |
Public Member Functions inherited from de.yaacc.share.PositionalSource | |
| final long | size () |
| final int | readAt (long position, byte[] buf, int off, int len) throws IOException |
Reads up to len bytes starting at position. | |
| final boolean | isClosing () |
| final void | close () |
| Refuses new reads and closes the backend: now if nothing is reading, else when the last running read ends. | |
A file of another app that is kept readable by holding its descriptor open.
The registry (as an AutoCloseable target of a LOCAL_FILE entry) closes it; closing never blocks and never happens while a read runs (PositionalSource).
Reads use Os#pread, which does not touch the file offset, so any number of responses read different ranges of the one descriptor. The held descriptor is a dup of the provider's one, and the provider's is closed, so the provider process is not pinned by a stable reference. The start offset and length the provider declares are clamped to the real file size (clampLength).
|
protected |
Closes the backend.
Called exactly once, never while a read is running, possibly on a reader's thread. Should not throw; an exception is swallowed.
Reimplemented from de.yaacc.share.PositionalSource.
|
static |
Whether positional reads work on the descriptor: a regular file (fstat) on which lseek(SEEK_CUR) succeeds (it fails with ESPIPE for pipes and sockets).
Cheap and does not change the descriptor.
Referenced by de.yaacc.share.HeldFileSource.open().

|
static |
Holds the file behind the provider's descriptor.
On success this method has duplicated the descriptor and closed afd, so the caller must not use or close it any more. On any failure afd is left open, untouched and still owned by the caller (who may then fall back to copying from it, and closes it).
Do not call on the main thread: fstat on a provider descriptor can block.
| NotSeekableException | if the descriptor cannot be read positionally |
| IOException | if the descriptor is unusable (empty window, offset beyond the end, dup failed) |
Referenced by de.yaacc.share.SharedFileOpener.openDescriptor().


|
protected |
Reads from the backend.
Called with 0 <= position < size(), len > 0 and a valid buffer range; possibly from several threads at once; never after the backend was closed. May return fewer bytes than asked. Returns -1 (or 0) if the backend has no more data at that position.
Reimplemented from de.yaacc.share.PositionalSource.