Package org.cryptomator.cryptofs.fh
Class OpenCryptoFile
- java.lang.Object
-
- org.cryptomator.cryptofs.fh.OpenCryptoFile
-
- All Implemented Interfaces:
Closeable,AutoCloseable
@OpenFileScoped public class OpenCryptoFile extends Object implements Closeable
-
-
Constructor Summary
Constructors Constructor Description OpenCryptoFile(FileCloseListener listener, ChunkCache chunkCache, org.cryptomator.cryptolib.api.Cryptor cryptor, FileHeaderHolder headerHolder, org.cryptomator.cryptofs.fh.ChunkIO chunkIO, AtomicReference<Path> currentFilePath, AtomicLong fileSize, AtomicReference<Instant> lastModified, OpenCryptoFileComponent component)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()PathgetCurrentFilePath()FileTimegetLastModifiedTime()FileChannelnewFileChannel(EffectiveOpenOptions options)Creates a new file channel with the given open options.voidsetCurrentFilePath(Path currentFilePath)voidsetLastModifiedTime(FileTime lastModifiedTime)Optional<Long>size()StringtoString()
-
-
-
Constructor Detail
-
OpenCryptoFile
@Inject public OpenCryptoFile(FileCloseListener listener, ChunkCache chunkCache, org.cryptomator.cryptolib.api.Cryptor cryptor, FileHeaderHolder headerHolder, org.cryptomator.cryptofs.fh.ChunkIO chunkIO, @CurrentOpenFilePath AtomicReference<Path> currentFilePath, @OpenFileSize AtomicLong fileSize, @OpenFileModifiedDate AtomicReference<Instant> lastModified, OpenCryptoFileComponent component)
-
-
Method Detail
-
newFileChannel
public FileChannel newFileChannel(EffectiveOpenOptions options) throws IOException
Creates a new file channel with the given open options.- Parameters:
options- The options to use to open the file channel. For the most part these will be passed through to the ciphertext channel.- Returns:
- A new file channel. Ideally used in a try-with-resource statement. If the channel is not properly closed, this OpenCryptoFile will stay open indefinite.
- Throws:
IOException
-
size
public Optional<Long> size()
- Returns:
- The size of the opened file. Note that the filesize is unknown until a
file channel is opened. In this case this method returns an empty optional.
-
getLastModifiedTime
public FileTime getLastModifiedTime()
-
setLastModifiedTime
public void setLastModifiedTime(FileTime lastModifiedTime)
-
getCurrentFilePath
public Path getCurrentFilePath()
-
setCurrentFilePath
public void setCurrentFilePath(Path currentFilePath)
-
close
public void close()
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable
-
-