diff --git a/atom b/atom index b1aa548..a122d94 100755 --- a/atom +++ b/atom @@ -28,7 +28,9 @@ declare -A \ } DOCDIR=./doc +SHAREDIR=./share exampleconf=$DOCDIR/example.cfg +schema=$SHAREDIR/schema.sql #parse arguments #parse config @@ -59,6 +61,9 @@ getConfigGeneral() { 'temporary-directory') tempdir="$value" ;; + 'database') + database="$value" + ;; debug) #unimplemented ;; @@ -197,6 +202,33 @@ getConfig() { #check sanity +openDatabase() { + if [ ! -d "$tempdir" ] + then + mkdir -p "$tempdir" + fi + mkfifo "$tempdir"/sqlite.{in,out} + if [ ! -f "$database" ] + then + if [ ! -d "${database%/*}" ] + then + mkdir -p "${database%/*}" + fi + sqlite3 "$database" < $schema + fi + sqlite3 -line "$database" \ + < "$tempdir/sqlite.in" \ + > "$tempdir/sqlite.out" & + exec 3> "$tempdir"/sqlite.in + exec 4< "$tempdir"/sqlite.out +} + +closeDatabase() { + exec 3>&- + exec 4<&- + rm "$tempdir"/sqlite.{in,out} +} + getFiles() { : } @@ -328,4 +360,8 @@ echo "|Copied mime-type|${destinationcopymime[$destination]//\|/ done }|column -t -s'|' -n +openDatabase + +closeDatabase + # vim:set ts=8 sw=8: