add stub ID3FS::File and subclasses
authorIan Beckwith <ianb@erislabs.net>
Sun, 19 Sep 2010 21:56:15 +0000 (22:56 +0100)
committerIan Beckwith <ianb@erislabs.net>
Sun, 19 Sep 2010 21:56:15 +0000 (22:56 +0100)
lib/ID3FS/DB.pm
lib/ID3FS/File.pm [new file with mode: 0644]
lib/ID3FS/File/Flac.pm [new file with mode: 0644]
lib/ID3FS/File/Mp3.pm [new file with mode: 0644]
lib/ID3FS/File/Ogg.pm [new file with mode: 0644]

index 32db70a..9da8069 100644 (file)
@@ -3,6 +3,7 @@ package ID3FS::DB;
 use strict;
 use warnings;
 use DBI;
+use ID3FS::File;
 
 our $SCHEMA_VERSION=1;
 
@@ -83,6 +84,7 @@ sub cmd_sth
 sub add
 {
     my($self,$path)=@_;
+    my $file=ID3FS::File->new($path);
 }
 
 sub cmd
diff --git a/lib/ID3FS/File.pm b/lib/ID3FS/File.pm
new file mode 100644 (file)
index 0000000..9aa26c4
--- /dev/null
@@ -0,0 +1,35 @@
+package ID3FS::File;
+
+use strict;
+use warnings;
+use ID3FS::File::Mp3;
+use ID3FS::File::Ogg;
+use ID3FS::File::Flac;
+
+# omg a factory class, I feel vaguely dirty
+sub new
+{
+    my (undef,$path)=@_;
+    my $ext=($path=~/.*\.(.*)/)[0];
+    return undef unless($ext);
+    $ext=lc($ext);
+    if($ext eq "mp3")
+    {
+       return ID3FS::File::Mp3->new($path);
+    }
+    elsif($ext eq "ogg")
+    {
+       return ID3FS::File::Ogg->new($path);
+    }
+    elsif($ext eq "flac")
+    {
+       return ID3FS::File::Ogg->new($path);
+    }
+    else
+    {
+       print("Unknown extension: $ext\n");
+       return undef;
+    }
+}
+
+1;
diff --git a/lib/ID3FS/File/Flac.pm b/lib/ID3FS/File/Flac.pm
new file mode 100644 (file)
index 0000000..faf11e1
--- /dev/null
@@ -0,0 +1,18 @@
+package ID3FS::File::Flac;
+
+use strict;
+use warnings;
+
+sub new
+{
+    my $proto=shift;
+    my $class=ref($proto) || $proto;
+    my $self={};
+    bless($self,$class);
+    # FIXME
+    print "FLAC UNIMPLEMENTED\n";
+    $self->{path}=shift;
+    return $self;
+}
+
+1;
diff --git a/lib/ID3FS/File/Mp3.pm b/lib/ID3FS/File/Mp3.pm
new file mode 100644 (file)
index 0000000..3f8964e
--- /dev/null
@@ -0,0 +1,18 @@
+package ID3FS::File::Mp3;
+
+use strict;
+use warnings;
+
+sub new
+{
+    my $proto=shift;
+    my $class=ref($proto) || $proto;
+    my $self={};
+    bless($self,$class);
+
+    $self->{path}=shift;
+    return $self;
+}
+
+1;
+
diff --git a/lib/ID3FS/File/Ogg.pm b/lib/ID3FS/File/Ogg.pm
new file mode 100644 (file)
index 0000000..0f664b0
--- /dev/null
@@ -0,0 +1,18 @@
+package ID3FS::File::Ogg;
+
+use strict;
+use warnings;
+
+sub new
+{
+    my $proto=shift;
+    my $class=ref($proto) || $proto;
+    my $self={};
+    bless($self,$class);
+    # FIXME
+    print "OGG UNIMPLEMENTED\n";
+    $self->{path}=shift;
+    return $self;
+}
+
+1;