]> git.donarmstrong.com Git - lilypond.git/blob - lily/source.cc
* lily/include/midi-item.hh (class Midi_track): idem.
[lilypond.git] / lily / source.cc
1 /*
2   source.cc -- implement Sources
3
4   source file of the LilyPond music typesetter
5
6   (c) 1997--2006 Han-Wen Nienhuys <hanwen@xs4all.nl>
7 */
8
9 #include "source.hh"
10
11 #include "killing-cons.tcc"
12 #include "source-file.hh"
13 #include "file-path.hh"
14
15 Sources::Sources ()
16 {
17   path_ = 0;
18   is_binary_ = false;
19 }
20
21 void
22 Sources::set_binary (bool bo)
23 {
24   is_binary_ = bo;
25 }
26
27 void
28 Sources::set_path (File_path *f)
29 {
30   path_ = f;
31 }
32
33 /**
34    open a file
35
36    @param file_string the file to be opened, name might be changed if it
37    is found in a search path. UGH!
38
39    @return 0 if no file found
40 */
41 Source_file *
42 Sources::get_file (string &file_string) //UGH
43 {
44   if ((file_string != "-") && path_)
45     {
46       string file_string_o = path_->find (file_string);
47       if ((file_string_o == "") && (file_string != ""))
48         return 0;
49       file_string = file_string_o;
50     }
51   Source_file *f = new Source_file (file_string);
52   add (f);
53   return f;
54 }
55
56 void
57 Sources::add (Source_file *sourcefile)
58 {
59   sourcefiles_.push_back (sourcefile);
60 }
61
62 Sources::~Sources ()
63 {
64   junk_pointers (sourcefiles_);
65 }
66
67 Source_file *
68 Sources::get_sourcefile (char const *str0)
69 {
70   for (vector<Source_file*>::iterator i = sourcefiles_.begin();
71        i != sourcefiles_.end (); i++)
72     {
73       if ((*i)->contains (str0))
74         return *i;
75     }
76
77   return 0;
78 }
79