Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 8f096737

Von Bernd Blessmann vor fast 13 Jahren hinzugefügt

  • ID 8f09673745acf3c55ad511142dd6b7a85deeebbd
  • Vorgänger 32c9d480
  • Nachfolger d4a434e1

Bei Vorlagensätzen werden auch Unterverzeichnisse und Symlinks kopiert.

Unterschiede anzeigen:

bin/mozilla/admin.pl
37 37
use English qw(-no_match_vars);
38 38
use Fcntl;
39 39
use File::Copy;
40
use File::Find;
41
use File::Spec;
42
use Cwd;
40 43
use IO::File;
41 44
use POSIX qw(strftime);
42 45
use Sys::Hostname;
......
539 542
      umask(007);
540 543

  
541 544
      # copy templates to the directory
542
      my $templatedir = "$::lx_office_conf{paths}->{templates}/mastertemplates/$form->{mastertemplates}";
543 545

  
544
      opendir TEMPLATEDIR, $templatedir or $form->error($templatedir . " : $ERRNO");
545
      my @templates = grep /.*?\.(html|tex|sty|odt|xml|txb)$/,
546
        readdir TEMPLATEDIR;
547
      closedir TEMPLATEDIR;
548

  
549
      foreach my $file (@templates) {
550
        open(TEMP, "<", $templatedir . "/$file")
551
          or $form->error($templatedir . "/$file : $ERRNO");
546
      my $oldcurrdir = getcwd();
547
      if (!chdir("$::lx_office_conf{paths}->{templates}/mastertemplates/$form->{mastertemplates}")) {
548
        $form->error("$ERRNO: chdir $::lx_office_conf{paths}->{templates}/mastertemplates/$form->{mastertemplates}");
549
      }
552 550

  
553
        open(NEW, ">", "$form->{templates}/$file")
554
          or $form->error("$form->{templates}/$file : $ERRNO");
551
      my $newdir = File::Spec->catdir($oldcurrdir, $form->{templates});
552

  
553
      find(
554
        sub
555
        {
556
          next if ($_ eq ".");
557

  
558
          if (-d $_) {
559
            if (!mkdir (File::Spec->catdir($newdir, $File::Find::name))) {
560
              chdir($oldcurrdir);
561
              $form->error("$ERRNO: mkdir $File::Find::name");
562
            }
563
          } elsif (-l $_) {
564
            if (!symlink (readlink($_),
565
                          File::Spec->catfile($newdir, $File::Find::name))) {
566
              chdir($oldcurrdir);
567
              $form->error("$ERRNO: symlink $File::Find::name");
568
            }
569
          } elsif (-f $_ && $_ =~ m/.*?\.(html|tex|sty|odt|xml|txb|eps|pdf|png|jpg)$/) {
570
            if (!copy($_, File::Spec->catfile($newdir, $File::Find::name))) {
571
              chdir($oldcurrdir);
572
              $form->error("$ERRNO: cp $File::Find::name");
573
            }
574
          }
575
        }, "./");
576

  
577
      chdir($oldcurrdir);
555 578

  
556
        while (my $line = <TEMP>) {
557
          print NEW $line;
558
        }
559
        close(TEMP);
560
        close(NEW);
561
      }
562 579
    } else {
563 580
      $form->error("$ERRNO: $form->{templates}");
564 581
    }

Auch abrufbar als: Unified diff