diff options
author | Justus Winter <justus@sequoia-pgp.org> | 2018-09-10 10:06:16 +0200 |
---|---|---|
committer | Justus Winter <justus@sequoia-pgp.org> | 2018-09-17 14:43:58 +0200 |
commit | 030b195820c82d8fd89feefa5034e966446f4546 (patch) | |
tree | 65facc47f6fffb61c0789d7fc6c538a32352c5c7 /openpgp/src | |
parent | 21c1e132b7de05360abbac48347470a2067854ff (diff) |
openpgp: Use the new reader.
- Use the new reader either directly, or make sure that calls to
from_file(..) use it down the call chain.
Diffstat (limited to 'openpgp/src')
-rw-r--r-- | openpgp/src/armor.rs | 4 | ||||
-rw-r--r-- | openpgp/src/packet_pile.rs | 5 | ||||
-rw-r--r-- | openpgp/src/parse/packet_parser_builder.rs | 5 | ||||
-rw-r--r-- | openpgp/src/parse/packet_pile_parser.rs | 6 | ||||
-rw-r--r-- | openpgp/src/parse/stream.rs | 8 | ||||
-rw-r--r-- | openpgp/src/reader.rs | 5 | ||||
-rw-r--r-- | openpgp/src/tpk/mod.rs | 3 |
7 files changed, 18 insertions, 18 deletions
diff --git a/openpgp/src/armor.rs b/openpgp/src/armor.rs index 40d6c9c1..a09b93be 100644 --- a/openpgp/src/armor.rs +++ b/openpgp/src/armor.rs @@ -27,8 +27,8 @@ extern crate base64; use buffered_reader::{ BufferedReader, BufferedReaderGeneric, BufferedReaderMemory, + BufferedReaderFile, }; -use std::fs::File; use std::io::{Cursor, Read, Write}; use std::io::{Result, Error, ErrorKind}; use std::path::Path; @@ -453,7 +453,7 @@ impl<'a> Reader<'a> { where P: AsRef<Path> { Ok(Self::from_buffered_reader( - Box::new(BufferedReaderGeneric::new(File::open(path)?, None)), + Box::new(BufferedReaderFile::open(path)?), kind)) } diff --git a/openpgp/src/packet_pile.rs b/openpgp/src/packet_pile.rs index 5c7f2710..e527cc13 100644 --- a/openpgp/src/packet_pile.rs +++ b/openpgp/src/packet_pile.rs @@ -3,11 +3,11 @@ use std::slice; use std::vec; use std::io; use std::path::Path; -use std::fs::File; use buffered_reader::BufferedReader; use buffered_reader::BufferedReaderGeneric; use buffered_reader::BufferedReaderMemory; +use buffered_reader::BufferedReaderFile; use Result; use Error; @@ -291,7 +291,8 @@ impl PacketPile { /// /// See `from_reader` for more details and caveats. pub fn from_file<P: AsRef<Path>>(path: P) -> Result<PacketPile> { - PacketPile::from_reader(File::open(path)?) + PacketPile::from_buffered_reader( + Box::new(BufferedReaderFile::with_cookie(path, Cookie::default())?)) } /// Deserializes the OpenPGP message stored in the provided buffer. diff --git a/openpgp/src/parse/packet_parser_builder.rs b/openpgp/src/parse/packet_parser_builder.rs index 4f76eddf..f6001175 100644 --- a/openpgp/src/parse/packet_parser_builder.rs +++ b/openpgp/src/parse/packet_parser_builder.rs @@ -1,10 +1,10 @@ use std::io; use std::path::Path; -use std::fs::File; use buffered_reader::BufferedReader; use buffered_reader::BufferedReaderGeneric; use buffered_reader::BufferedReaderMemory; +use buffered_reader::BufferedReaderFile; use Result; use parse::PacketParserResult; @@ -52,7 +52,8 @@ impl<'a> PacketParserBuilder<'a> { /// Creates a `PacketParserBuilder` for an OpenPGP message stored /// in the file named `path`. pub fn from_file<P: AsRef<Path>>(path: P) -> Result<Self> { - PacketParserBuilder::from_reader(File::open(path)?) + PacketParserBuilder::from_buffered_reader( + Box::new(BufferedReaderFile::with_cookie(path, Cookie::default())?)) } /// Creates a `PacketParserBuilder` for an OpenPGP message stored diff --git a/openpgp/src/parse/packet_pile_parser.rs b/openpgp/src/parse/packet_pile_parser.rs index 74acde40..fb0faf9c 100644 --- a/openpgp/src/parse/packet_pile_parser.rs +++ b/openpgp/src/parse/packet_pile_parser.rs @@ -1,5 +1,4 @@ use std::io; -use std::fs::File; use std::path::Path; use { @@ -15,7 +14,7 @@ use parse::{ Cookie }; use buffered_reader::{BufferedReader, BufferedReaderGeneric, - BufferedReaderMemory}; + BufferedReaderMemory, BufferedReaderFile}; #[cfg(test)] #[allow(unused_macros)] @@ -134,7 +133,8 @@ impl<'a> PacketPileParser<'a> { /// in the file named by `path`. pub fn from_file<P: AsRef<Path>>(path: P) -> Result<PacketPileParser<'a>> { - PacketPileParser::from_reader(File::open(path)?) + PacketPileParser::from_buffered_reader( + Box::new(BufferedReaderFile::with_cookie(path, Cookie::default())?)) } /// Creates a `PacketPileParser` to parse the OpenPGP message stored diff --git a/openpgp/src/parse/stream.rs b/openpgp/src/parse/stream.rs index 0e963893..6deef331 100644 --- a/openpgp/src/parse/stream.rs +++ b/openpgp/src/parse/stream.rs @@ -5,12 +5,12 @@ use std::cmp; use std::collections::HashMap; -use std::fs::File; use std::io::{self, Read}; use std::path::Path; use buffered_reader::{ BufferedReader, BufferedReaderGeneric, BufferedReaderMemory, + BufferedReaderFile, }; use { Error, @@ -165,9 +165,8 @@ impl<'a, H: VerificationHelper> Verifier<'a, H> { where P: AsRef<Path> { Verifier::from_buffered_reader( - Box::new(BufferedReaderGeneric::with_cookie(File::open(path)?, - None, - Default::default())), + Box::new(BufferedReaderFile::with_cookie(path, + Default::default())?), helper) } @@ -413,6 +412,7 @@ impl<'a, H: VerificationHelper> io::Read for Verifier<'a, H> { #[cfg(test)] mod test { use failure; + use std::fs::File; use std::path::PathBuf; use super::*; diff --git a/openpgp/src/reader.rs b/openpgp/src/reader.rs index dd84132d..a6abc01f 100644 --- a/openpgp/src/reader.rs +++ b/openpgp/src/reader.rs @@ -1,7 +1,7 @@ use buffered_reader::{ BufferedReader, BufferedReaderGeneric, BufferedReaderMemory, + BufferedReaderFile, }; -use std::fs::File; use std::io; use std::path::Path; @@ -39,8 +39,7 @@ impl<'a> Reader<'a> { pub fn from_file<P>(path: P) -> Result<Self> where P: AsRef<Path> { - Self::from_buffered_reader( - Box::new(BufferedReaderGeneric::new(File::open(path)?, None))) + Self::from_buffered_reader(Box::new(BufferedReaderFile::open(path)?)) } /// Creates a `Reader` from a buffer. diff --git a/openpgp/src/tpk/mod.rs b/openpgp/src/tpk/mod.rs index 9be83d4a..c5f22b4e 100644 --- a/openpgp/src/tpk/mod.rs +++ b/openpgp/src/tpk/mod.rs @@ -3,7 +3,6 @@ use std::io; use std::cmp::Ordering; use std::path::Path; -use std::fs::File; use std::slice; use std::mem; use std::fmt; @@ -1004,7 +1003,7 @@ impl TPK { /// Returns the first TPK encountered in the file. pub fn from_file<P: AsRef<Path>>(path: P) -> Result<Self> { - Self::from_reader(File::open(path)?) + TPK::from_packet_parser(PacketParser::from_file(path)?) } /// Returns the first TPK found in the `PacketPile`. |