ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/Convert-CD/lib/Convert/CD/TOCFile.pm
Revision: 1.3
Committed: Tue Jun 10 12:47:49 2003 UTC (23 years, 3 months ago) by root
Branch: MAIN
Changes since 1.2: +15 -0 lines
Log Message:
*** empty log message ***

File Contents

# User Rev Content
1 root 1.1 =head1 NAME
2    
3     Convert::CD::TOCFile - base class to represent TOC files.
4    
5     =head1 SYNOPSIS
6    
7     use Convert::CD::TOCFile;
8    
9     # to be done
10    
11     =head1 DESCRIPTION
12    
13     A TOCFile object is used to represent file-format-specific information
14     about an image, such as image or track filenames and read/write
15     functionality for toc files.
16    
17     =head2 Convert:CD::TOCFile METHODS
18    
19     =over 4
20    
21     =cut
22    
23     package Convert::CD::TOCFile;
24    
25     $VERSION = 0.01;
26    
27     use File::Spec;
28     use Carp;
29    
30     use Convert::CD;
31    
32     use base Convert::CD::TOCFile;
33    
34     =item new param => value...
35    
36 root 1.2 Create a new Convert::CD::TOCFile object.
37 root 1.1
38     Parameters:
39    
40     path the base image filename
41    
42     =cut
43    
44     sub new {
45     my $class = shift;
46     my $self = bless { @_, }, $class;
47    
48     $self;
49     }
50    
51     =item $toc->find_tocfile suffixes..
52    
53     Try to find a tocfile by probing the given suffixes.
54    
55     =cut
56    
57     sub find_tocfile {
58     my ($self, @ext) = @_;
59    
60     my $stem = $self->{path};
61    
62 root 1.2 $stem =~ s/\.\S{2,4}$//;
63 root 1.1
64     for (@ext) {
65     return "$stem.$_" if -f "$stem.$_";
66     }
67    
68     ();
69     }
70    
71     =item $cd = $toc->read
72    
73     Read the TOC file, returns a new Convert::CD object.
74    
75     =item $toc->write ($cd)
76    
77     Write the TOC File using the information in the given Convert::CD object.
78    
79     =cut
80    
81     sub read {
82     my ($self) = @_;
83    
84     my $cd = new Convert::CD path => $self->{path}
85     or croak "unable to create a new Convert::CD object";
86    
87     $self->_read ($cd);
88 root 1.2
89     $cd;
90 root 1.1 }
91    
92     sub write {
93     my ($self, $cd) = @_;
94    
95     $self->_write ($cd);
96     }
97    
98     # abstract methods
99     sub _read {
100     my ($self, $cd) = @_;
101    
102     croak sprintf "reading %s toc files is not supported", ref $self;
103     }
104    
105     sub _write {
106     my ($self, $cd) = @_;
107    
108     croak sprintf "writing %s toc files is not supported", ref $self;
109     }
110    
111 root 1.3 =item $msf = Convert::CD::TOCFile->parse_msf ($string)
112    
113     Parses a time and returns it as a frame number (can be negative if the
114     string contains a leading minus).
115    
116     Returns C<undef> on error.
117    
118     =cut
119    
120     sub parse_msf {
121     $_[1] =~ /^(-?\d+):(\d+):(\d+)$/
122     or return undef;
123     ($1 * 60 + $2) * 75 + $3;
124     }
125    
126 root 1.1 1;
127    
128     =back
129    
130     =head1 AUTHOR
131    
132     Marc Lehmann <pcg@goof.com>
133    
134     =cut
135