Merge branch 'fret-diagram-details'
[lilypond/csorensen.git] / lily / sources.cc
blobbfd3e0d2954fe1868ccf5a2b2924ed5f5806ea80
1 /*
2 source.cc -- implement Sources
4 source file of the LilyPond music typesetter
6 (c) 1997--2007 Han-Wen Nienhuys <hanwen@xs4all.nl>
7 */
9 #include "sources.hh"
11 #include "source-file.hh"
12 #include "file-path.hh"
14 Sources::Sources ()
16 path_ = 0;
20 Sources::Sources (Sources const &)
22 assert (false);
26 void
27 Sources::set_path (File_path *f)
29 path_ = f;
32 /**
33 open a file
35 File_string the file to be opened, name might be changed if it is
36 found in a search path.
38 Source_file *
39 Sources::get_file (string *file_string) //UGH
41 if (*file_string != "-" && path_)
43 string file_string_o = path_->find (*file_string);
44 if ((file_string_o == "") && (*file_string != ""))
45 return 0;
46 *file_string = file_string_o;
48 Source_file *f = new Source_file (*file_string);
49 add (f);
50 return f;
53 void
54 Sources::add (Source_file *sourcefile)
56 sourcefiles_.push_back (sourcefile);
59 Sources::~Sources ()
61 for (vsize i = 0; i < sourcefiles_.size (); i++)
63 sourcefiles_[i]->unprotect ();