loadFile method

File loadFile(
  1. String filename, {
  2. File? to,
})

Loads a file form the secure vault with filename to location to where it will be stored unencrypted. It is then returned.

When to is null, the file returned is located in a temp directory

Implementation

File loadFile(String filename, {File? to}) {
  if (!filename.endsWith('.gpg')) {
    throw 'Files in vault always end with ".gpg". '
        '"$filename" does not';
  }
  unlock();
  final path = location.file(filename);
  if (!path.existsSync()) {
    throw "${path.path} does not exist in vault";
  }
  return gpgDecrypt(path, _passphrase!, output: to);
}