SVN: vfmg/trunk/VFMG/Icons.pm
sparky
sparky at pld-linux.org
Mon Dec 4 16:22:06 CET 2006
Author: sparky
Date: Mon Dec 4 16:22:01 2006
New Revision: 8061
Modified:
vfmg/trunk/VFMG/Icons.pm
Log:
- support in-line convert scripts, not tested
Modified: vfmg/trunk/VFMG/Icons.pm
==============================================================================
--- vfmg/trunk/VFMG/Icons.pm (original)
+++ vfmg/trunk/VFMG/Icons.pm Mon Dec 4 16:22:01 2006
@@ -14,6 +14,30 @@
'',
);
+my @del_files;
+sub prepare_exec($) {
+ my $sect = shift;
+ unless (exists $main::rcSect{$sect}) {
+ warn "Section '$sect' does not exist!\n";
+ return undef;
+ }
+
+ my $tmp = (grep {defined and length and -d and -w}
+ ($ENV{TMPDIR}, $ENV{TMP}, "/tmp"))[0];
+ return undef unless ($tmp);
+ my $file = "$tmp/$sect";
+
+ umask 077;
+ unlink $file if -e $file;
+ open F_OUT, ">", $file or warn "$file: $!\n" and return undef;
+ push @del_files, $file;
+ print F_OUT @{$main::rcSect{$sect}};
+ close F_OUT or return undef;
+ chmod 700, $file;
+ return undef unless -x $file;
+ return $file;
+}
+
sub preconf() {
eval { $main::opt{icons_dir} = VFMG::Output::icons_dir() }
unless length $main::opt{icons_dir};
@@ -21,7 +45,22 @@
$main::opt{icons_ext} = 1 if $main::opt{icons_full};
return unless $main::opt{icons_scale};
- if ( length $main::opt{icons_dir} ) {
+ unless ( length $main::opt{icons_dir} ) {
+ $main::opt{icons_scale} = 0;
+ warn "Icons destination directory is not specified, not scaling.\n";
+ return;
+ }
+ if ( $main::opt{convert} =~ s/^\s*\$(\S+)\s+// ) {
+ my $sect = $1;
+ my $conv = prepare_exec($sect);
+ if ( defined $conv and length $conv and -x $conv ) {
+ $main::opt{convert} =~ s/^/$conv /;
+ $main::opt{icons} = 1;
+ } else {
+ warn "Some error ocurred wile preparing '\$$sect' script\n";
+ $main::opt{icons_scale} = 0;
+ }
+ } else {
my $conv = (split /\s/, $main::opt{convert})[0];
if ( length `which $conv` ) {
$main::opt{icons} = 1;
@@ -29,10 +68,8 @@
$main::opt{icons_scale} = 0;
warn "$conv is not executable, not scaling icons.\n";
}
- } else {
- $main::opt{icons_scale} = 0;
- warn "Icons destination directory is not specified, not scaling.\n";
}
+ return;
}
our $scale_icon;
@@ -118,6 +155,7 @@
foreach my $cmd (@scale) {
system($cmd);
}
+ unlink @del_files;
}
1;
More information about the pld-cvs-commit
mailing list