. "$_EXEC/cgilite/storage.sh"
# == FILE FORMAT ==
-# LENGTH WIDTH HEIGHT TAGS COMMENT NAME
+# LENGTH WIDTH HEIGHT TAGS COMMENT NAME GROUP
# == GLOBALS ==
UNSET_META='unset \
- META_LENGTH META_WIDTH META_HEIGHT META_TAGS META_COMMENT META_NAME
+ META_LENGTH META_WIDTH META_HEIGHT META_TAGS META_COMMENT META_NAME META_GROUP
'
LOCAL_META='local \
- META_LENGTH META_WIDTH META_HEIGHT META_TAGS META_COMMENT META_NAME
+ META_LENGTH META_WIDTH META_HEIGHT META_TAGS META_COMMENT META_NAME META_GROUP
'
eval "$UNSET_META"
# Global exports
META_LENGTH='' META_WIDTH='' META_HEIGHT='' META_TAGS=''
- META_COMMENT='' META_NAME=''
+ META_COMMENT='' META_NAME='' META_GROUP=''
if [ $# -eq 0 ]; then
- read -r META_LENGTH META_WIDTH META_HEIGHT META_TAGS META_COMMENT META_NAME
+ read -r META_LENGTH META_WIDTH META_HEIGHT META_TAGS META_COMMENT \
+ META_NAME META_GROUP
elif [ "$name" -a -f "$meta_db" -a -r "$meta_db" ]; then
- read -r META_LENGTH META_WIDTH META_HEIGHT META_TAGS META_COMMENT META_NAME <<-EOF
+ read -r META_LENGTH META_WIDTH META_HEIGHT META_TAGS META_COMMENT \
+ META_NAME META_GROUP <<-EOF
$(grep -F " ${name}${CR}" "$meta_db")
EOF
fi
META_NAME="$(UNSTRING "${META_NAME%${CR}}")"
META_COMMENT="$(UNSTRING "${META_COMMENT#comment=}")"
META_TAGS="$(UNSTRING "${META_TAGS#tags=}")"
+ META_GROUP="${META_GROUP#\\}"
else
eval "$UNSET_META"
return 1
}
update_meta(){
- local name="${1:=${META_NAME}}" tags comment length width height
- local LENGTH WIDTH HEIGH TAGS COMMENT NAME
+ local name="${1:=${META_NAME}}" tags comment length width height group
+ local LENGTH WIDTH HEIGH TAGS COMMENT NAME GROUP
local arg cnt meta_db="$_DATA/.index/meta"
[ "${name%%/*}" != "$name" ] \
lenght=*) lenght="${arg#*=}";;
width=*) width="${arg#*=}";;
height=*) height="${arg#*=}";;
+ group=*) group="${arg#*=}";;
esac; done
if LOCK "$meta_db"; then
- read -r LENGTH WIDTH HEIGHT TAGS COMMENT NAME <<-EOF
+ read -r LENGTH WIDTH HEIGHT TAGS COMMENT NAME GROUP <<-EOF
$(grep -F " ${name}${CR}" "$meta_db")
EOF
if [ ! "$NAME" ]; then
RELEASE "$meta_db"
return 1
fi
- printf '%i %i %i tags=%s comment=%s %s\r\n' \
+ printf '%i %i %i tags=%s comment=%s %s\r %s\n' \
"${length:-${length-${LENGTH}}${length+0}}" \
"${width:-${width-${WIDTH}}${width+0}}" \
"${height:-${height-${HEIGHT}}${height+0}}" \
"$(STRING "${tags-$(UNSTRING "${TAGS#tags=}")}")" \
"$(STRING "${comment-$(UNSTRING "${COMMENT#comment=}")}")" \
- "${NAME%${CR}}" \
+ "${NAME%${CR}}" "${group:-${GROUP:-\\}}" \
>"${meta_db}.$$"
grep -vF " ${name}${CR}" "$meta_db" >>"${meta_db}.$$"
new_meta(){
local name="$1" meta_db="$_DATA/.index/meta"
- local LENGTH WIDTH HEIGHT TAGS COMMENT NAME
+ local LENGTH WIDTH HEIGHT TAGS COMMENT NAME GROUP
[ "${name%%/*}" != "$name" ] \
&& meta_db="$_DATA/${name%%/*}/.index/meta"
name="$(STRING "${name##*/}")"
if LOCK "$meta_db"; then
- while read -r LENGTH WIDTH HEIGHT TAGS COMMENT NAME; do
+ while read -r LENGTH WIDTH HEIGHT TAGS COMMENT NAME GROUP; do
if [ "$name" = "${NAME%${CR}}" ]; then
RELEASE "$vid_db"
return 1
fi
done <"$meta_db"
- printf '0 0 0 tags=\\ comment=\\ %s\r\n' \
+ printf '0 0 0 tags=\\ comment=\\ %s\r \\\n' \
"${name}" >>"$meta_db"
RELEASE "$meta_db"
else
delete_meta() {
local name="$1" meta_db="$_DATA/.index/meta"
- local LENGTH WIDTH HEIGHT TAGS COMMENT NAME
+ local LENGTH WIDTH HEIGHT TAGS COMMENT NAME GROUP
[ "${name%%/*}" != "$name" ] \
&& meta_db="$_DATA/${name%%/*}/.index/meta"
name="$(STRING "${name##*/}")"
if LOCK "$meta_db"; then
- while read -r LENGTH WIDTH HEIGHT TAGS COMMENT NAME; do
+ while read -r LENGTH WIDTH HEIGHT TAGS COMMENT NAME GROUP; do
[ "$name" = "${NAME%${CR}}" ] \
- || printf '%i %i %i tags=%s comment=%s %s\r\n' \
+ || printf '%i %i %i tags=%s comment=%s %s\r %s\n' \
"$length" "$width" "$height" "${TAGS#tags=}" \
- "${COMMENT#comment=}" "${NAME%${CR}}"
+ "${COMMENT#comment=}" "${NAME%${CR}}" "${GROUP:-\\}"
done <"$meta_db" >"${meta_db}.$$"
mv -- "${meta_db}.$$" "$meta_db"
list_meta(){
local meta pfx
- local LENGTH WIDTH HEIGHT TAGS COMMENT NAME
+ local LENGTH WIDTH HEIGHT TAGS COMMENT NAME GROUP
if [ "$#" -eq 0 ]; then
find "$_DATA" -path '*/.index/meta'
pfx="$(STRING "${pfx#/}")"
[ "$pfx" = '\' ] && pfx='' || pfx="${pfx}/"
- while read -r LENGTH WIDTH HEIGHT TAGS COMMENT NAME; do
- printf '%i %i %i tags=%s comment=%s %s%s\r\n' \
+ while read -r LENGTH WIDTH HEIGHT TAGS COMMENT NAME GROUP; do
+ printf '%i %i %i tags=%s comment=%s %s%s\r %s\n' \
$LENGTH $WIDTH $HEIGHT "${TAGS#tags=}" \
- "${COMMENT#comment=}" "${pfx}" "${NAME%${CR}}"
+ "${COMMENT#comment=}" "${pfx}" "${NAME%${CR}}" "${GROUP:-\\}"
done <"$meta"
done
}
sort -k6
elif [ $ORDER = Group ]; then
sed -E '
+ /^[^\t]+\t[^\t]+\t[^\t]+\t[^\t]+\t[^\t]+\t[^\r]*\r$/bX;
+ /^[^\t]+\t[^\t]+\t[^\t]+\t[^\t]+\t[^\t]+\t[^\r]*\r\t\\$/bX;
+ s;^([^\t]+\t[^\t]+\t[^\t]+\t[^\t]+\t[^\t]+\t)([^\r]*)\r\t(.*)$;\1\r\3 \2\r\t;;
+ t;
:X
- s;^([^\t]+\t[^\t]+\t[^\t]+\t[^\t]+\t[^\t]+\t[^ 0-9]*)-([0-9a-zA-Z_-]{11}\r|ph[0-9a-f]{13}\r|[0-9]{8}\r)(.*)$;\1-\r\3 \2\n;;
+ s;^([^\t]+\t[^\t]+\t[^\t]+\t[^\t]+\t[^\t]+\t[^ 0-9]*)-([0-9a-zA-Z_-]{11}\r|ph[0-9a-f]{13}\r|[0-9]{8}\r)(.*)$;\1-\r\3 \2;;
t;
s;^([^\t]+\t[^\t]+\t[^\t]+\t[^\t]+\t[^\t]+\t[^ 0-9]*)([0-9]+)(.*)$;\1\r\3 \2;;
tX;' \
ln="$name"
done \
| sort -s -n -k1,1 |sed -E 's;^[0-9]+\t;;;' \
- | sed -E ':X s;^([^\t]+\t[^\t]+\t[^\t]+\t[^\t]+\t[^\t]+\t[^\r]*)\r([^ ]*) ([^ ]+)( .*)?$;\1\3\2\4;; tX'
+ | sed -E '
+ s;^([^\t]+\t[^\t]+\t[^\t]+\t[^\t]+\t[^\t]+\t)\r([0-9A-Za-z:=]{16}) ([^ ]+)$;\1\3\r\t\2;; t;
+ :X s;^([^\t]+\t[^\t]+\t[^\t]+\t[^\t]+\t[^\t]+\t[^\r]*)\r([^ ]*) ([^ ]+)( .*)?$;\1\3\2\4;; tX
+ '
elif [ $ORDER = Length ]; then
sort -sn -k1
elif [ $ORDER = Date ]; then
while read -r fm; do
- fn="$(list_fullname "${fm##* }")"
+ fn="${fm%${CR} *}"
+ fn="$(list_fullname "${fn##* }")"
printf '%i %s\n' \
"$(stat -c %Y "$fn")" "${fm}"
done \