| 3 |
# $Id$ |
# $Id$ |
| 4 |
# |
# |
| 5 |
# $Log$ |
# $Log$ |
| 6 |
|
# Revision 1.4 2002/08/16 19:06:39 cvsjoko |
| 7 |
|
# + sub getDirList |
| 8 |
|
# |
| 9 |
# Revision 1.3 2002/07/19 18:13:50 cvsjoko |
# Revision 1.3 2002/07/19 18:13:50 cvsjoko |
| 10 |
# no message |
# no message |
| 11 |
# |
# |
| 30 |
stripHtml stripSpaces stripNewLines toReal trim |
stripHtml stripSpaces stripNewLines toReal trim |
| 31 |
croak |
croak |
| 32 |
array_getDifference |
array_getDifference |
| 33 |
|
getDirList |
| 34 |
); |
); |
| 35 |
|
|
| 36 |
use strict; |
use strict; |
| 51 |
|
|
| 52 |
use Carp; |
use Carp; |
| 53 |
|
|
| 54 |
|
use DirHandle; |
| 55 |
|
|
| 56 |
|
|
| 57 |
######################################## |
######################################## |
| 58 |
|
|
| 133 |
return $res->{diff}; |
return $res->{diff}; |
| 134 |
} |
} |
| 135 |
|
|
| 136 |
|
|
| 137 |
|
# ============================================= |
| 138 |
|
# "global" vars used in directory-recursive-parsing |
| 139 |
|
my $dirlist_buf; |
| 140 |
|
my @dirlist_path; |
| 141 |
|
my $dirlist_base; |
| 142 |
|
|
| 143 |
|
sub entry_callback { |
| 144 |
|
|
| 145 |
|
my $entry = shift; |
| 146 |
|
|
| 147 |
|
# CHECKS |
| 148 |
|
# dont't use this: |
| 149 |
|
if ($entry eq '.' || $entry eq '..') { return; } |
| 150 |
|
|
| 151 |
|
# PREPARE |
| 152 |
|
# prepare path to current entry |
| 153 |
|
my $cur_entry = join('/', @dirlist_path, $entry); |
| 154 |
|
# prepare path to current entry (absolute) |
| 155 |
|
my $cur_entry_abs = join('/', $dirlist_base, @dirlist_path, $entry); |
| 156 |
|
|
| 157 |
|
# ENTRY |
| 158 |
|
# add current entry to buffer |
| 159 |
|
$dirlist_buf .= $cur_entry . "\n"; |
| 160 |
|
|
| 161 |
|
# (SUB-)DIRECTORY |
| 162 |
|
# check if current entry is a (sub-)directory ... |
| 163 |
|
if (-d $cur_entry_abs) { |
| 164 |
|
push @dirlist_path, $cur_entry; |
| 165 |
|
# ... and parse this (recursion here!!!) |
| 166 |
|
iterate_path($cur_entry_abs); |
| 167 |
|
pop @dirlist_path; |
| 168 |
|
} |
| 169 |
|
} |
| 170 |
|
|
| 171 |
|
sub iterate_path { |
| 172 |
|
|
| 173 |
|
my $path = shift; |
| 174 |
|
|
| 175 |
|
# create new "DirHandle"-object |
| 176 |
|
my $d = new DirHandle $path; |
| 177 |
|
if (defined $d) { |
| 178 |
|
|
| 179 |
|
# iterate through all entries in $path ($d->read) and call out entry-handler on each entry |
| 180 |
|
while (defined(my $line = $d->read)) { |
| 181 |
|
entry_callback($line); |
| 182 |
|
} |
| 183 |
|
|
| 184 |
|
undef $d; |
| 185 |
|
} |
| 186 |
|
} |
| 187 |
|
|
| 188 |
|
sub getDirList { |
| 189 |
|
|
| 190 |
|
$dirlist_base = shift; |
| 191 |
|
|
| 192 |
|
# reset vars |
| 193 |
|
$dirlist_buf = ''; |
| 194 |
|
@dirlist_path = (); |
| 195 |
|
|
| 196 |
|
# start parsing file-structure |
| 197 |
|
iterate_path($dirlist_base); |
| 198 |
|
|
| 199 |
|
# return complete list of directory-content including files and subdirs |
| 200 |
|
# entries are newline (\n) - seperated |
| 201 |
|
return $dirlist_buf; |
| 202 |
|
|
| 203 |
|
} |
| 204 |
|
# ============================================= |
| 205 |
|
|
| 206 |
|
|
| 207 |
1; |
1; |