Execute retab! on all files to expand tabs into spaces.
This commit is contained in:
Matthias Beyer
2016-10-23 17:00:54 +02:00
parent c862338243
commit d3c0c1ed9d
2 changed files with 10 additions and 10 deletions
+3 -3
View File
@@ -6,9 +6,9 @@ quick_error! {
pub enum BreakError {
/// An error returned when doing file operations, this might happen by opening, closing,
/// locking or flushing
Io(err: ::std::io::Error) {
from()
}
Io(err: ::std::io::Error) {
from()
}
/// This error happens if Bincode cannot deserialize a given file. If you get this error
/// check your database is not corrupt. (This includes non-empty files **not** created by
/// RustBreak!
+7 -7
View File
@@ -104,7 +104,7 @@ pub type BreakResult<T> = Result<T, BreakError>;
/// ];
///
/// for (album, artist) in albums {
/// db.insert(&format!("album_{}",album), artist).unwrap();
/// db.insert(&format!("album_{}",album), artist).unwrap();
/// }
/// db.flush().unwrap();
/// ```
@@ -133,20 +133,20 @@ impl<T: Serialize + Deserialize + Eq + Hash> Database<T> {
/// ];
///
/// for (album, artist) in albums {
/// db.insert(&format!("album_{}",album), artist).unwrap();
/// db.insert(&format!("album_{}",album), artist).unwrap();
/// }
/// db.flush().unwrap();
/// ```
pub fn open<P: AsRef<Path>>(path: P) -> BreakResult<Database<T>> {
use std::fs::OpenOptions;
use fs2::FileExt;
use std::fs::OpenOptions;
use fs2::FileExt;
use std::io::Read;
use bincode::serde::deserialize;
let mut file = try!(OpenOptions::new().read(true).write(true).create(true).open(path));
try!(file.try_lock_exclusive());
let mut file = try!(OpenOptions::new().read(true).write(true).create(true).open(path));
try!(file.try_lock_exclusive());
let mut buf = Vec::new();
let mut buf = Vec::new();
try!(file.read_to_end(&mut buf));
let map : HashMap<T, Vec<u8>> = if !buf.is_empty() {
try!(deserialize(&buf))