Prty
view release on metacpan or search on metacpan
lib/Prty/Path.pm view on Meta::CPAN
my $srcPath = shift;
my $destPath = shift;
# @_: @opt
# Optionen
my $preserve = 0;
if (@_) {
Prty::Option->extract(\@_,
-preserve=>\$preserve,
);
}
# Operation ausführen
if ($method eq 'copy') {
$class->copy($srcPath,$destPath,-preserve=>1);
}
elsif ($method eq 'move' || $method eq 'rename') {
$class->rename($srcPath,$destPath);
}
elsif ($method eq 'link') {
$class->link($srcPath,$destPath);
}
elsif ($method eq 'symlink') {
$class->symlinkRelative($srcPath,$destPath);
}
else {
$class->throw;
}
return;
}
# -----------------------------------------------------------------------------
=head3 encoding() - Liefere das Encoding der Datei
=head4 Synopsis
$encoding = $class->encoding($path,$altEncoding);
=head4 Description
Analysiere Datei $path hinsichtlich ihres Character-Encodings
und liefere den Encoding-Bezeichner zurück. Unterschieden werden:
=over 2
=item *
ASCII
=item *
UTF-8
=item *
UTF-16/32 mit BOM
=back
und $altEncoding. Ist $altEncoding nicht angegeben, wird
'ISO-8859-1' angenommen.
Anmerkung: Die Datei wird zur Zeichensatz-Analyse vollständig eingelesen.
Bei groÃen Dateien kann dies ineffizient sein.
=cut
# -----------------------------------------------------------------------------
sub encoding {
my $class = shift;
my $path = shift;
my $altEncoding = shift // 'ISO-8859-1';
my $data = $class->read($path);
my $dec = Encode::Guess->guess($data);
if (ref $dec) {
return $dec->name;
}
elsif ($dec =~ /No appropriate encodings found/i) {
return $altEncoding;
}
# Unerwarteter Fehler
$class->throw(
q~PATH-00099: Can't decode file content~,
Path => $path,
Message => $dec,
);
}
# -----------------------------------------------------------------------------
=head3 link() - Erzeuge (Hard)Link
=head4 Synopsis
$class->link($path,$link);
=head4 Description
Erzeuge einen Hardlink $link auf Pfad $path.
Die Methode liefert keinen Wert zurück.
=cut
# -----------------------------------------------------------------------------
sub link {
my ($class,$path,$link) = @_;
CORE::link $path,$link or do {
$class->throw(
q~FS-00002: Kann Link nicht erzeugen~,
Path=>$path,
( run in 1.563 second using v1.01-cache-2.11-cpan-2398b32b56e )