]> git.donarmstrong.com Git - lilypond.git/blob - lib/source.cc
release: 0.1.9
[lilypond.git] / lib / source.cc
1 /*
2   source.cc -- implement Sources
3
4   source file of the LilyPond music typesetter
5
6   (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
7 */
8
9
10 #include <assert.h>
11
12 #include "binary-source-file.hh"
13 #include "string.hh"
14 #include "proto.hh"
15 #include "plist.hh"
16 #include "source-file.hh"
17 #include "source.hh"
18 #include "path.hh"
19
20 void
21 Sources::set_path(File_path *f_C)
22 {
23     path_C_ = f_C;
24 }
25
26 /**
27   open a file
28
29   @param file_str the file to be opened, name might be changed if it
30   is found in a search path. UGH!
31
32   @return 0 if no file found
33   */
34 Source_file*
35 Sources::get_file_l(String &file_str ) //UGH
36 {
37     if (path_C_)
38       {
39         String file_str_o = path_C_->find(file_str); 
40         if ( ( file_str_o == "" ) && ( file_str != "" ) )
41             return 0;
42         file_str = file_str_o;
43       }
44     Source_file * f_p= (!binary_b_) ?
45         new Source_file(file_str) : new Binary_source_file(file_str);
46     add(f_p);
47     return f_p;
48 }
49
50 Sources::Sources()
51 {
52     path_C_= 0;
53     binary_b_ = false;
54 }
55
56 void
57 Sources::add( Source_file* sourcefile_p )
58 {
59     sourcefile_p_list_.bottom().add( sourcefile_p );
60 }
61
62 /**
63   search the list for file whose map contains pointer #ch_C#
64
65   @return 0 if not found.
66   */
67 Source_file*
68 Sources::sourcefile_l( char const* ch_C )
69 {
70     PCursor<Source_file*> sourcefile_l_pcur( sourcefile_p_list_.top() );
71     for ( ; sourcefile_l_pcur.ok(); sourcefile_l_pcur++ )
72         if ( sourcefile_l_pcur->in_b( ch_C ) )  
73             return *sourcefile_l_pcur;
74     return 0;
75 }
76
77 Sources::~Sources()
78 {}