projects
/
id3fs.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
9b7d549
)
ID3FS: use File::Find to recursively add files
author
Ian Beckwith
<ianb@erislabs.net>
Sun, 19 Sep 2010 21:40:12 +0000
(22:40 +0100)
committer
Ian Beckwith
<ianb@erislabs.net>
Sun, 19 Sep 2010 21:40:12 +0000
(22:40 +0100)
bin/id3fs
patch
|
blob
|
history
lib/ID3FS/DB.pm
patch
|
blob
|
history
diff --git
a/bin/id3fs
b/bin/id3fs
index
eb0b2bd
..
485eabd
100755
(executable)
--- a/
bin/id3fs
+++ b/
bin/id3fs
@@
-6,17
+6,20
@@
use lib '/home/ianb/projects/id3fs/id3fs/lib';
use strict;
use Getopt::Long qw(Configure);
use ID3FS::DB;
use strict;
use Getopt::Long qw(Configure);
use ID3FS::DB;
+use File::Find;
use vars qw($me);
$me=($0=~/(?:.*\/)?(.*)/)[0];
my $verbose=0;
my $help=0;
my $init=0;
use vars qw($me);
$me=($0=~/(?:.*\/)?(.*)/)[0];
my $verbose=0;
my $help=0;
my $init=0;
+my @extensions=qw(mp3 ogg flac);
Configure(qw(bundling no_ignore_case));
my $optret=GetOptions(
"verbose|v" => \$verbose,
"quiet|q" => sub { $verbose=0; },
"help|h" => \$help,
Configure(qw(bundling no_ignore_case));
my $optret=GetOptions(
"verbose|v" => \$verbose,
"quiet|q" => sub { $verbose=0; },
"help|h" => \$help,
+ "extensions|e=s" => sub { @extensions=split(/\s+|\s*,\s*/, $_[1]); },
"init|i" => \$init,
);
"init|i" => \$init,
);
@@
-25,6
+28,22
@@
usage() if(!@ARGV || !$optret || $help);
my $path=shift;
my $db=ID3FS::DB->new($path, $init, $me);
my $path=shift;
my $db=ID3FS::DB->new($path, $init, $me);
+File::Find::find( {wanted => \&wanted, follow => 1, no_chdir => 1}, $path);
+
+sub wanted
+{
+ my $ext='';
+ if(/.*\.(.*)/) { $ext=lc($1); }
+ if(-d)
+ {
+ print("$_\n") if $verbose;
+ }
+ elsif(-f && scalar(grep({ $ext eq lc($_);} @extensions)))
+ {
+ $db->add($_);
+ }
+}
+
sub usage
{
die("Usage: $me [-v] [-q] [-h] [--] file...\n".
sub usage
{
die("Usage: $me [-v] [-q] [-h] [--] file...\n".
diff --git
a/lib/ID3FS/DB.pm
b/lib/ID3FS/DB.pm
index
6b0f844
..
32db70a
100644
(file)
--- a/
lib/ID3FS/DB.pm
+++ b/
lib/ID3FS/DB.pm
@@
-80,6
+80,11
@@
sub cmd_sth
return $sth;
}
return $sth;
}
+sub add
+{
+ my($self,$path)=@_;
+}
+
sub cmd
{
my ($self, @args)=@_;
sub cmd
{
my ($self, @args)=@_;