Class OpenCryptoFiles

    • Method Detail

      • get

        public Optional<OpenCryptoFile> get​(Path ciphertextPath)
        Gets an OpenCryptoFile (if any is opened) without creating it.

        Useful if you don't want to create any FileChannel but want to check whether this file is currently opened (e.g. to get its current OpenCryptoFile.size()).

        Parameters:
        ciphertextPath - Path of the file which might have been opened
        Returns:
        The OpenCryptoFile if opened or an empty Optional otherwise.
      • getOrCreate

        public OpenCryptoFile getOrCreate​(Path ciphertextPath)
        Opens a file to retrieve a FileChannel. If this file is already opened, a shared instance is returned. Getting the file channel should be the next invocation, since the lifecycle of the OpenFile strictly depends on the lifecycle of the channel.
        Parameters:
        ciphertextPath - Path of the file to open
        Returns:
        The opened file.
        See Also:
        get(Path)
      • prepareMove

        public OpenCryptoFiles.TwoPhaseMove prepareMove​(Path src,
                                                        Path dst)
                                                 throws FileAlreadyExistsException
        Prepares to update any open file references during a move operation. MUST be invoked using a try-with-resource statement and committed after the physical file move succeeded.
        Parameters:
        src - The ciphertext file path before the move
        dst - The ciphertext file path after the move
        Returns:
        Utility to update OpenCryptoFile references.
        Throws:
        FileAlreadyExistsException - Thrown if the destination file is an existing file that is currently opened.