summaryrefslogtreecommitdiffstats
path: root/imag-store
diff options
context:
space:
mode:
authorMatthias Beyer <mail@beyermatthias.de>2016-01-29 16:50:52 +0100
committerMatthias Beyer <mail@beyermatthias.de>2016-02-09 13:45:13 +0100
commitcaee76650d1b3b99a4ce36a3bfaf6f829e57b13f (patch)
treeb3e3a0985fc0596b008716dfeebf5fde259febb6 /imag-store
parentddd54e03ad6186fcb717d9969549d23c70d33b7b (diff)
Add store entry path builder helper
Diffstat (limited to 'imag-store')
-rw-r--r--imag-store/src/util.rs15
1 files changed, 15 insertions, 0 deletions
diff --git a/imag-store/src/util.rs b/imag-store/src/util.rs
index 3a15165b..a96fc508 100644
--- a/imag-store/src/util.rs
+++ b/imag-store/src/util.rs
@@ -1,12 +1,27 @@
use std::collections::BTreeMap;
+use std::path::PathBuf;
use std::str::Split;
use clap::ArgMatches;
use toml::Value;
use libimagstore::store::EntryHeader;
+use libimagrt::runtime::Runtime;
use libimagutil::key_value_split::IntoKeyValue;
+pub fn build_entry_path(rt: &Runtime, path_elem: &str) -> PathBuf {
+ debug!("Building path...");
+ let mut path = rt.store().path().clone();
+
+ if path_elem.chars().next() == Some('/') {
+ path.push(&path_elem[1..path_elem.len()]);
+ } else {
+ path.push(path_elem);
+ }
+
+ path
+}
+
pub fn build_toml_header(matches: &ArgMatches, header: EntryHeader) -> EntryHeader {
debug!("Building header from cli spec");
if let Some(headerspecs) = matches.values_of("header") {