Changeset 31477
- Timestamp:
- 2017-03-09T14:32:44+13:00 (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/trunk/greenstone2/perllib/plugins/DirectoryPlugin.pm
r31459 r31477 238 238 foreach my $e (keys %$exts) { 239 239 # block the file 240 &util::block_filename($block_hash,"$prefix$e");240 $self->block_filename($block_hash,"$prefix$e"); 241 241 # set up as an associatd file 242 242 print STDERR " $self->{'plugin_type'}: Associating $prefix$e with $tie_to version\n"; … … 254 254 255 255 256 # do block exp OR special blocking ???257 258 sub file_is_blocked {259 my $self = shift (@_);260 my ($block_hash, $filename_full_path) = @_;261 262 $filename_full_path = &util::upgrade_if_dos_filename($filename_full_path);263 264 if (($ENV{'GSDLOS'} =~ m/^windows$/) && ($^O ne "cygwin")) {265 # on windows, all block paths are lowercased.266 my $lower_filename = lc ($filename_full_path);267 if (defined $block_hash->{'file_blocks'}->{$lower_filename}) {268 $self->{'num_blocked'} ++;269 return 1;270 }271 }272 else {273 if (defined $block_hash->{'file_blocks'}->{$filename_full_path}) {274 $self->{'num_blocked'} ++;275 return 1;276 }277 }278 # check Directory plugin's own block_exp279 if ($self->{'block_exp'} ne "" && $filename_full_path =~ /$self->{'block_exp'}/) {280 $self->{'num_blocked'} ++;281 return 1; # blocked282 }283 return 0;284 }285 286 256 287 257 … … 334 304 335 305 # Recursively read each $raw_subfile 336 print $outhandle "DirectoryPlugin block recurring: ". Encode::decode("utf8", $raw_file_subfile) ."\n" if ($verbosity > 2); 337 print $outhandle "DirectoryPlugin block recurring: ". Encode::decode(locale =>$raw_file_subfile) ."\n" if ($verbosity > 2); 338 306 print $outhandle "DirectoryPlugin block recurring: $raw_file_subfile\n" if ($verbosity > 2); 339 307 #$count += &plugin::file_block_read ($pluginfo, $this_file_base_dir, 340 308 … … 434 402 # but with URL style slashes. 435 403 my $local_dirname = &util::filename_within_directory_url_format($dirname, $base_dir); 436 ### need it in perl unicode, not raw filesystem437 my $filename_encoding = $self->guess_filesystem_encoding();438 439 # copied this from set_Source_metadata in BasePlugin440 if ((defined $filename_encoding) && ($filename_encoding ne "ascii")) {441 # Use filename_encoding to map raw filename to a Perl unicode-aware string442 $local_dirname = decode($filename_encoding,$local_dirname);443 }444 else {445 # otherwise generate %xx encoded version of filename for char > 127446 $local_dirname = &unicode::raw_filename_to_url_encoded($local_dirname);447 }448 404 449 405 # if we are in import folder, then local_dirname will be empty 450 406 if ($local_dirname ne "") { 407 # convert to perl unicode 408 $local_dirname = $self->raw_filename_to_unicode($local_dirname); 409 451 410 # look for extra metadata passed down from higher folders 452 411 $local_dirname .= "/"; # closing slash must be URL type slash also and not $dirsep; … … 476 435 my $raw_file_subfile = &FileUtils::filenameConcatenate($file, $raw_subfile); 477 436 my $raw_full_filename = &FileUtils::filenameConcatenate($this_file_base_dir, $raw_file_subfile); 478 479 if ($self->file_is_blocked($block_hash,$raw_full_filename)) { 480 print STDERR "DirectoryPlugin: file $raw_full_filename was blocked for metadata_read\n" if ($verbosity > 2); 437 if ($self->raw_file_is_blocked($block_hash, $raw_full_filename)) { 438 print STDERR "DirectoryPlugin: file $raw_full_filename was blocked for metadata_read\n";# if ($verbosity > 2); 439 print STDERR "raw file was blocked for metadata read\n"; 440 print STDERR &unicode::debug_unicode_string($raw_full_filename)."\n"; 481 441 next; 482 442 } 483 443 484 444 # Recursively read each $raw_subfile 485 print $outhandle "DirectoryPlugin metadata recurring: $raw_subfile\n" if ($verbosity > 2);445 print $outhandle "DirectoryPlugin metadata recurring: $raw_subfile\n"; # if ($verbosity > 2); 486 446 487 447 &plugin::metadata_read ($pluginfo, $this_file_base_dir, … … 560 520 my $raw_full_filename 561 521 = &FileUtils::filenameConcatenate($this_file_base_dir,$raw_file_subfile); 562 522 my $full_unicode_file = $self->raw_filename_to_unicode($raw_full_filename); 523 print STDERR "full unicode filename $full_unicode_file\n"; 524 print STDERR &unicode::debug_unicode_string($full_unicode_file)."\n"; 525 if ($self->file_is_blocked($block_hash,$full_unicode_file)) { 526 print STDERR "Actually, we have blocked the unicode version\n"; 527 next; 528 } 563 529 if ($self->file_is_blocked($block_hash,$raw_full_filename)) { 564 print STDERR "DirectoryPlugin: file $raw_full_filename was blocked for read\n" if ($verbosity > 2);530 print STDERR "DirectoryPlugin: file $raw_full_filename was blocked for read\n"; # if ($verbosity > 2); 565 531 next; 566 532 } 567 568 533 # Follow Windows shortcuts 569 534 if ($raw_subfile =~ m/(?i)\.lnk$/ && (($ENV{'GSDLOS'} =~ m/^windows$/i) && ($^O ne "cygwin"))) {
Note:
See TracChangeset
for help on using the changeset viewer.