| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
############################################################################## |
|
2
|
|
|
|
|
|
|
# The Faq-O-Matic is Copyright 1997 by Jon Howell, all rights reserved. # |
|
3
|
|
|
|
|
|
|
# # |
|
4
|
|
|
|
|
|
|
# This program is free software; you can redistribute it and/or # |
|
5
|
|
|
|
|
|
|
# modify it under the terms of the GNU General Public License # |
|
6
|
|
|
|
|
|
|
# as published by the Free Software Foundation; either version 2 # |
|
7
|
|
|
|
|
|
|
# of the License, or (at your option) any later version. # |
|
8
|
|
|
|
|
|
|
# # |
|
9
|
|
|
|
|
|
|
# This program is distributed in the hope that it will be useful, # |
|
10
|
|
|
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of # |
|
11
|
|
|
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # |
|
12
|
|
|
|
|
|
|
# GNU General Public License for more details. # |
|
13
|
|
|
|
|
|
|
# # |
|
14
|
|
|
|
|
|
|
# You should have received a copy of the GNU General Public License # |
|
15
|
|
|
|
|
|
|
# along with this program; if not, write to the Free Software # |
|
16
|
|
|
|
|
|
|
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.# |
|
17
|
|
|
|
|
|
|
# # |
|
18
|
|
|
|
|
|
|
# Jon Howell can be contacted at: # |
|
19
|
|
|
|
|
|
|
# 6211 Sudikoff Lab, Dartmouth College # |
|
20
|
|
|
|
|
|
|
# Hanover, NH 03755-3510 # |
|
21
|
|
|
|
|
|
|
# jonh@cs.dartmouth.edu # |
|
22
|
|
|
|
|
|
|
# # |
|
23
|
|
|
|
|
|
|
# An electronic copy of the GPL is available at: # |
|
24
|
|
|
|
|
|
|
# http://www.gnu.org/copyleft/gpl.html # |
|
25
|
|
|
|
|
|
|
# # |
|
26
|
|
|
|
|
|
|
############################################################################## |
|
27
|
|
|
|
|
|
|
|
|
28
|
1
|
|
|
1
|
|
6
|
use strict; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
46
|
|
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
### |
|
31
|
|
|
|
|
|
|
### The Bags module provides services related to bit bags, |
|
32
|
|
|
|
|
|
|
### binary files stored with and linked to by a FAQ-O-Matic. |
|
33
|
|
|
|
|
|
|
### |
|
34
|
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
package FAQ::OMatic::Bags; |
|
36
|
|
|
|
|
|
|
|
|
37
|
1
|
|
|
1
|
|
5
|
use FAQ::OMatic; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
15
|
|
|
38
|
1
|
|
|
1
|
|
5
|
use FAQ::OMatic::Item; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
324
|
|
|
39
|
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub getBagDesc { |
|
41
|
|
|
|
|
|
|
# return an item containing descriptive properties about |
|
42
|
|
|
|
|
|
|
# a bag |
|
43
|
0
|
|
|
0
|
0
|
|
my $bagName = shift; |
|
44
|
|
|
|
|
|
|
|
|
45
|
0
|
|
|
|
|
|
my $bagDesc = new FAQ::OMatic::Item($bagName.".desc", |
|
46
|
|
|
|
|
|
|
$FAQ::OMatic::Config::bagsDir); |
|
47
|
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
# if it didn't exist before... |
|
49
|
0
|
|
|
|
|
|
$bagDesc->setProperty('Title', 'Bag Description'); |
|
50
|
0
|
|
|
|
|
|
$bagDesc->setProperty('filename', $bagName.".desc"); |
|
51
|
|
|
|
|
|
|
|
|
52
|
0
|
|
|
|
|
|
return $bagDesc; |
|
53
|
|
|
|
|
|
|
} |
|
54
|
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
sub getBagProperty { |
|
56
|
0
|
|
|
0
|
0
|
|
my $bagName = shift; |
|
57
|
0
|
|
|
|
|
|
my $property = shift; |
|
58
|
0
|
|
0
|
|
|
|
my $default = shift || ''; |
|
59
|
|
|
|
|
|
|
|
|
60
|
0
|
|
|
|
|
|
my $bagDesc = getBagDesc($bagName); |
|
61
|
0
|
|
0
|
|
|
|
return $bagDesc->getProperty($property) || $default; |
|
62
|
|
|
|
|
|
|
} |
|
63
|
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
sub saveBagDesc { |
|
65
|
0
|
|
|
0
|
0
|
|
my $bagDesc = shift; |
|
66
|
|
|
|
|
|
|
|
|
67
|
0
|
|
|
|
|
|
$bagDesc->saveToFile('', |
|
68
|
|
|
|
|
|
|
$FAQ::OMatic::Config::bagsDir); |
|
69
|
|
|
|
|
|
|
} |
|
70
|
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
sub untaintBagName { |
|
72
|
|
|
|
|
|
|
# untaint a bag name -- result is either a valid name or '' |
|
73
|
0
|
|
|
0
|
0
|
|
my $name = FAQ::OMatic::untaintFilename(shift()); |
|
74
|
|
|
|
|
|
|
# Don't want user overwriting .desc files with binary bags -- YUK! |
|
75
|
0
|
0
|
|
|
|
|
return '' if ($name =~ m/\.desc$/); |
|
76
|
0
|
|
|
|
|
|
return $name; |
|
77
|
|
|
|
|
|
|
} |
|
78
|
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
sub updateDependents { |
|
80
|
0
|
|
|
0
|
0
|
|
my $bagName = shift; |
|
81
|
|
|
|
|
|
|
|
|
82
|
0
|
|
|
|
|
|
my $dependent; |
|
83
|
0
|
|
|
|
|
|
foreach $dependent (FAQ::OMatic::Item::getDependencies("bags.".$bagName)) { |
|
84
|
0
|
|
|
|
|
|
my $dependentItem = new FAQ::OMatic::Item($dependent); |
|
85
|
0
|
|
|
|
|
|
$dependentItem->writeCacheCopy(); |
|
86
|
|
|
|
|
|
|
} |
|
87
|
|
|
|
|
|
|
} |
|
88
|
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
1; |
|
90
|
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
|