From 1656edb2884ec63c571d6b1fffff9291716f7dd8 Mon Sep 17 00:00:00 2001 From: Ian Beckwith Date: Sun, 19 Sep 2010 22:56:15 +0100 Subject: [PATCH] add stub ID3FS::File and subclasses --- lib/ID3FS/DB.pm | 2 ++ lib/ID3FS/File.pm | 35 +++++++++++++++++++++++++++++++++++ lib/ID3FS/File/Flac.pm | 18 ++++++++++++++++++ lib/ID3FS/File/Mp3.pm | 18 ++++++++++++++++++ lib/ID3FS/File/Ogg.pm | 18 ++++++++++++++++++ 5 files changed, 91 insertions(+) create mode 100644 lib/ID3FS/File.pm create mode 100644 lib/ID3FS/File/Flac.pm create mode 100644 lib/ID3FS/File/Mp3.pm create mode 100644 lib/ID3FS/File/Ogg.pm diff --git a/lib/ID3FS/DB.pm b/lib/ID3FS/DB.pm index 32db70a..9da8069 100644 --- a/lib/ID3FS/DB.pm +++ b/lib/ID3FS/DB.pm @@ -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 index 0000000..9aa26c4 --- /dev/null +++ b/lib/ID3FS/File.pm @@ -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 index 0000000..faf11e1 --- /dev/null +++ b/lib/ID3FS/File/Flac.pm @@ -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 index 0000000..3f8964e --- /dev/null +++ b/lib/ID3FS/File/Mp3.pm @@ -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 index 0000000..0f664b0 --- /dev/null +++ b/lib/ID3FS/File/Ogg.pm @@ -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; -- 2.11.0