Package org.yamcs.cfdp
Class OutgoingFileSource
java.lang.Object
org.yamcs.cfdp.OutgoingFileSource
- All Implemented Interfaces:
AutoCloseable
- Direct Known Subclasses:
OutgoingFileSource.DiskSource
The data of a file being sent (uplinked) by CFDP.
The data is read in pieces with positional reads, so the file does not have to be kept in memory. Two implementations exist: a file on disk (normally a copy of the bucket object in the transfer directory) and an in memory array (used for tests or when no transfer directory is available).
The reads are performed from the CFDP executor thread; they are not synchronized.
-
Nested Class Summary
Nested Classes -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionlongchecksum(long length) Computes the CFDP modular checksum of the firstlengthbytes of the file by streaming it.abstract voidclose()createFile(Path path, byte[] data) Writes the data into a new file at the given path (truncating it if it exists), syncs it to disk and returns a source reading from that file.static OutgoingFileSourceofBytes(byte[] data) Opens an existing fileabstract voidread(long pos, byte[] dst, int off, int len) Reads exactlylenbytes starting at positionposin the file intodst[off..off+len).abstract longsize()
-
Constructor Details
-
OutgoingFileSource
public OutgoingFileSource()
-
-
Method Details
-
size
public abstract long size()- Returns:
- the size of the file
-
read
Reads exactlylenbytes starting at positionposin the file intodst[off..off+len).- Throws:
IOException- if the data cannot be read or the file is shorter than pos+len
-
checksum
Computes the CFDP modular checksum of the firstlengthbytes of the file by streaming it.- Throws:
IOException
-
close
public abstract void close()- Specified by:
closein interfaceAutoCloseable
-
ofBytes
-
createFile
Writes the data into a new file at the given path (truncating it if it exists), syncs it to disk and returns a source reading from that file.- Throws:
IOException
-
openFile
Opens an existing file- Throws:
IOException
-