#!/bin/bash
#---------------------------------------------------------------------
##
##=head1 SYNOPSIS
## 
## Url handler functions for grabbing directory urls.
##
##=head1 DESCRIPTION
##
## This type of url was added as a response to the following request:
##
##   I'm an AbiWord developer, and I keep the latest source 
##   tree in my abi directory. If I could make the abi spell 
##   (not to be confused with the abispell) use my current 
##   CVS checked-out tree, that would  be nice.
##
## This file contains functions for I<downloading> (actually it just
## copies, tars, and compresses) directories which can be accessed 
## through the local file system.
##
## Url's of this type are specified using the format 
##
##  dir://<directory>
##
## where <directory> is the full path to a directory that will be
## tarred and compressed for use by sorcery in casting a spell.
##
##=head1 COPYRIGHT
##
## Copyright 2002 by the Source Mage Team
##
##=head1 FUNCTIONS
##
##=over 4
##
#---------------------------------------------------------------------


#---------------------------------------------------------------------
##=item dl_get_dir <url>
## 
## Copies the specified dir url.
##
#---------------------------------------------------------------------
function url_dir_get() {

  local target=$1
  local url_list=$2
  local hints=$3
  local dl_target=$4
  local dl_type=$5
  local url rc=1
  local DIRNAME

  [[ $target ]] || return 255

  for url in $url_list; do
    DIRNAME=`url_dir_crack $url`
    if  test -d  "$DIRNAME"  ; then
      message "Copying $DIRNAME to $target."
      cp  -aR  $DIRNAME $target &&
      message "Finished."
    fi
  done
  
  eval "$dl_target=\"$target\""
  eval "$dl_type=\"tree\""
  return $rc

}

#---------------------------------------------------------------------
##=back
##
##=head1 LICENSE
##
## This software is free software; you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published by
## the Free Software Foundation; either version 2 of the License, or
## (at your option) any later version.
##
## This software is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
## GNU General Public License for more details.
##
## You should have received a copy of the GNU General Public License
## along with this software; if not, write to the Free Software
## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
##
#---------------------------------------------------------------------

