$self->{db}=shift;
$self->{path}=shift;
$self->{verbose}=shift;
+ $self->{maxtagdepth}=shift;
+ $self->{curtagdepth}=0;
$self->{path} =~ s/\/\//\//g; # drop doubled slashes
$self->parse();
# print "DIRENTS: FILE: $self->{path}\n";
if($state==$STATE_ALL)
{
- @dents=($self->artists(), $PATH_ALLTRACKS, $PATH_NOARTIST);
+ @dents=($PATH_ALLTRACKS, $PATH_NOARTIST, $self->artists());
}
elsif($state==$STATE_TAG || $state==$STATE_TAGVAL)
{
}
else
{
- @dents=($self->artists(), qw(AND OR), $PATH_ALLTRACKS, $PATH_NOARTIST);
+ if($self->{maxtagdepth} && ($self->{curtagdepth} < $self->{maxtagdepth}))
+ {
+ @dents=qw(AND OR);
+ }
+ push(@dents, $PATH_ALLTRACKS, $PATH_NOARTIST, $self->artists());
}
}
elsif($state==$STATE_BOOLEAN)
{
- @dents=$self->tags();
my $parent=$self->tail();
unless(defined($parent) &&
ref($parent) eq "ID3FS::PathElement::Boolean" &&
$parent->{name} eq "NOT")
{
- push(@dents, "NOT");
+ @dents=("NOT");
}
+ push(@dents,$self->tags());
}
elsif($state==$STATE_ROOT)
{
- @dents=($self->tags(), qw(ALL NOT));
+ @dents=(qw(ALL NOT), $self->tags());
}
elsif($state==$STATE_ALBUMS)
{
- @dents=($self->albums(), $PATH_ALLTRACKS, $PATH_NOALBUM);
+ @dents=($PATH_ALLTRACKS, $PATH_NOALBUM, $self->albums());
}
elsif($state==$STATE_TRACKLIST)
{
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();