]> git.donarmstrong.com Git - lilypond.git/blob - lily/sources.cc
bfd3e0d2954fe1868ccf5a2b2924ed5f5806ea80
[lilypond.git] / lily / sources.cc
1 /*
2   source.cc -- implement Sources
3
4   source file of the LilyPond music typesetter
5
6   (c) 1997--2007 Han-Wen Nienhuys <hanwen@xs4all.nl>
7 */
8
9 #include "sources.hh"
10
11 #include "source-file.hh"
12 #include "file-path.hh"
13
14 Sources::Sources ()
15 {
16   path_ = 0;
17 }
18
19
20 Sources::Sources (Sources const &)
21 {
22   assert (false);
23 }
24
25
26 void
27 Sources::set_path (File_path *f)
28 {
29   path_ = f;
30 }
31
32 /**
33    open a file
34
35    File_string the file to be opened, name might be changed if it is
36    found in a search path.
37 */
38 Source_file *
39 Sources::get_file (string *file_string) //UGH
40 {
41   if (*file_string != "-" && path_)
42     {
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;
47     }
48   Source_file *f = new Source_file (*file_string);
49   add (f);
50   return f;
51 }
52
53 void
54 Sources::add (Source_file *sourcefile)
55 {
56   sourcefiles_.push_back (sourcefile);
57 }
58
59 Sources::~Sources ()
60 {
61   for (vsize i = 0; i < sourcefiles_.size (); i++)
62     {
63       sourcefiles_[i]->unprotect ();
64     }
65 }
66