aboutsummaryrefslogtreecommitdiff
path: root/utils/fdata
diff options
context:
space:
mode:
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")" ]
+}