use Fuse;
use Cwd;
use POSIX qw(EINVAL EROFS ENOENT EOPNOTSUPP S_IRUSR S_IRGRP S_IROTH S_IXUSR S_IXGRP S_IXOTH);
-our ($TYPE_DIR, $TYPE_SYMLINK)=(0040, 0120);
+our ($TYPE_DIR, $TYPE_SYMLINK)=(0040, 0120);
+our $DEFAULT_MAXTAGDEPTH = 15;
sub new
{
my $proto=shift;
$self->{source}=shift;
$self->{mountpoint}=Cwd::abs_path(shift);
$self->{verbose}=shift;
+ $self->{tagdepth}=shift;
+ $self->{tagdepth}=$DEFAULT_MAXTAGDEPTH unless($self->{tagdepth});
$self->{perms} = S_IRUSR() | S_IXUSR() | S_IRGRP() | S_IXGRP() | S_IROTH() | S_IXOTH();
return $self;
{
my($self, $filename)=@_;
# print "**GETATTR: $filename\n";
- my $path=ID3FS::Path->new($self->{db}, $filename, $self->{verbose});
+ my $path=ID3FS::Path->new($self->{db}, $filename, $self->{verbose}, $self->{tagdepth});
my $last_update=$self->{db}->last_update();
return(-ENOENT()) unless($path->isvalid());
my($dev,$ino,$nlink)=(0,0,1);
{
my($self,$filename)=@_;
# print "**READLINK: $filename\n";
- my $path=ID3FS::Path->new($self->{db}, $filename, $self->{verbose});
+ my $path=ID3FS::Path->new($self->{db}, $filename, $self->{verbose}, $self->{tagdepth});
return(-EINVAL()) unless($path->isfile());
return $path->dest($self->{mountpoint});
}
{
my($self, $filename)=@_;
# print "**GETDIR: $filename\n";
- my $path=ID3FS::Path->new($self->{db}, $filename, $self->{verbose});
+ my $path=ID3FS::Path->new($self->{db}, $filename, $self->{verbose}, $self->{tagdepth});
return(-ENOENT()) unless($path->isvalid());
return(-ENOTDIR()) unless($path->isdir());
my @dents=();
$self->{db}=shift;
$self->{path}=shift;
$self->{verbose}=shift;
+ $self->{maxtagdepth}=shift;
+ $self->{curtagdepth}=0;
$self->{path} =~ s/\/\//\//g; # drop doubled slashes
$self->parse();
}
else
{
- @dents=(qw(AND OR), $PATH_ALLTRACKS, $PATH_NOARTIST, $self->artists());
+ if($self->{maxtagdepth} && ($self->{curtagdepth} < $self->{maxtagdepth}))
+ {
+ @dents=qw(AND OR);
+ }
+ push(@dents, $PATH_ALLTRACKS, $PATH_NOARTIST, $self->artists());
}
}
elsif($state==$STATE_BOOLEAN)
sub state
{
my($self, $newstate)=@_;
- $self->{state}=$newstate if(defined($newstate));
+ if(defined($newstate))
+ {
+ $self->{state}=$newstate;
+ $self->{curtagdepth}++ if($newstate == $STATE_TAG);
+ }
return $self->{state};
}
my($self, $dir, $maxdepth)=@_;
return 0 unless($maxdepth);
# print "testing($maxdepth): $dir\n";
- my $path=ID3FS::Path->new($self->{db}, $dir, $self->{verbose});
+ my $path=ID3FS::Path->new($self->{db}, $dir, $self->{verbose}, $self->{tagdepth});
# print "PATH INVALID\n" unless($path->isvalid());
return 1 unless($path->isvalid());
my($subdirs,$subfiles)=$path->dirents();
my $verbose=0;
my $help=0;
my $dbpath=undef;
+my $tagdepth=undef;
Configure(qw(bundling no_ignore_case));
my $optret=GetOptions(
"verbose|v" => sub { $verbose++; },
"help|h" => \$help,
"database|f=s" => \$dbpath,
+ "t|tagdepth=s" => \$tagdepth,
);
usage() if(scalar(@ARGV) != 2 || !$optret || $help);
my $db=ID3FS::DB->new($me, $verbose, 0, $dbpath, $source);
exit unless($db);
-my $fuse=ID3FS::Fuse->new($db, $source, $mountpoint, $verbose);
+my $fuse=ID3FS::Fuse->new($db, $source, $mountpoint, $verbose, $tagdepth);
$fuse->run();
sub usage