[Vienna-pm] symlink: Ungültiger Dateidescriptor
Lars Dɪᴇᴄᴋᴏᴡ 迪拉斯
daxim at cpan.org
Fri Jun 13 16:07:07 PDT 2008
Hallo Calli,
du redest ganz schön wirr. Keine Angabe über Betriebssystem und
Perlversion, kein Quellcode zum nachvollziehen. Wie soll man sich ein
klares Bild über das Problem verschaffen?
Ich habe soeben mit dem Programm unten erfolgreich knapp 70000 Dateien
einsortiert. Das ist mit Perl 5.10 auf Linux 2.6.
Was mich stutzig macht: "Ungültiger Dateideskriptor" == EBADF, aber das
ist in man 2 symlink gar nicht aufgeführt. Überprüfst du Rückgabewerte
auf die korrekte Art?
#!/usr/bin/env perl
use utf8;
use 5.010;
use strict;
use warnings FATAL => 'all';
use File::HomeDir qw();
use File::Next qw();
use File::Path qw(mkpath);
use IPC::System::Simple qw(capture);
use Path::Class qw(dir file);
use Readonly qw(Readonly);
Readonly my $home => File::HomeDir->my_home;
Readonly my $next => File::Next::files({follow_symlinks => 0}, $home);
my $counter = 0;
while (defined (my $filename = $next->())) {
next if -l $filename;
next unless -f _ and -r _;
chomp(my $type = capture(qw(file -b -i), $filename));
$type =~ s{[;,] .* \z}{}msx;
my $target_dir = dir($home, 'calli_test', split m|/|, $type);
mkpath $target_dir, {verbose => 0} unless -e $target_dir;
unless (symlink $filename, file($target_dir, $counter)) {
say "$filename: $!";
};
$counter++;
};
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 194 bytes
Desc: This is a digitally signed message part.
Url : http://mail.pm.org/pipermail/vienna-pm/attachments/20080614/0da89e07/attachment.bin
More information about the Vienna-pm
mailing list