YAACC - UPNP Client and Server
Loading...
Searching...
No Matches
de.yaacc.share.BudgetedCopier Class Reference

The copy loop of the copy fallback: copies a provider stream to a file chunk by chunk and asks CopyBudget before EVERY chunk is written, so a copy never goes over the byte cap or below the free-space reserve. More...

Collaboration diagram for de.yaacc.share.BudgetedCopier:
Collaboration graph

Classes

enum  Outcome
 How the copy ended. More...
 
class  Result
 The outcome and the number of bytes written.
 

Static Public Member Functions

static Result copy (InputStream in, OutputStream out, long declaredSize, long maxBytes, LongSupplier usableSpace, BooleanSupplier cancelled, byte[] buffer) throws IOException
 

Detailed Description

The copy loop of the copy fallback: copies a provider stream to a file chunk by chunk and asks CopyBudget before EVERY chunk is written, so a copy never goes over the byte cap or below the free-space reserve.

Plain Java; streams, free space and the stop flag are passed in.

The caller deletes the partial file for every outcome except Outcome#COPIED.

Member Function Documentation

◆ copy()

static Result de.yaacc.share.BudgetedCopier.copy ( InputStream in,
OutputStream out,
long declaredSize,
long maxBytes,
LongSupplier usableSpace,
BooleanSupplier cancelled,
byte[] buffer ) throws IOException
static
Parameters
inthe provider stream
outthe target file
declaredSizethe size the provider declared, negative for unknown
maxBytesthe most that may be copied (see IncomingCache#remainingCopyBudget)
usableSpaceasked before each chunk: the free bytes on the volume now
cancelledasked before each chunk: true to stop
bufferthe chunk buffer, not empty
Exceptions
IOExceptionif reading or writing fails
Here is the call graph for this function:

The documentation for this class was generated from the following file: