aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndy Shevchenko <andy@smile.org.ua>2008-08-25 20:13:54 +0000
committerAndy Shevchenko <andy@smile.org.ua>2008-08-25 20:13:54 +0000
commit0a88e0a636815ee0073d7d2186a60423da6a6975 (patch)
treed18a3211e59d5d70cd340fc1bf08504153557948
parent10755bc0030617d17b968252957b3e51e7d3f0a5 (diff)
downloadrenrot-0a88e0a636815ee0073d7d2186a60423da6a6975.tar.gz
renrot-0a88e0a636815ee0073d7d2186a60423da6a6975.tar.bz2
Switch to use File::Spec instead of some hardcoded symbols. Should fix bugs with pathnames on different filesystems. Aggregation still need review.
git-svn-id: file:///svnroot/renrot/branches/andy@554 fe2816f4-e837-0410-b10a-f608c9d244a1
-rwxr-xr-xrenrot57
1 files changed, 28 insertions, 29 deletions
diff --git a/renrot b/renrot
index a3b6708..b1a361e 100755
--- a/renrot
+++ b/renrot
@@ -16,6 +16,7 @@ use Time::localtime;
use Time::Local;
use Image::ExifTool;
use Getopt::Long;
+use File::Spec;
use Term::ANSIColor;
@@ -707,9 +708,9 @@ sub parseConfig {
$home = $ENV{"USERPROFILE"} if (not defined $home);
if (defined $home and $home ne "") {
- push (@homeRC, $home . "/" . ".renrotrc");
- push (@homeRC, $home . "/" . ".renrot/.renrotrc");
- push (@homeRC, $home . "/" . ".renrot/renrot.conf");
+ push (@homeRC, File::Spec->catfile($home, ".renrotrc"));
+ push (@homeRC, File::Spec->catfile($home, ".renrot", ".renrotrc"));
+ push (@homeRC, File::Spec->catfile($home, ".renrot", "renrot.conf"));
} else {
warnmsg ("User's home environment variable isn't defined or empty!\n");
}
@@ -1218,7 +1219,7 @@ sub contactSheetGenerator {
use File::Copy;
my $exifToolObj = shift;
- my $workdir = $cfgOpts{'contact sheet dir'} . "/";
+ my $workdir = $cfgOpts{'contact sheet dir'};
my $file;
my $info;
my $infothm;
@@ -1256,12 +1257,13 @@ sub contactSheetGenerator {
if ($contactSheetThm != 0 and defined $orientation and $orientation > 1) {
$filefull = rot_thm_cs ($file, $rotorient{$orientation}, $workdir);
} elsif ($contactSheetThm != 0 and defined $orientation and $orientation == 1) {
- # we need this since rotated img'll be @ $workdir, but others are in current
- $ThumbnailOriginal = $workdir . $file;
+ # We need this since rotated imgage will be at $workdir, but others are
+ # in current
+ $ThumbnailOriginal = File::Spec->catfile($workdir, $file);
copy ($file, $ThumbnailOriginal) or die "copy failed: $!";
$filefull = $ThumbnailOriginal;
} elsif ($contactSheetThm == 0 and defined ${$$info{ThumbnailImage}}) {
- $ThumbnailOriginal = $workdir . $file;
+ $ThumbnailOriginal = File::Spec->catfile($workdir, $file);
unless (open (OLDTHUMBNAIL, ">$ThumbnailOriginal")) {
die "$ThumbnailOriginal wasn't opened!\n";
}
@@ -1274,22 +1276,22 @@ sub contactSheetGenerator {
}
if (defined $orientation and $orientation > 1) {
- $filefull = rot_thm_cs ($ThumbnailOriginal, $orientation, "");
+ $filefull = rot_thm_cs ($ThumbnailOriginal, $orientation, File::Spec->curdir());
} else {
$filefull = $ThumbnailOriginal;
}
} elsif ($contactSheetThm == 0 and not defined ${$$info{ThumbnailImage}} and $gen_thm == 0) {
warnmsg ("$filefull has no ThumbnailImage tag. Stub thumbnail image'll be used.\n");
- if (not -f $workdir . "thmbstub.jpg") {
- thm_gen_stub ($workdir, "thmbstub.jpg");
- }
- copy ($workdir . "thmbstub.jpg", $workdir . $file);
- $filefull = $workdir . $file;
+ my $thmbstubjpg = File::Spec->catfile($workdir, "thmbstub.jpg");
+ thm_gen_stub($thmbstubjpg) if (not -f $thmbstubjpg);
+ my $ffwf = File::Spec->catfile($workdir, $file);
+ copy ($thmbstubjpg, $ffwf);
+ $filefull = $ffwf;
} elsif ($contactSheetThm == 0 and not defined ${$$info{ThumbnailImage}} and $gen_thm != 0) {
warnmsg ("$filefull has no ThumbnailImage tag. Thumbnail image'll be generated.\n");
-
- move (thm_gen_orig($file, 0), $workdir . $file);
- $filefull = $workdir . $file;
+ my $ffwf = File::Spec->catfile($workdir, $file);
+ move (thm_gen_orig($file, 0), $ffwf);
+ $filefull = $ffwf;
}
$infothm = $exifToolObj->ImageInfo($filefull);
@@ -1452,7 +1454,7 @@ sub contactSheetGenerator {
else { errmsg ("Image::Magick error: $readres\n\n"); }
# ranking
- $substrFile = substr($thumbnailes_sorted[$csIteration], length($cfgOpts{'contact sheet dir'})+1);
+ $substrFile = substr($thumbnailes_sorted[$csIteration], length($cfgOpts{'contact sheet dir'}) + 1);
if (defined $ranks->{$substrFile}->[1] and length($ranks->{$substrFile}->[1]) > 1) {
dbgmsg (4, "[last] $substrFile mattecolor is \"$ranks->{$substrFile}->[1]\"\n");
$image->[$readIndex]->Set(mattecolor => $ranks->{$substrFile}->[1]);
@@ -1529,18 +1531,15 @@ sub contactSheetGenerator {
}
########################################################################################
-# Usage : thm_gen_stub($wrkdir, $thmbname);
+# Usage : thm_gen_stub($thm_name);
# Purpose : thumbnail stub generator
# Returns : none
-# Parameters : $wrkdir str - the directory, thumbnailes are kept
-# : $thmbname str - thumbnail image name
+# Parameters : $thm_name str - thumbnail image pathname
# Throws : no exceptions
# Comments : none
# See Also : contactSheetGenerator();
sub thm_gen_stub {
- my $workdir = shift;
- my $file = shift;
- my $thm_name = $workdir . $file;
+ my $thm_name = shift;
my $size = $cfgOpts{'generate thumbnail size'};
my $thmb = Image::Magick->new;
@@ -1559,7 +1558,7 @@ sub thm_gen_stub {
if ($thmbnum) { errmsg ("$thmbnum\n\n"); }
undef $thmb;
- procmsg ("Stub thumbnail image've been created.\n");
+ procmsg ("Stub thumbnail image has been created.\n");
}
########################################################################################
@@ -1615,7 +1614,7 @@ sub rot_thm_cs {
my $angle = shift;
my $workdir = shift;
my $image_to_rotate = Image::Magick->new;
- my $result = $workdir . $base_orig;
+ my $result = File::Spec->catfile($workdir, $base_orig);
$image_to_rotate->Read("JPEG:" . $base_orig);
$image_to_rotate->Rotate(degrees => $angle);
@@ -1671,16 +1670,16 @@ sub aggregateFile {
if ($cfgOpts{'aggregation virtual'} == 0) {
makeDir($cfgOpts{'aggregation directory'});
- $new_dir = $cfgOpts{'aggregation directory'} . "/" . $new_dir;
+ $new_dir = File::Spec->catdir($cfgOpts{'aggregation directory'}, $new_dir);
makeDir($new_dir);
- my $newname = $new_dir . "/" . $file;
+ my $newname = File::Spec->catfile($new_dir, $file);
rename ($file, $newname) || ( fatalmsg ("While moving $file -> $newname, perhaps new directory is at different file system\n"), die );
dbgmsg (3, "$file moved to $newname\n");
} else {
makeDir($cfgOpts{'aggregation virtual directory'});
- $new_dir = $cfgOpts{'aggregation virtual directory'} . "/" . $new_dir;
+ $new_dir = File::Spec->catdir($cfgOpts{'aggregation virtual directory'}, $new_dir);
makeDir($new_dir);
- my $newfile = $new_dir . "/" . $file;
+ my $newfile = File::Spec->catfile($new_dir, $file);
my @virt_dir = split(/\//, $cfgOpts{'aggregation virtual directory'});

Return to:

Send suggestions and report system problems to the System administrator.