]> git.donarmstrong.com Git - lilypond.git/blob - lib/source.cc
release: 0.0.52
[lilypond.git] / lib / source.cc
1 /*
2   source.cc -- implement Source
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
19 void
20 Sources::set_path(File_path *f_C)
21 {
22     path_C_ = f_C;
23 }
24
25 /**
26   open a file
27
28   @param file_str the file to be opened, name might be changed if it
29   is found in a search path. UGH!
30
31   @return 0 if no file found
32   */
33 Source_file*
34 Sources::get_file_l(String &file_str ) //UGH
35 {
36     if (path_C_){
37         String file_str_o = path_C_->find(file_str); 
38         if ( ( file_str_o == "" ) && ( file_str != "" ) )
39             return 0;
40         file_str = file_str_o;
41     }
42     Source_file * f_p= (!binary_b_) ?
43         new Source_file(file_str) : new Binary_source_file(file_str);
44     add(f_p);
45     return f_p;
46 }
47
48 Sources::Sources()
49 {
50     path_C_= 0;
51     binary_b_ = false;
52 }
53
54 void
55 Sources::add( Source_file* sourcefile_p )
56 {
57     sourcefile_p_iplist_.bottom().add( sourcefile_p );
58 }
59
60 /**
61   search the list for file whose map contains pointer #ch_C#
62
63   @return 0 if not found.
64   */
65 Source_file*
66 Sources::sourcefile_l( char const* ch_C )
67 {
68     PCursor<Source_file*> sourcefile_l_pcur( sourcefile_p_iplist_.top() );
69     for ( ; sourcefile_l_pcur.ok(); sourcefile_l_pcur++ )
70         if ( sourcefile_l_pcur->in_b( ch_C ) )  
71             return *sourcefile_l_pcur;
72     return 0;
73 }