lilypond-1.3.129
[lilypond.git] / flower / source.cc
blob8623548e2597af1df188fc76c0311ac673236ebd
1 /*
2 source.cc -- implement Sources
4 source file of the LilyPond music typesetter
6 (c) 1997--2000 Han-Wen Nienhuys <hanwen@cs.uu.nl>
7 */
10 #include <assert.h>
11 #include "killing-cons.tcc"
12 #include "binary-source-file.hh"
13 #include "string.hh"
14 #include "flower-proto.hh"
15 #include "source-file.hh"
16 #include "source.hh"
17 #include "file-path.hh"
19 Sources::Sources ()
21 sourcefile_p_list_ = 0;
22 path_C_= 0;
23 binary_b_ = false;
26 void
27 Sources::set_binary (bool bo)
29 binary_b_ = bo;
32 void
33 Sources::set_path (File_path *f_C)
35 path_C_ = f_C;
38 /**
39 open a file
41 @param file_str the file to be opened, name might be changed if it
42 is found in a search path. UGH!
44 @return 0 if no file found
46 Source_file*
47 Sources::get_file_l (String &file_str) //UGH
49 if ((file_str != "-") && path_C_)
51 String file_str_o = path_C_->find (file_str);
52 if ((file_str_o == "") && (file_str != ""))
53 return 0;
54 file_str = file_str_o;
56 Source_file * f_p = (!binary_b_) ?
57 new Source_file (file_str) : new Binary_source_file (file_str);
58 add (f_p);
59 return f_p;
62 void
63 Sources::add (Source_file* sourcefile_p)
65 sourcefile_p_list_ = new Killing_cons<Source_file> (sourcefile_p, sourcefile_p_list_);
68 Sources::~Sources ()
70 delete sourcefile_p_list_;
72 /**
73 search the list for file whose map contains pointer #ch_C#
75 @return 0 if not found.
77 Source_file*
78 Sources::sourcefile_l (char const* ch_C)
81 for (Cons<Source_file> *i = sourcefile_p_list_; i; i = i->next_)
82 if (i->car_->in_b (ch_C))
83 return i->car_;
84 return 0;