aboutsummaryrefslogtreecommitdiffstats
path: root/lib/Iurt/File.pm
diff options
context:
space:
mode:
authorGustavo De Nardin <spuk@mandriva.org>2007-05-12 20:11:53 +0000
committerGustavo De Nardin <spuk@mandriva.org>2007-05-12 20:11:53 +0000
commitc2801c794b9bcdcfecb9ce95bc1d449e6c58b128 (patch)
tree99140f43559dc34a3c95a58e7784325036edf26a /lib/Iurt/File.pm
parent9f069679e6b24ebe7409414a9ca2cc2e75fe05ea (diff)
downloadiurt-c2801c794b9bcdcfecb9ce95bc1d449e6c58b128.tar
iurt-c2801c794b9bcdcfecb9ce95bc1d449e6c58b128.tar.gz
iurt-c2801c794b9bcdcfecb9ce95bc1d449e6c58b128.tar.bz2
iurt-c2801c794b9bcdcfecb9ce95bc1d449e6c58b128.tar.xz
iurt-c2801c794b9bcdcfecb9ce95bc1d449e6c58b128.zip
Restoring code lost in the SVN breakage from an old checkout
Diffstat (limited to 'lib/Iurt/File.pm')
-rw-r--r--lib/Iurt/File.pm68
1 files changed, 68 insertions, 0 deletions
diff --git a/lib/Iurt/File.pm b/lib/Iurt/File.pm
new file mode 100644
index 0000000..ba5f718
--- /dev/null
+++ b/lib/Iurt/File.pm
@@ -0,0 +1,68 @@
+package Iurt::File;
+
+use base qw(Exporter);
+use Iurt::Util qw(plog);
+use strict;
+
+our @EXPORT = qw(
+ check_upload_tree
+);
+
+=head2 config_usage($config_usage, $config)
+
+Create an instance of a class at runtime.
+I<$config_usage> is the configuration help,
+I<%config> is the current configuration values
+Return true.
+
+=cut
+
+sub check_upload_tree {
+ my ($_run, $todo, $func, $post) = @_;
+
+ # Squash double slashes for cosmetics
+ $todo =~ s!/+!/!g;
+
+ opendir my $dir, $todo;
+ plog('INFO', "check dir: $todo");
+
+ foreach my $f (readdir $dir) {
+ $f =~ /^\.{1,2}$/ and next;
+ if (-d "$todo/$f") {
+ plog('DEBUG', "checking target $todo/$f");
+ opendir my $target_dir, "$todo/$f";
+
+ foreach my $m (readdir $target_dir) {
+ $m =~ /^\.{1,2}$/ and next;
+ if (-d "$todo/$f/$m") {
+ plog('DEBUG', "checking media $todo/$f/$m");
+ opendir my $media_dir, "$todo/$f/$m";
+
+ foreach my $s (readdir $media_dir) {
+ $s =~ /^\.{1,2}$/ and next;
+ if (-d "$todo/$f/$m/$s") {
+ if ($func) {
+ opendir my $submedia_dir, "$todo/$f/$m/$s";
+ foreach my $r (readdir $submedia_dir) {
+ $r =~ /^\.{1,2}$/ and next;
+ $func->($todo, $f, $m, $s, $r);
+ }
+ }
+ # cleaning
+ if ($post) {
+ opendir my $submedia_dir, "$todo/$f/$m/$s";
+ foreach my $r (readdir $submedia_dir) {
+ $r =~ /^\.{1,2}$/ and next;
+ $post->($todo, $f, $m, $s, $r);
+ }
+ }
+ } else {
+ # may need to check also here for old target
+ }
+ }
+ }
+ }
+ }
+ }
+}
+