| 1 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | =encoding utf8 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | =head1 NAME | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | Quiq::DestinationTree - Verwalte Zielbaum eines Datei-Generators | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | =head1 BASE CLASS | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | L<Quiq::Object> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | use Quiq::DestinationTree; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | $dt = Quiq::DestinationTree->(@dirs); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | ... | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | # Dateien und Verzeichnisse erzeugen | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | $dt->addFile($file,$content); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | $dt->addDir($dir); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | ... | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | # Überzählige Dateien und Verzeichnisse entfernen | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | $dt->cleanup; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | Die Klasse verwaltet die Dateien und Unterverzeichnisse von | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | einem oder mehreren Zielverzeichnissen. Sie ist für Dateigeneratoren | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | gedacht, die den Inhalt ihrer Zielverzeichnisse komplett | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | kontrollieren. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | package Quiq::DestinationTree; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | 2 | ▶ | use base qw/Quiq::Object/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | 2 | ▶ | use v5.10; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | 2 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | 2 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 2 | ▶ | use utf8; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | 2 | our $VERSION = '1.240'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | 2 | ▶ | use Quiq::Option; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | 2 | ▶ | use Quiq::DirHandle; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | 2 | ▶ | use Quiq::Path; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | 2 | ▶ | use Quiq::Terminal; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | =head1 METHODS | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | =head2 Konstruktor | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | =head3 new() - Konstruktor | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | =head4 Synopsis | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | $tree = $class->new(@dirs,@opt); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | =head4 Options | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | =item -cleanup => $bool (Default: 0) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | Entferne alle Dateien und Verzeichnisse, die generiert wurden. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | Diese Option ist für ein "make clean" nützlich. Im Unterschied | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | zu einem $tree->cleanup() direkt nach Objektinstantiierung, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | werden hierbei Dateien, die mit -writeInitially=>1 erzeugt wurden, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | nur dann gelöscht, wenn sie nicht modifiziert wurden. Wurden | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | sie modifiziert, bleiben sie erhalten. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | =item -dryRun => $bool (Default: 0) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | Ändere nichts, zeige die Operationen nur an. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | =item -exclude => $regex (Default: keiner) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | Schließe alle Dateien, die Regex $regex erfüllen von der Betrachtung | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | aus. D.h. diese werden vom Nutzer der Klasse nicht verwaltet (weder | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | erzeugt noch entfernt). | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | =item -files => \@files (Default: []) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | Liste von Einzeldateien. Beispiel: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | -files=>[glob '*_1.sql'], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | =item -force => $bool (Default: 0) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | Forciere das Schreiben aller Dateien, auch wenn ihr Inhalt nicht | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | differiert. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | =item -include => $regex (Default: keiner) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | Berücksichtige nur Dateien, die Regex $regex erfüllen, alle anderen | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | werden von der Klasse nicht verwaltet (weder erzeugt noch entfernt). | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | =item -inHandle => $fh (Default: \*STDIN) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | Filehandle, von der Benutzereingaben gelesen werden. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | =item -language => 'de'|'en' (Default: 'de') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | Sprache für die Kommunikation mit dem Benutzer. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | =item -prefix => $str (Default: '') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | Setze Zeichenkette $str an den Anfang jeder Änderungsmeldung. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | Beispiel: C<< -prefix=>'* ' >> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | =item -quiet => $bool (Default: 0) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | Schreibe keine Meldungen nach STDERR. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | =item -outHandle => $fh (Default: \*STDOUT) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | Filehandle, auf die Ausgaben geschrieben werden. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | =head4 Description | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | Instantiiere ein Dateibaumobjekt über den Verzeichnissen @dirs | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | und liefere eine Referenz auf dieses Objekt zurück. Die Verzeichnisse | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | in @dirs müssen nicht existieren. Hat ein Verzeichnis die Form | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | "DIR/*" wird nicht rekursiv in DIR abgestiegen, sondern nur | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | die Dateien (nicht die Verzeichnisse) in DIR werden verwaltet. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | 2 | ▶ | sub new { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=17 SCAR=38.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | 2 | my $class = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | # @_: @dirs,@opt | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | 2 | my $cleanup = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | 2 | my $dryRun = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | 2 | my $exclude = undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | 2 | my $files = []; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | 2 | my $force = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | 2 | my $include = undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | 2 | my $inHandle = \*STDIN; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | 2 | my $language = 'de'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | 2 | my $outHandle = \*STDOUT; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | 2 | my $prefix = ''; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | 2 | my $quiet = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | 2 | Quiq::Option->extract(-mode=>'sloppy',\@_, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | -cleanup => \$cleanup, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | -dryRun => \$dryRun, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | -exclude => \$exclude, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | -files => \$files, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | -force => \$force, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | -include => \$include, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | -inHandle => \$inHandle, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | -language => \$language, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | -outHandle => \$outHandle, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | -prefix => \$prefix, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | -quiet => \$quiet, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | 2 | my %path; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | 2 | for my $dir (@_) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | 2 | ▶ | next if defined $dir && $dir ne '' && !-e $dir; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
defined $dir and $dir ne "" and not -e $dir
defined $dir and $dir ne ""
MC/DC0%0/3
defined $dir and $dir ne "" and not -e $dir
defined $dir
$dir ne ""
not -e $dir
Truth table25%1/4
A and B and not(C)
A= defined $dirB= $dir ne ""C= not -e $dir
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | 2 | ▶ | if ((my $dir) = $dir =~ m|(.*)/\*$|) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | # Füge nur die Dateien aus dem Verzeichnis hinzu, steige | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | # nicht in Subverzeichnisse ab | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | 0 | my $dh = Quiq::DirHandle->new($dir); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | 0 | ▶ | while (my $path = $dh->next) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | 0 | $path = "$dir/$path"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | 0 | ▶ | next if !-f $path; # wir verwalten nur die Dateien | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | 0 | ▶ | next if $exclude && $path =~ /$exclude/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$exclude and $path =~ /$exclude/
MC/DC0%0/2
$exclude and $path =~ /$exclude/
$exclude
$path =~ /$exclude/
Truth table0%0/3
A and B
A= $excludeB= $path =~ /$exclude/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | 0 | ▶ | next if $include && $path !~ /$include/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$include and not $path =~ /$include/
MC/DC0%0/2
$include and not $path =~ /$include/
$include
not $path =~ /$include/
Truth table0%0/3
A and not(B)
A= $includeB= not $path =~ /$include/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | 0 | $path{$path} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | 0 | $dh->close; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | # Rekursiver Abstieg | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | 2 | for (Quiq::Path->find($dir, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | -exclude => $exclude, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | )) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | 4 | s|^\./||; # ./ am Pfadanfang entfernen | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | 4 | ▶ | next if $_ eq ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | # next if $exclude && /$exclude/; # hier ignorieren wir Dateien | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | # füge Verzeichnisse immer hinzu, wenn sie nicht excluded wurden | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | 4 | ▶ | if (-d) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | 2 | $path{$_} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | 2 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | 2 | ▶ | next if $include && !/$include/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$include and not /$include/
MC/DC0%0/2
$include and not /$include/
$include
not /$include/
Truth table33%1/3
A and not(B)
A= $includeB= not /$include/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | 2 | $path{$_} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | # Einzeldateien | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | 2 | @path{@$files} = (1) x @$files; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | 2 | return bless [ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | \%path, # [0] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | $force, # [1] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | $quiet, # [2] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | $cleanup, # [3] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | $inHandle, # [4] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | $outHandle, # [5] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | $language, # [6] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | $prefix, # [7] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | $dryRun, # [8] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | ],$class; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | =head2 Objektmethoden | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | =head3 addDir() - Füge Verzeichnis zum Dateibaum hinzu | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | =head4 Synopsis | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | $bool = $tree->addDir($dir); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | =head4 Description | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | Füge Verzeichnis $dir zum Dateibaum hinzu. Die Methode liefert 1, wenn | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | das Verzeichnis effektiv erzeugt wurde (s.u.) oder 0, wenn dies nicht | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | der Fall war. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | Das Verzeichnis wird effektiv nur erzeugt, wenn es noch nicht | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | existiert. In dem Fall schreibt die Methode eine entsprechende Meldung | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | auf den Ausgabekanal und liefert als Returnwert 1. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | Der Rückgabewert kann benutzt werden, um im Falle der | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | Verzeichniserzeugung weitere Aktionen auszuführen, wie z.B. das Setzen | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | von Verzeichnisrechten. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | 32 | ▶ | sub addDir { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
addDir: called CC=7 SCAR=20.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | 32 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | 32 | my $dir = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | # Nulloperation, wenn Konstruktor-Option -cleanup | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | 32 | ▶ | return 0 if $self->[3]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | # Nulloperation, wenn kein Pfad angegeben | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | 32 | ▶ | return if !$dir; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | # ./ am Pfadanfang entfernen | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | 32 | $dir =~ s|^\./||; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | # Eintrag entfernen | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | 32 | delete $self->[0]{$dir}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | # Vaterverzeichnis hinzufügen, falls vorhanden | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | 32 | my ($parent) = $dir =~ m|(.*)/|; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | 32 | ▶ | $self->addDir($parent) if $parent; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | # Verzeichnis erzeugen, wenn es nicht existiert | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | 32 | ▶ | if (!-e $dir) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | 3 | ▶ | if (!$self->[8]) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | 3 | Quiq::Path->mkdir($dir); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | 3 | ▶ | if (!$self->[2]) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | 0 | my $out = $self->[5]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | 0 | my $msg = $self->getText('Verzeichnis erzeugt'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | 0 | print $out "$self->[7]$dir -- $msg\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | 3 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | 29 | return 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | =head3 paths() - Liefere die Liste der Pfade | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | =head4 Synopsis | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | @paths | $pathA = $tree->paths; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | =head4 Description | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | Liefere die Liste der Pfade, die zu den Zielverzeichnissen gehören. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | =over 2 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 309 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 310 | =item * | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 311 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 312 | Die Reihenfolge ist undefiniert. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 313 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 314 | =item * | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 315 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 316 | Die Liste enthält sowohl Verzeichnisse also auch Dateien. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 317 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 318 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 319 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 320 | Sortierung herstellen: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 321 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 322 | @paths = sort $tree->paths; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 323 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 324 | Nur Dateien erhalten: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 325 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 326 | @paths = grep {!-d} $tree->paths; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 327 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 328 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 329 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 330 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 331 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 332 | 0 | ▶ | sub paths { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
paths: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 333 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 334 | 0 | my @paths = keys %{$self->[0]}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 335 | 0 | ▶ | return wantarray? @paths: \@paths; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 336 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 337 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 338 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 339 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 340 | =head3 addFile() - Füge Datei zum Dateibaum hinzu | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 341 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 342 | =head4 Synopsis | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 343 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 344 | $bool = $tree->addFile($file,$data,@opt); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 345 | $bool = $tree->addFile($file,\$data,@opt); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 346 | $bool = $tree->addFile($file,@opt); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 347 | $bool = $tree->addFile($file, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 348 | -generate => $bool, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 349 | -onGenerate => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 350 | ... | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 351 | return $data; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 352 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 353 | @opt | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 354 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 355 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 356 | =head4 Options | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 357 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 358 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 359 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 360 | =item -encoding => $encoding (Default: undef) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 361 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 362 | Encodiere/decodiere die Daten mit Encoding $encoding. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 363 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 364 | =item -force => $bool (Default: 0) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 365 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 366 | Forciere das Schreiben der Datei ohne den Dateiinhalt zu vergleichen. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 367 | Die Option ist nützlich, wenn der Aufrufer bereits festgestellt hat, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 368 | dass eine Differenz besteht. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 369 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 370 | =item -generate => $bool (Default: 0) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 371 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 372 | Rufe die onGenerate-Subroutine auf, um den Dateiinhalt zu generieren. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 373 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 374 | =item -onGenerate => sub { ... } (Default: undef) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 375 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 376 | Die Subroutine generiert und liefert den Inhalt der Datei. Sie wird | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 377 | aufgerufen, wenn Argument $data nicht definiert ist und die Datei | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 378 | nicht existiert oder Option -generate I<wahr> ist. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 379 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 380 | =item -onUpdate => sub { ... } (Default: undef) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 381 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 382 | Führe Subroutine aus, I<bevor> Datei $file geschrieben wird. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 383 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 384 | =item -quiet => $bool (Default: 0) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 385 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 386 | Unterdrücke Ausgabe der Meldung. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 387 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 388 | =item -skipEmptyFiles => $bool | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 389 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 390 | Übergehe Dateien mit leerem Inhalt. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 391 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 392 | =item -writeInitially => $bool (Default: 0) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 393 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 394 | Schreibe Datei nur, wenn sie nicht existiert. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 395 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 396 | Diese Option ist nützlich, wenn von einer Datei ein anfängliches | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 397 | Muster erzeugt werden soll, das anschließend manuell bearbeitet werden | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 398 | kann. Die manuell bearbeitete Datei soll danach natürlich nicht mehr | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 399 | vom Muster überschieben werden. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 400 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 401 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 402 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 403 | =head4 Description | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 404 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 405 | Füge Datei $file mit dem Inhalt $data zum Dateibaum hinzu. Die | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 406 | Methode liefert 0, wenn die Datei nicht geschrieben wurde, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 407 | 1, wenn die Datei existiert hat und geschrieben wurde, 2, wenn | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 408 | die Datei neu erzeugt wurde. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 409 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 410 | Ist $data C<undef> wird die Datei nicht geschrieben, bleibt | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 411 | aber weiter bestehen. Dies ist nützlich, wenn es teuer ist, den Inhalt | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 412 | der Datei zu generieren, und bekannt ist, dass sich am Inhalt nichts | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 413 | geändert hat. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 414 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 415 | Die Datei wird effektiv geschrieben, wenn sie nicht existiert oder der | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 416 | Inhalt differiert. In dem Fall schreibt die Methode eine entsprechende | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 417 | Meldung nach STDERR und liefert als Returnwert 1. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 418 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 419 | Der Rückgabewert kann benutzt werden, um im Falle des Schreibens | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 420 | der Datei weitere Aktionen auszuführen, wie z.B. das Setzen von | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 421 | Dateirechten. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 422 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 423 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 424 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 425 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 426 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 427 | 3 | ▶ | sub addFile { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
addFile: called CC=29 SCAR=51.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 428 | 3 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 429 | 3 | my $file = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 430 | 3 | ▶ | my $dataR = @_%2? (ref $_[0]? shift: \shift): undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 431 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 432 | 3 | my $encoding = undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 433 | 3 | my $force = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 434 | 3 | my $generate = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 435 | 3 | my $onGenerate = undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 436 | 3 | my $onUpdate = undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 437 | 3 | my $quiet = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 438 | 3 | my $skipEmptyFiles = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 439 | 3 | my $writeInitially = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 440 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 441 | 3 | Quiq::Option->extract(\@_, # ehedem: -mode=>'strict-dash' | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 442 | -encoding => \$encoding, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 443 | -force => \$force, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 444 | -generate => \$generate, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 445 | -onGenerate => \$onGenerate, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 446 | -onUpdate => \$onUpdate, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 447 | -quiet => \$quiet, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 448 | -skipEmptyFiles => \$skipEmptyFiles, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 449 | -writeInitially => \$writeInitially, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 450 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 451 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 452 | # Wir ignorieren leere Dateien, wenn -skipEmptyFiles=>1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 453 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 454 | 3 | ▶ | if ($skipEmptyFiles && (!$dataR || !defined $$dataR || $$dataR eq '')) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition11%1/9
$skipEmptyFiles and !($dataR && defined $$dataR) || $$dataR eq ""
not $dataR && defined $$dataR or $$dataR eq ""
$dataR && defined $$dataR
MC/DC0%0/4
$skipEmptyFiles and !($dataR && defined $$dataR) || $$dataR eq ""
$skipEmptyFiles
$dataR
defined $$dataR
$$dataR eq ""
Truth table20%1/5
A and not(B && C) or D
A= $skipEmptyFilesB= $dataRC= defined $$dataRD= $$dataR eq ""
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 455 | 0 | return 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 456 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 457 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 458 | # ./ am Pfadanfang entfernen | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 459 | 3 | $file =~ s|^\./||; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 460 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 461 | # Verzeichnis ermitteln | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 462 | 3 | my ($dir) = $file =~ m|(.*)/|; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 463 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 464 | # Wir wissen, dass die Datei nicht modifiziert wurde und wollen | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 465 | # sie nicht schreiben. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 466 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 467 | 3 | ▶ | if (!defined $dataR || !defined $$dataR) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $dataR and defined $$dataR
MC/DC0%0/2
defined $dataR and defined $$dataR
defined $dataR
defined $$dataR
Truth table33%1/3
A and B
A= defined $dataRB= defined $$dataR
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 468 | 0 | ▶ | if ((!-e $file || $generate) && $onGenerate) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition0%0/6
!(-e $file) || $generate and $onGenerate
not -e $file or $generate
MC/DC0%0/3
!(-e $file) || $generate and $onGenerate
not -e $file
$generate
$onGenerate
Truth table0%0/5
not(A) or B and C
A= not -e $fileB= $generateC= $onGenerate
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 469 | # Wir generieren den Inhalt der Datei | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 470 | 0 | $dataR = \$onGenerate->($file); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 471 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 472 | elsif (!-e $file) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 473 | # Fataler Fehler. Die Datei existiert nicht und wir können | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 474 | # ihren Inhalt nicht erzeugen, da wir ihn nicht haben. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 475 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 476 | 0 | $self->throw( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 477 | 'DTREE-00001: Datei existiert nicht. Ohne Inhalt kann sie nicht angelegt werden.', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 478 | File => $file, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 479 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 480 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 481 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 482 | # Als Dateiinhalt wurde undef übergeben und die Datei existiert. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 483 | # Wir registrieren die Datei als existent und kehren zurück. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 484 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 485 | 0 | $self->addDir($dir); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 486 | 0 | delete $self->[0]{$file}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 487 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 488 | 0 | return 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 489 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 490 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 491 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 492 | # Nulloperation, bei Konstruktor-Option -cleanup=>1. Ist die | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 493 | # Option -writeInitially=>1 angegeben, wird die Datei aus | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 494 | # der Pfadliste entfernt, wenn sie existiert und nicht identisch ist, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 495 | # d.h. sie wird im Zuge des cleanup *nicht* gelöscht. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 496 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 497 | 3 | ▶ | if ($self->[3]) { # cleanup | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 498 | 0 | ▶ | if ($writeInitially && -e $file && | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
$writeInitially and -e $file and "Quiq::Path"->read($file, "-decode", $encoding) ne $$dataR
$writeInitially and -e $file
MC/DC0%0/3
$writeInitially and -e $file and "Quiq::Path"->read($file, "-decode", $encoding) ne $$dataR
$writeInitially
-e $file
"Quiq::Path"->read($file, "-decode", $encoding) ne $$dataR
Truth table0%0/4
A and B and C
A= $writeInitiallyB= -e $fileC= "Quiq::Path"->read($file, "-decode", $encoding) ne $$dataR
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 499 | Quiq::Path->read($file,-decode=>$encoding) ne $$dataR) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 500 | # Eintrag entfernen, d.h. Datei am Ende *nicht* löschen | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 501 | 0 | delete $self->[0]{$file}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 502 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 503 | 0 | return 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 504 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 505 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 506 | # Eintrag entfernen | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 507 | 3 | delete $self->[0]{$file}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 508 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 509 | # Existenz der Datei ermitteln | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 510 | 3 | my $fileExists = -e $file; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 511 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 512 | # Datei nicht schreiben, wenn sie bereits existiert | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 513 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 514 | 3 | ▶ | if ($writeInitially && $fileExists) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$writeInitially and $fileExists
MC/DC0%0/2
$writeInitially and $fileExists
$writeInitially
$fileExists
Truth table33%1/3
A and B
A= $writeInitiallyB= $fileExists
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 515 | 0 | $self->addDir($dir); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 516 | 0 | return 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 517 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 518 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 519 | # Inhalt vergleichen. Wenn identisch, Datei nicht schreiben. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 520 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 521 | 3 | ▶ | if ($self->[1] || $force || !$fileExists) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%3/6
$self->[1] or $force or not $fileExists
$self->[1] or $force
MC/DC33%1/3
$self->[1] or $force or not $fileExists
$self->[1]
$force
not $fileExists
Truth table50%2/4
A or B or not(C)
A= $self->[1]B= $forceC= not $fileExists
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 522 | # nichts tun, wir schreiben auf jeden Fall | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 523 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 524 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 525 | # Datei existiert. Prüfen, ob die Daten differieren. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 526 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 527 | 2 | ▶ | if (Quiq::Path->read($file,-decode=>$encoding) eq $$dataR) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 528 | 1 | $self->addDir($dir); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 529 | 1 | return 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 530 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 531 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 532 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 533 | # Callbackmethode vor dem Schreiben | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 534 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 535 | 2 | ▶ | if ($onUpdate) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 536 | 0 | $self->$onUpdate($file,$$dataR); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 537 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 538 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 539 | # Verzeichnis hinzufügen | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 540 | 2 | $self->addDir($dir); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 541 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 542 | # Datei schreiben | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 543 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 544 | 2 | ▶ | if (!$self->[8]) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 545 | 2 | Quiq::Path->write($file,$$dataR,-encode=>$encoding); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 546 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 547 | 2 | ▶ | if (!$self->[2] && !$quiet) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$self->[2] or $quiet
MC/DC0%0/2
$self->[2] or $quiet
$self->[2]
$quiet
Truth table33%1/3
A or B
A= $self->[2]B= $quiet
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 548 | 0 | my $out = $self->[5]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 549 | 0 | ▶ | my $msg = $self->getText($fileExists? 'Datei aktualisiert': | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 550 | 'Datei erzeugt'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 551 | 0 | print $out "$self->[7]$file -- $msg\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 552 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 553 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 554 | 2 | ▶ | return $fileExists? 1: 2; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 555 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 556 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 557 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 558 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 559 | =head3 obsoletePaths() - Liste der überzähligen Pfade | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 560 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 561 | =head4 Synopsis | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 562 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 563 | @arr | $arr = $tree->obsoletePaths; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 564 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 565 | =head4 Description | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 566 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 567 | Die Pfade werden lexikalisch absteigend sortiert, so dass der | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 568 | Inhalt eines Verzeichnisses typischerweise vor dem Verzeichnis | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 569 | kommt. Dies ist aber nicht garantiert, da Punkt "." und Bindestrich | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 570 | "-" vor dem Verzeichnistrenner "/" kommen. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 571 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 572 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 573 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 574 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 575 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 576 | 5 | ▶ | sub obsoletePaths { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
obsoletePaths: called CC=2 SCAR=7.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 577 | 5 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 578 | 0 | my @arr = sort {$b cmp $a} keys %{$self->[0]}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 579 | 5 | ▶ | return wantarray? @arr: \@arr; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 580 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 581 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 582 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 583 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 584 | =head3 removePath() - Lösche Datei oder Verzeichnis aus Baum | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 585 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 586 | =head4 Synopsis | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 587 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 588 | $bool = $tree->removePath($path); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 589 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 590 | =head4 Description | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 591 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 592 | Lösche Datei oder Verzeichnis $path aus dem Zielbaum. Liefere 1, wenn | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 593 | die Löschung durchgeführt wurde, andernfalls 0. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 594 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 595 | Im Falle eines Verzeichnisses wird die Löschung nur durchgeführt, wenn | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 596 | das Verzeichnis leer ist. Dateien werden grundsätzlich gelöscht. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 597 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 598 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 599 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 600 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 601 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 602 | 1 | ▶ | sub removePath { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
removePath: called CC=8 SCAR=30.3
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 603 | 1 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 604 | 1 | my $path = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 605 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 606 | 1 | my $removed = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 607 | 1 | ▶ | if (-d $path) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 608 | 0 | ▶ | if (Quiq::Path->isEmpty($path)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 609 | 0 | ▶ | if (!$self->[8]) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 610 | 0 | Quiq::Path->delete($path); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 611 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 612 | 0 | ▶ | if (!$self->[2]) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 613 | 0 | my $out = $self->[5]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 614 | 0 | my $msg = $self->getText('Verzeichnis gelöscht'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 615 | 0 | print $out "$self->[7]$path -- $msg\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 616 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 617 | 0 | $removed = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 618 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 619 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 620 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 621 | 1 | ▶ | if (!$self->[8]) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 622 | 1 | Quiq::Path->delete($path); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 623 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 624 | 1 | ▶ | if (!$self->[2]) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 625 | 0 | my $out = $self->[5]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 626 | 0 | my $msg = $self->getText('Datei gelöscht'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 627 | 0 | print $out "$self->[7]$path -- $msg\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 628 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 629 | 1 | $removed = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 630 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 631 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 632 | 1 | ▶ | if ($removed) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 633 | # Eintrag entfernen | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 634 | 1 | delete $self->[0]{$path}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 635 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 636 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 637 | 1 | return $removed; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 638 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 639 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 640 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 641 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 642 | =head3 cleanup() - Entferne überzählige Pfade aus dem Zielbaum | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 643 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 644 | =head4 Synopsis | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 645 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 646 | $n|@paths = $tree->cleanup; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 647 | $n|@paths = $tree->cleanup($ask); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 648 | $n|@paths = $tree->cleanup($ask,\$timer); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 649 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 650 | =head4 Returns | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 651 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 652 | Anzahl oder Liste der gelöschten Pfade (Skalarkontext/Arraykontext) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 653 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 654 | =head4 Description | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 655 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 656 | Entferne alle Dateien und Verzeichnisse aus dem Zielbaum, die obsolet | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 657 | geworden sind, die seit Objekt-Instantiierung also nicht via | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 658 | $tree->addFile() oder $tree->addDir() angelegt wurden. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 659 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 660 | Ist der Parameter $ask angegeben und wahr, wird vor der Löschung | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 661 | eine Rückfrage auf STDERR gestellt, ob die Löschung wirklich erfolgen | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 662 | soll. Wird diese nicht mit 'y' beantwortet (auf STDIN), findet | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 663 | kein Löschen statt und die Methode liefert 0. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 664 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 665 | Ist ferner der Parameter $timer angegeben, wird die Antwortzeit | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 666 | des Benutzers auf dessen Wert aufaddiert. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 667 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 668 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 669 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 670 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 671 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 672 | 2 | ▶ | sub cleanup { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
cleanup: called CC=11 SCAR=32.6
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 673 | 2 | my ($self,$ask,$timerR) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 674 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 675 | 2 | my @obsoletePaths = $self->obsoletePaths; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 676 | 2 | ▶ | if (@obsoletePaths) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 677 | 1 | ▶ | if ($ask) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 678 | 0 | my $msg = $self->getText('Überzählige Dateien'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 679 | 0 | my $prompt = "$msg:\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 680 | 0 | for my $path (@obsoletePaths) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 681 | # Verzeichnisse zeigen wir nicht an | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 682 | 0 | ▶ | if (-f $path) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 683 | 0 | $prompt .= "$self->[7]$path\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 684 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 685 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 686 | 0 | $prompt .= $self->getText('Löschen?'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 687 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 688 | 0 | ▶ | my $answ = Quiq::Terminal->askUser( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 689 | $prompt, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 690 | -values => 'y/n', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 691 | -default => 'y', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 692 | -inHandle => $self->[4], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 693 | -outHandle => $self->[5], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 694 | $timerR? (-timer=>$timerR): (), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 695 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 696 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 697 | 0 | ▶ | if ($answ ne 'y') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 698 | 0 | ▶ | return wantarray? (): 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 699 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 700 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 701 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 702 | # Doch (erstmal) keine Meldung | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 703 | #if (!$self->[2]) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 704 | # my $out = $self->[5]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 705 | # my $msg = $self->getText('Aufräumen'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 706 | # print $out "*$msg*\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 707 | #} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 708 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 709 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 710 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 711 | # Die Liste der überzähligen Pfade wird so lange durchlaufen | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 712 | # bis keine Änderungen mehr eintritt. Auf diese Weise wird | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 713 | # sichergestellt, dass Elternverzeichnisse gelöscht werden, wenn | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 714 | # sie leer werden. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 715 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 716 | 2 | my @paths; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 717 | 2 | while (1) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 718 | 3 | my $n = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 719 | 3 | for my $path ($self->obsoletePaths) { # Liste ändert sich! | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 720 | 1 | ▶ | if ($self->removePath($path)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 721 | 1 | $n++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 722 | 1 | push @paths,$path; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 723 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 724 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 725 | # TODO: Warnung, wenn ungelöschte Pfade übrig bleiben? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 726 | 3 | ▶ | last if $n == 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 727 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 728 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 729 | 2 | return @paths; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 730 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 731 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 732 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 733 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 734 | =head3 close() - Schließe Zielbaumvergleich ab | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 735 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 736 | =head4 Synopsis | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 737 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 738 | $dt->close; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 739 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 740 | =head4 Description | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 741 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 742 | Schließe Zielbaumvergeleich ab. Nach Aufruf kann die Objektreferenz | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 743 | nicht mehr verwendet werden. Die Methode liefert keinen Wert zurück. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 744 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 745 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 746 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 747 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 748 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 749 | 0 | ▶ | sub close { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
close: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 750 | 0 | $_[0] = undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 751 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 752 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 753 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 754 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 755 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 756 | =head3 getText() - Liefere Übersetzung | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 757 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 758 | =head4 Synopsis | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 759 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 760 | $text = $tree->getText($textDe); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 761 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 762 | =head4 Returns | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 763 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 764 | Übersetzten Text (String) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 765 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 766 | =head4 Description | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 767 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 768 | Liefere die Übersetzung zum deutschen Text $textDe. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 769 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 770 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 771 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 772 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 773 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 774 | 2 | my %Text = ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 775 | 'Verzeichnis erzeugt' => 'directory created', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 776 | 'Datei aktualisiert' => 'file updated', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 777 | 'Datei erzeugt' => 'file created', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 778 | 'Verzeichnis gelöscht' => 'directory deleted', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 779 | 'Datei gelöscht' => 'file deleted', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 780 | 'Überzählige Dateien' => 'Obsolete files', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 781 | 'Löschen?' => 'Remove?', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 782 | 'Aufräumen' => 'cleanup', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 783 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 784 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 785 | 0 | ▶ | sub getText { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
getText: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 786 | 0 | my ($self,$textDe) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 787 | 0 | ▶ | return $self->[6] eq 'de'? $textDe: $Text{$textDe} || $textDe; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$Text{$textDe} or $textDe
MC/DC0%0/2
$Text{$textDe} or $textDe
$Text{$textDe}
$textDe
Truth table0%0/3
A or B
A= $Text{$textDe}B= $textDe
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 788 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 789 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 790 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 791 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 792 | =head1 VERSION | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 793 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 794 | 1.240 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 795 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 796 | =head1 AUTHOR | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 797 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 798 | Frank Seitz, L<http://fseitz.de/> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 799 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 800 | =head1 COPYRIGHT | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 801 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 802 | Copyright (C) 2026 Frank Seitz | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 803 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 804 | =head1 LICENSE | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 805 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 806 | This code is free software; you can redistribute it and/or modify | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 807 | it under the same terms as Perl itself. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 808 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 809 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 810 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 811 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 812 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 813 | 2 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 814 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 815 | # eof | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||