]> git.donarmstrong.com Git - lilypond.git/blob - lily/source.cc
*** empty log message ***
[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 "source-file.hh"
12 #include "file-path.hh"
13
14 Sources::Sources ()
15 {
16   path_ = 0;
17   is_binary_ = false;
18 }
19
20 void
21 Sources::set_binary (bool bo)
22 {
23   is_binary_ = bo;
24 }
25
26 void
27 Sources::set_path (File_path *f)
28 {
29   path_ = f;
30 }
31
32 /**
33    open a file
34
35    @param file_string the file to be opened, name might be changed if it
36    is found in a search path. UGH!
37
38    @return 0 if no file found
39 */
40 Source_file *
41 Sources::get_file (string &file_string) //UGH
42 {
43   if ((file_string != "-") && path_)
44     {
45       string file_string_o = path_->find (file_string);
46       if ((file_string_o == "") && (file_string != ""))
47         return 0;
48       file_string = file_string_o;
49     }
50   Source_file *f = new Source_file (file_string);
51   add (f);
52   return f;
53 }
54
55 void
56 Sources::add (Source_file *sourcefile)
57 {
58   sourcefiles_.push_back (sourcefile);
59 }
60
61 Sources::~Sources ()
62 {
63   junk_pointers (sourcefiles_);
64 }
65
66 Source_file *
67 Sources::get_sourcefile (char const *str0)
68 {
69   for (vector<Source_file*>::iterator i = sourcefiles_.begin();
70        i != sourcefiles_.end (); i++)
71     {
72       if ((*i)->contains (str0))
73         return *i;
74     }
75
76   return 0;
77 }
78