blob: 4d36242cd347e476346fbdc8a33a16cdeeb399ee (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
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")" ]
}
|