From 48fd3e66f5f9ecd1efcf4434eed0286ded0c0667 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Mon, 23 Nov 2015 18:58:25 +0100 Subject: [PATCH] Add implementation for Storage::createEmpty() --- src/main.rs | 1 + src/storage/backend.rs | 13 ++++++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/main.rs b/src/main.rs index 1dfdd28d..2e711b59 100644 --- a/src/main.rs +++ b/src/main.rs @@ -3,6 +3,7 @@ #[macro_use] extern crate serde; #[macro_use] extern crate serde_json; #[macro_use] extern crate glob; +#[macro_use] extern crate uuid; extern crate config; extern crate regex; diff --git a/src/storage/backend.rs b/src/storage/backend.rs index 8ea66cde..65c965e6 100644 --- a/src/storage/backend.rs +++ b/src/storage/backend.rs @@ -45,7 +45,18 @@ impl StorageBackend { } } - fn createEmpty() -> FileID { + fn createEmpty(&self) -> Option { + use std::fs::File; + use uuid::Uuid; + let uuid = Uuid::new_v4().to_hyphenated_string(); + let pathstr = self.basepath + uuid.as_str(); + let path = Path::new(&pathstr); + + if let Ok(f) = File::create(path) { + Some(uuid) + } else { + None + } } fn createFile() -> File {