version 1.1504, 2023/03/19 16:05:48
|
version 1.1505, 2023/03/27 18:41:07
|
Line 12105 sub stat_file {
|
Line 12105 sub stat_file {
|
# files which have a matching extension will be ignored. |
# files which have a matching extension will be ignored. |
# $nonemptydir - if true, will only populate $fileshashref hash entry for a particular |
# $nonemptydir - if true, will only populate $fileshashref hash entry for a particular |
# directory with first file found (with acceptable extension). |
# directory with first file found (with acceptable extension). |
|
# $addtopdir - if true, set $dirhashref->{'/'} = 1 |
# $toppath - Top level directory (i.e., /res/$dom/$uname or /priv/$dom/$uname |
# $toppath - Top level directory (i.e., /res/$dom/$uname or /priv/$dom/$uname |
# $relpath - Current path (relative to top level). |
# $relpath - Current path (relative to top level). |
# $dirhashref - reference to hash to populate with URLs of directories (Required) |
# $dirhashref - reference to hash to populate with URLs of directories (Required) |
Line 12121 sub stat_file {
|
Line 12122 sub stat_file {
|
# |
# |
|
|
sub recursedirs { |
sub recursedirs { |
my ($is_home,$recurse,$include,$exclude,$nonemptydir,$toppath,$relpath,$dirhashref,$filehashref) = @_; |
my ($is_home,$recurse,$include,$exclude,$nonemptydir,$addtopdir,$toppath,$relpath,$dirhashref,$filehashref) = @_; |
return unless (ref($dirhashref) eq 'HASH'); |
return unless (ref($dirhashref) eq 'HASH'); |
my $docroot = $perlvar{'lonDocRoot'}; |
my $docroot = $perlvar{'lonDocRoot'}; |
my $currpath = $docroot.$toppath; |
my $currpath = $docroot.$toppath; |
Line 12139 sub recursedirs {
|
Line 12140 sub recursedirs {
|
$checkexc = 1; |
$checkexc = 1; |
} |
} |
if ($is_home) { |
if ($is_home) { |
if (opendir(my $dirh,$currpath)) { |
if ((-e $currpath) && (opendir(my $dirh,$currpath))) { |
my $filecount = 0; |
my $filecount = 0; |
foreach my $item (sort { lc($a) cmp lc($b) } grep(!/^\.+$/,readdir($dirh))) { |
foreach my $item (sort { lc($a) cmp lc($b) } grep(!/^\.+$/,readdir($dirh))) { |
next if ($item eq ''); |
next if ($item eq ''); |
Line 12152 sub recursedirs {
|
Line 12153 sub recursedirs {
|
} |
} |
$dirhashref->{&Apache::lonlocal::js_escape($newpath)} = 1; |
$dirhashref->{&Apache::lonlocal::js_escape($newpath)} = 1; |
if ($recurse) { |
if ($recurse) { |
&recursedirs($is_home,$recurse,$include,$exclude,$nonemptydir,$toppath,$newpath,$dirhashref,$filehashref); |
&recursedirs($is_home,$recurse,$include,$exclude,$nonemptydir,$addtopdir,$toppath,$newpath,$dirhashref,$filehashref); |
} |
} |
} elsif (($savefile) || ($relpath eq '')) { |
} elsif (($savefile) || ($relpath eq '')) { |
next if ($nonemptydir && $filecount); |
next if ($nonemptydir && $filecount); |
Line 12165 sub recursedirs {
|
Line 12166 sub recursedirs {
|
next if ($extension && $exclude->{$extension}); |
next if ($extension && $exclude->{$extension}); |
} |
} |
} |
} |
if (($relpath eq '') && (!exists($dirhashref->{'/'}))) { |
if (($relpath eq '') && (!exists($dirhashref->{'/'}))) { |
$dirhashref->{'/'} = 1; |
$dirhashref->{'/'} = 1; |
} |
} |
if ($savefile) { |
if ($savefile) { |
Line 12206 sub recursedirs {
|
Line 12207 sub recursedirs {
|
} |
} |
$dirhashref->{&Apache::lonlocal::js_escape($newpath)} = 1; |
$dirhashref->{&Apache::lonlocal::js_escape($newpath)} = 1; |
if ($recurse) { |
if ($recurse) { |
&recursedirs($is_home,$recurse,$include,$exclude,$nonemptydir,$toppath,$newpath,$dirhashref,$filehashref); |
&recursedirs($is_home,$recurse,$include,$exclude,$nonemptydir,$addtopdir,$toppath,$newpath,$dirhashref,$filehashref); |
} |
} |
} elsif (($savefile) || ($relpath eq '')) { |
} elsif (($savefile) || ($relpath eq '')) { |
next if ($nonemptydir && $filecount); |
next if ($nonemptydir && $filecount); |
Line 12234 sub recursedirs {
|
Line 12235 sub recursedirs {
|
} |
} |
} |
} |
} |
} |
|
if ($addtopdir) { |
|
if (($relpath eq '') && (!exists($dirhashref->{'/'}))) { |
|
$dirhashref->{'/'} = 1; |
|
} |
|
} |
return; |
return; |
} |
} |
|
|