fix thinko when dealing with non-MIDI tracks
[ardour.git] / libs / ardour / tape_file_matcher.cc
1 /*
2  * Copyright (C) 2008-2016 Paul Davis <paul@linuxaudiosystems.com>
3  * Copyright (C) 2009 David Robillard <d@drobilla.net>
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License along
16  * with this program; if not, write to the Free Software Foundation, Inc.,
17  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18  */
19
20 #include "pbd/error.h"
21
22 #include "ardour/tape_file_matcher.h"
23
24 #include "pbd/i18n.h"
25
26 using namespace std;
27
28 namespace {
29
30 const char* const tape_file_regex_string = X_("/T[0-9][0-9][0-9][0-9]-");
31
32 }
33
34 namespace ARDOUR {
35
36 TapeFileMatcher::TapeFileMatcher()
37 {
38         int err;
39
40         if ((err = regcomp (&m_compiled_pattern,
41                                         tape_file_regex_string, REG_EXTENDED|REG_NOSUB)))
42         {
43                 char msg[256];
44
45                 regerror (err, &m_compiled_pattern, msg, sizeof (msg));
46
47                 PBD::error << string_compose (_("Cannot compile tape track regexp for use (%1)"), msg) << endmsg;
48                 // throw
49         }
50
51 }
52
53 bool
54 TapeFileMatcher::matches (const string& audio_filename) const
55 {
56
57         if (regexec (&m_compiled_pattern, audio_filename.c_str(), 0, 0, 0) == 0)
58         {
59                 // matches
60                 return true;
61         }
62         return false;
63 }
64
65 } // namespace ARDOUR