/var/lib/sorcery/modules/dl_handlers/dl_file
1 #!/bin/bash
2 #---------------------------------------------------------------------
3 ##
4 ## @Synopsis Url handler functions for grabbing file urls.
5 ## This file contains functions for I<downloading> (actually it just
6 ## copies) files which can be accessed through the local file system.
7 ## Url's of this type are specified using the format
8 ##
9 ## file://<path>
10 ##
11 ## where <path> is the full path to the file.
12 ##
13 ## @Copyright Copyright 2002 by the Source Mage Team
14 ##
15 #---------------------------------------------------------------------
16
17 #---------------------------------------------------------------------
18 ## @param url
19 ##
20 ## Copies the specified file url.
21 ##
22 #---------------------------------------------------------------------
23 function dl_file_get() {
24
25 local target=$1
26 local url_list=$2
27 local hints=$3
28 local dl_target=$4
29 local dl_type=$5
30 local url rc=1
31 local FILENAME
32
33 [[ $target ]] || return 255
34
35 for url in $url_list; do
36 FILENAME=`url_crack $url` &&
37 test -f "$FILENAME" &&
38 test -r "$FILENAME" &&
39 cp -a $FILENAME $target && break
40 done
41
42 eval "$dl_target=\"$target\""
43 eval "$dl_type=\"file\""
44 return $rc
45
46 }
47
48
49 #---------------------------------------------------------------------
50 ##=back
51 ##
52 ##=head1 LICENSE
53 ##
54 ## This software is free software; you can redistribute it and/or modify
55 ## it under the terms of the GNU General Public License as published by
56 ## the Free Software Foundation; either version 2 of the License, or
57 ## (at your option) any later version.
58 ##
59 ## This software is distributed in the hope that it will be useful,
60 ## but WITHOUT ANY WARRANTY; without even the implied warranty of
61 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
62 ## GNU General Public License for more details.
63 ##
64 ## You should have received a copy of the GNU General Public License
65 ## along with this software; if not, write to the Free Software
66 ## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
67 ##
68 #---------------------------------------------------------------------