aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndy Shevchenko <andy@smile.org.ua>2006-06-12 07:42:14 +0000
committerAndy Shevchenko <andy@smile.org.ua>2006-06-12 07:42:14 +0000
commit8e6a9b5e6ab982306d8261eff39499587f0a5b14 (patch)
treed2fdb45200100efe3f4c96ebfd973c132d184a1c
parent3c37e7f7346012ccff3129a6da4daf9956e334ad (diff)
downloadrenrot-8e6a9b5e6ab982306d8261eff39499587f0a5b14.tar.gz
renrot-8e6a9b5e6ab982306d8261eff39499587f0a5b14.tar.bz2
Check for directory tree in aggregation arguments. Now it isn't possible.
Remove support of old style tag options. git-svn-id: file:///svnroot/renrot/trunk@207 fe2816f4-e837-0410-b10a-f608c9d244a1
-rw-r--r--ChangeLog5
-rw-r--r--TODO6
-rwxr-xr-xrenrot116
3 files changed, 67 insertions, 60 deletions
diff --git a/ChangeLog b/ChangeLog
index af0eedc..84824e1 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,4 +1,8 @@
$Log$
+Revision 1.133 2006/06/12 07:42:14 andy
+Check for directory tree in aggregation arguments. Now it isn't possible.
+Remove support of old style tag options.
+
Revision 1.132 2006/06/11 14:05:38 andy
Use $dryRun in the rotateOrient(), renameFile(), mtimeSet(), and tagWriter().
@@ -535,3 +539,4 @@ Id keyword is added to renrot file.
Revision 1.1 2005/10/17 13:39:38 zeus
ChangeLog file is added. Its the very begining.
+
diff --git a/TODO b/TODO
index 88d2428..5d67d99 100644
--- a/TODO
+++ b/TODO
@@ -11,8 +11,6 @@ EXIF tags
q to write to some tag the options passed to renrot
-+- to review XMP tags related code
-
+- to implement %t in name template, where the array of desired tags will be
inited
@@ -25,7 +23,7 @@ Disk I/O
mechanism (conversions by ImageMagick and/or netpbm as well as jpegtran)
+- implement aggregation option (to aggregate large bundle of files according
- the different time intervals, perhapse with some kind of euristics for
+ the different time intervals, perhaps with some kind of euristics for
analyzing the bigest time interval between shots)
- to fix the feature with --aggr-template SOMENAME, when SOMENAME is dumb
@@ -37,6 +35,8 @@ Disk I/O
- avoid hard link making where in and out files on different partitions
+- backup option for making or not backups
+
User interface
diff --git a/renrot b/renrot
index 0627757..5a59a32 100755
--- a/renrot
+++ b/renrot
@@ -416,7 +416,7 @@ sub getConfig {
if (defined $value) {
$key = lc($key);
if ($key eq "include" and not $incFiles{$value}) {
- dbgmsg (2, "getConfig(): Parsing included file: '$value'.\n");
+ dbgmsg (2, "getConfig(): Parsing included file: '$value'\n");
%hConfig = parseConfigFile($fc, $value, %hConfig);
}
$key .= sprintf("#%d#%d", $fc, $i) if (grep (/^$key$/, @multOpts));
@@ -476,6 +476,33 @@ sub parseConfig {
########################################################################################
#
+# dirConv() simplifies directory name
+#
+sub dirConv {
+ my $dirStr = shift;
+ $dirStr =~ s/\/*\/\.\/\/*/\//g; # remove dotslashes
+ $dirStr =~ s/^\.\/\/*//; # remove heading dotslash
+ $dirStr =~ s/\/+$//; # remove trailing slashes
+ return $dirStr;
+}
+
+########################################################################################
+#
+# dirValidator() validates given string as no tree and no current directory
+#
+sub dirValidator {
+ my $dirStr = shift;
+ if ($dirStr =~ m/\// or
+ $dirStr eq "." or
+ $dirStr eq ".." or
+ $dirStr eq "") {
+ return 0;
+ }
+ return 1;
+}
+
+########################################################################################
+#
# MAIN() renames and rotates given files
#
@@ -490,8 +517,7 @@ $configOptions{'aggregation directory'} = $aggrDir if (defined $aggrDir);
$configOptions{'aggregation mode'} = $aggrMode if (defined $aggrMode);
$configOptions{'aggregation template'} = $aggrTemplate if (defined $aggrTemplate);
$configOptions{'aggregation virtual'} = $aggrVirtual if (defined $aggrVirtual);
-# $configOptions{'aggregation virtual directory'} = $aggrVirtDir if (defined $aggrVirtDir);
-$configOptions{'aggregation virtual directory'} = 'Images.Links.Directory'; # defining by user, now not possible!
+$configOptions{'aggregation virtual directory'} = $aggrVirtDir if (defined $aggrVirtDir);
$configOptions{'mtime'} = $mtime if (defined $mtime);
$configOptions{'name template'} = $nameTemplate if (defined $nameTemplate);
$configOptions{'trim'} = $trim if (defined $trim);
@@ -503,6 +529,14 @@ if (not grep (/^$configOptions{'aggregation mode'}$/, ('none', 'delta', 'templat
warnmsg ("Aggregation mode isn't correct!\n");
}
+$configOptions{'aggregation directory'} = dirConv($configOptions{'aggregation directory'});
+$configOptions{'aggregation virtual directory'} = dirConv($configOptions{'aggregation virtual directory'});
+
+fatalmsg ("Current or multilevel directory isn't possible now, sorry. Check aggregation arguments.\n"), die
+ if ($configOptions{'aggregation mode'} ne "none" and
+ (dirValidator($configOptions{'aggregation directory'}) == 0 or
+ dirValidator($configOptions{'aggregation virtual directory'}) == 0));
+
# Calculate ExifTool's verbosity
my $exiftoolVerbose = ($verbose > $maxVerbosity) ? ($verbose - $maxVerbosity) : 0;
@@ -545,39 +579,6 @@ if (scalar(@filenames) == 0) {
exit 1;
}
-# Convert old style of tags to new one
-if (defined $configOptions{'comment file'}) {
- $tags{'Comment'} = {value => getFileData($configOptions{'comment file'})};
-}
-if (defined $configOptions{'tag usercomment'}) {
- $tags{'UserComment'} = {value => $configOptions{'tag usercomment'}};
-}
-
-if (defined $configOptions{'tag ciadrcity'}) {
- $tags{'CreatorContactInfoCiAdrCity'} = {value => $configOptions{'tag ciadrcity'}, group => 'XMP'};
-}
-if (defined $configOptions{'tag ciadrctry'}) {
- $tags{'CreatorContactInfoCiAdrCtry'} = {value => $configOptions{'tag ciadrctry'}, group => 'XMP'};
-}
-if (defined $configOptions{'tag ciadrextadr'}) {
- $tags{'CreatorContactInfoCiAdrExtadr'} = {value => $configOptions{'tag ciadrextadr'}, group => 'XMP'};
-}
-if (defined $configOptions{'tag ciadrpcode'}) {
- $tags{'CreatorContactInfoCiAdrPcode'} = {value => $configOptions{'tag ciadrpcode'}, group => 'XMP'};
-}
-if (defined $configOptions{'tag ciadrregion'}) {
- $tags{'CreatorContactInfoCiAdrRegion'} = {value => $configOptions{'tag ciadrregion'}, group => 'XMP'};
-}
-if (defined $configOptions{'tag ciemailwork'}) {
- $tags{'CreatorContactInfoCiEmailWork'} = {value => $configOptions{'tag ciemailwork'}, group => 'XMP'};
-}
-if (defined $configOptions{'tag citelwork'}) {
- $tags{'CreatorContactInfoCiTelWork'} = {value => $configOptions{'tag citelwork'}, group => 'XMP'};
-}
-if (defined $configOptions{'tag ciurlwork'}) {
- $tags{'CreatorContactInfoCiUrlWork'} = {value => $configOptions{'tag ciurlwork'}, group => 'XMP'};
-}
-
# Parse configuration file tag set
foreach my $cKey (keys %configOptions) {
next if ($cKey !~ m/^tag(file)?#\d+#\d+$/); # skip not a tag or tagfile
@@ -585,7 +586,7 @@ foreach my $cKey (keys %configOptions) {
foreach my $key (keys %tag) {
$tags{$key} = $tag{$key};
if ($cKey =~ m/^tagfile/) {
- dbgmsg (4, "main(): Read data from '$tags{$key}{value}' for '$key'.\n");
+ dbgmsg (4, "main(): Read data from '$tags{$key}{value}' for '$key'\n");
$tags{$key}{value} = getFileData($tags{$key}{value});
}
}
@@ -901,37 +902,40 @@ sub aggregationProcess {
########################################################################################
#
+# makeDir() makes one level directory
+#
+sub makeDir {
+ my $newDir = shift;
+ if (not -d $newDir) {
+ unless (mkdir $newDir) { errmsg ("$newDir wasn't created!\n"); }
+ }
+}
+
+########################################################################################
+#
# aggregateFile() moves file to new directory
#
sub aggregateFile {
my $file = shift;
my $NewDir = shift;
- if ($configOptions{'aggregation virtual'} != 0) {
- my $LnkDir = $configOptions{'aggregation virtual directory'};
- if (not -d $LnkDir) {
- unless (mkdir $LnkDir) { errmsg ("$LnkDir wasn't created!\n"); }
- }
- $NewDir = $LnkDir . "/" . $NewDir;
- }
-
- if (not -d $NewDir) {
- unless (mkdir $NewDir) { errmsg ("$NewDir wasn't created!\n"); }
- }
- my $newfilename = $NewDir . "/" . $file;
- my $symlink = "../../" . $file;
-
- if ($configOptions{'aggregation virtual'} != 0) {
+ if ($configOptions{'aggregation virtual'} == 0) {
+ makeDir($NewDir);
+ my $newfilename = $NewDir . "/" . $file;
+ rename ($file, $newfilename) || ( fatalmsg ("$file -> $newfilename\n"), die );
+ } else {
+ makeDir($configOptions{'aggregation virtual directory'});
+ $NewDir = $configOptions{'aggregation virtual directory'} . "/" . $NewDir;
+ makeDir($NewDir);
+ my $newfilename = $NewDir . "/" . $file;
if (not -l $newfilename) {
+ my $symlink = "../../" . $file;
symlink ($symlink, $newfilename) || ( fatalmsg ("While linking $file -> $newfilename\n"), die );
}
else {
procmsg ("Link $newfilename already exists.\n");
}
}
- else {
- rename ($file, $newfilename) || ( fatalmsg ("$file -> $newfilename\n"), die );
- }
}
########################################################################################
@@ -1678,8 +1682,6 @@ Configuration file placement (with high priority first):
=back
-=head1 NOTES
-
=head1 BUGS
If you found some bug or have nice proposition, you are welcome. Additionally,

Return to:

Send suggestions and report system problems to the System administrator.