fi
}
-list_fs_browse(){
- meta_dir "$_DATA/$ITEM"
- (cd "$_DATA/$ITEM";
- find ./ -type d \! -name .index -mindepth 1 -maxdepth 1 \
- -exec stat -c '%Y %n' '{}' +
- find ./ -type f -mindepth 1 -maxdepth 1 \
- -exec stat -c '%Y %n' '{}' +
- )
-}
-list_fs_index(){
- local d
- find "$_DATA/$ITEM" -type d -name .index \
- | while d="$(line)"; do
- meta_dir "${d%/.index}"
- done
- (cd "$_DATA/$ITEM";
- find ./ \! -path '*/.index/*' -type f \
- -exec stat -c '%Y %n' '{}' +
- )
-}
-
-list_browse(){
- local meta f fn file
- meta="$_DATA/$ITEM/.index/meta"
- meta_dir "$_DATA/$ITEM"
+list_directories(){
(cd "$_DATA/$ITEM";
find ./ -type d \! -name .index -mindepth 1 -maxdepth 1 \
) | cut -d/ -f2- | sort
- sort -n "$meta" | cut -f6- \
+}
+
+list_filemeta(){
+ local meta base f fn file
+ base="$1"
+ meta="$1/.index/meta"
+ meta_dir "$_DATA/$ITEM/$base"
+
+ grep -iE "$(STRING "${SEARCH}")" "$_DATA/$ITEM/$meta" \
+ | cut -f1,6- \
| while f="$(line)"; do
fn="$(UNSTRING "${f#* }")"; fn="${fn%${CR}}";
- file="$(printf '%s\n' "$_DATA/$ITEM/${fn}".*)"
+ file="$(printf '%s\n' "$_DATA/$ITEM/$base/${fn}".*)"
file="${file##*/}"
- [ -e "$_DATA/$ITEM/${file}" ] \
- && printf '%s\n' "${file}"
+ [ -e "$_DATA/$ITEM/$base/${file}" ] \
+ && printf '%s %s\n' "${f%% *}" "${base}/${file}"
done
}
list_index(){
- local meta base fn file
+ local meta
(cd "$_DATA/$ITEM";
find ./ -path '*/.index/meta'
) | while meta="$(line)"; do
- base="${meta%/.index/meta}"
- meta_dir "$_DATA/$ITEM/$base"
- cut -f1,6- <"$_DATA/$ITEM/$meta" \
- | while f="$(line)"; do
- fn="$(UNSTRING "${f#* }")"; fn="${fn%${CR}}";
- file="$(printf '%s\n' "$_DATA/$ITEM/$base/${fn}".*)"
- file="${file##*/}"
- [ -e "$_DATA/$ITEM/$base/${file}" ] \
- && printf '%s %s\n' "${f%% *}" "${base}/${file}"
- done
- done \
- | sort -n \
- | cut -d/ -f2-
+ list_filemeta "${meta%/.index/meta}"
+ done
}
list_items() {
[ "$mode" = browse -a "$ITEM" ] && printf '..\n'
if [ "$mode" = browse -a "$ORDER" = Date ]; then
- list_fs_browse | sort -rn | cut -d/ -f2-
+ list_directories
+ list_filemeta . |cut -f2- \
+ | xargs -d\n stat -c '%Y %n' \
+ | sort -rn |cut -d/ -f2-
elif [ "$mode" = browse -a "$ORDER" = Name ]; then
- list_fs_browse | sort -k 2 | cut -d/ -f2-
+ list_directories
+ list_filemeta . \
+ | sort -k 2 |cut -d/ -f2-
elif [ "$mode" = index -a "$ORDER" = Date ]; then
- list_fs_index | sort -rn | cut -d/ -f2-
+ list_index |cut -f2- \
+ | xargs -d'\n' stat -c '%Y %n' \
+ | sort -rn | cut -d/ -f2-
elif [ "$mode" = index -a "$ORDER" = Name ]; then
- list_fs_index | sort -k 2 | cut -d/ -f2-
+ list_index | sort -k 2 | cut -d/ -f2-
elif [ "$mode" = browse -a "$ORDER" = Length ]; then
- list_browse
+ list_directories
+ list_filemeta . \
+ | sort -n |cut -d/ -f2-
elif [ "$mode" = index -a "$ORDER" = Length ]; then
- list_index
+ list_index \
+ | sort -n |cut -d/ -f2-
fi
}