aboutsummaryrefslogtreecommitdiff
path: root/utils/fdata
diff options
context:
space:
mode:
authorKarel Kočí <cynerd@email.cz>2017-09-20 21:19:05 +0200
committerKarel Kočí <cynerd@email.cz>2017-09-20 21:22:36 +0200
commitf287ecedc78c0cc8fb485c5995b8d1cfae9f0fe8 (patch)
tree5025b33a8c3d4c69ad2b62e1169b669c56f712f9 /utils/fdata
parent65f52ead41dc6df73671ddd3a8c6a2edecb6dfb3 (diff)
downloadmulticonfig-f287ecedc78c0cc8fb485c5995b8d1cfae9f0fe8.tar.gz
multiconfig-f287ecedc78c0cc8fb485c5995b8d1cfae9f0fe8.tar.bz2
multiconfig-f287ecedc78c0cc8fb485c5995b8d1cfae9f0fe8.zip
Commit current statecomplicated
Diffstat (limited to 'utils/fdata')
-rw-r--r--utils/fdata36
1 files changed, 36 insertions, 0 deletions
diff --git a/utils/fdata b/utils/fdata
new file mode 100644
index 0000000..4d36242
--- /dev/null
+++ b/utils/fdata
@@ -0,0 +1,36 @@
+# vim:ft=sh:noexpandtab
+# Datasets on filesystem
+
+FDATA_PATH="/tmp/multiconfig-fdata"
+mkdir -p "$FDATA_PATH"
+cleaner_add "rm -rf '$FDATA_PATH'"
+
+dict_set() {
+ local DPATH="$FDATA_PATH/$1"; shift
+ mkdir -p "$DPATH"
+ local FPATH="$DPATH/$1"; shift
+ echo "$@" > "$FPATH"
+}
+
+dict_get() {
+ local P="$FDATA_PATH/$1/$2"
+ [ -f "$P" ] || return
+ cat "$P"
+}
+
+dict_keys() {
+ local P="$FDATA_PATH/$1"
+ if [ -d "$P" ]; then
+ ls -A "$P" | tr '\n' ' '
+ fi
+}
+
+dict_contains() {
+ local P="$FDATA_PATH/$1/$2"
+ [ -f "$P" ]
+}
+
+dict_empty() {
+ local P="$FDATA_PATH/$1"
+ [ ! -d "$P" ] || [ -z "$(ls -A "$P")" ]
+}