allow OR and NOT in the filesystem
authorIan Beckwith <ianb@erislabs.net>
Sat, 2 Oct 2010 01:55:31 +0000 (02:55 +0100)
committerIan Beckwith <ianb@erislabs.net>
Sat, 2 Oct 2010 01:55:31 +0000 (02:55 +0100)
lib/ID3FS/Path.pm

index 7107ac7..ae8d7d7 100644 (file)
@@ -79,17 +79,17 @@ sub dirents
        }
        else
        {
-           @dents=(qw(AND ALLTRACKS), # FIXME: NOT and OR
+           @dents=(qw(AND OR ALLTRACKS),
                    $self->{db}->artists(@{$self->{elements}}));
        }
     }
     elsif($state==$STATE_BOOLEAN)
     {
-       @dents=$self->{db}->tags(@{$self->{elements}});
+       @dents=("NOT", $self->{db}->tags(@{$self->{elements}}));
     }
     elsif($state==$STATE_ROOT)
     {
-       @dents=("ALL", $self->{db}->tags(@{$self->{elements}}));
+       @dents=(qw(ALL NOT), $self->{db}->tags(@{$self->{elements}}));
     }
     elsif($state==$STATE_ALBUMS)
     {
@@ -133,6 +133,10 @@ sub parse
            {
                $self->state($STATE_TAG);
            }
+           elsif($name eq "NOT")
+           {
+               $self->state($STATE_BOOLEAN);
+           }
            else
            {
                $tag=ID3FS::PathElement::Tag->new($self->{db}, $name);
@@ -182,11 +186,6 @@ sub parse
                $self->state($STATE_BOOLEAN);
 #              push(@{$self->{elements}}, ID3FS::PathElement::Boolean->new($name));
            }
-           elsif($name eq "NOT")
-           {
-               $self->state($STATE_TAG);
-#              push(@{$self->{elements}}, ID3FS::PathElement::Boolean->new($name));
-           }
            else
            {
                my $artist=ID3FS::PathElement::Artist->new($self->{db}, $name);
@@ -204,15 +203,22 @@ sub parse
        elsif($state==$STATE_BOOLEAN)
        {
 #          print "SM: BOOLEAN: $name\n";
-           my $tag=ID3FS::PathElement::Tag->new($self->{db}, $name);
-           if($tag)
+           if($name eq "NOT")
            {
-               push(@{$self->{elements}}, $tag);
-               $self->state($STATE_TAG);
-               }
+               $self->state($STATE_BOOLEAN);
+           }
            else
            {
-               $self->state($STATE_INVALID);
+               my $tag=ID3FS::PathElement::Tag->new($self->{db}, $name);
+               if($tag)
+               {
+                   push(@{$self->{elements}}, $tag);
+                   $self->state($STATE_TAG);
+               }
+               else
+               {
+                   $self->state($STATE_INVALID);
+               }
            }
        }
        elsif($state==$STATE_ALBUMS)