]> git.donarmstrong.com Git - lilypond.git/blob - lily/source.cc
* The grand 2005-2006 replace.
[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   sourcefile_list_ = 0;
18   path_ = 0;
19   is_binary_ = false;
20 }
21
22 void
23 Sources::set_binary (bool bo)
24 {
25   is_binary_ = bo;
26 }
27
28 void
29 Sources::set_path (File_path *f)
30 {
31   path_ = f;
32 }
33
34 /**
35    open a file
36
37    @param file_string the file to be opened, name might be changed if it
38    is found in a search path. UGH!
39
40    @return 0 if no file found
41 */
42 Source_file *
43 Sources::get_file (String &file_string) //UGH
44 {
45   if ((file_string != "-") && path_)
46     {
47       String file_string_o = path_->find (file_string);
48       if ((file_string_o == "") && (file_string != ""))
49         return 0;
50       file_string = file_string_o;
51     }
52   Source_file *f = new Source_file (file_string);
53   add (f);
54   return f;
55 }
56
57 void
58 Sources::add (Source_file *sourcefile)
59 {
60   sourcefile_list_ = new Killing_cons<Source_file> (sourcefile, sourcefile_list_);
61 }
62
63 Sources::~Sources ()
64 {
65   delete sourcefile_list_;
66 }
67 /**
68    search the list for file whose map contains pointer #str0#
69
70    @return 0 if not found.
71 */
72 Source_file *
73 Sources::get_sourcefile (char const *str0)
74 {
75
76   for (Cons<Source_file> *i = sourcefile_list_; i; i = i->next_)
77     if (i->car_->contains (str0))
78       return i->car_;
79   return 0;
80 }
81