2 simple-file-storage.cc -- implement Simple_file_storage
4 source file of the GNU LilyPond music typesetter
6 (c) 1997--2000 Han-Wen Nienhuys <hanwen@cs.uu.nl>
15 #include "simple-file-storage.hh"
21 Simple_file_storage::load_stdin ()
27 while ((c = fgetc (stdin)) != EOF)
30 data_ = chs.remove_array ();
34 Simple_file_storage::load_file (String s)
37 let's hope that "b" opens anything binary, and does not apply
40 FILE * f = fopen (s.to_str0 (), "rb");
44 warning (_f ("can't open file: `%s'", s));
48 int ret = fseek (f, 0, SEEK_END);
51 data_ = new char[len_+1];
53 ret = fread (data_, sizeof (char), len_, f);
56 warning (_f ("Huh? Got %d, expected %d characters", ret, len_));
62 Stupid but foolproof way of opening files.
65 Should check IO status
67 This is of course a build it yourself version of mmap, so we should
68 have been using that..., but this is simple & portable
72 Simple_file_storage::Simple_file_storage (String s)
84 Simple_file_storage::to_str0 () const
90 Simple_file_storage::length () const
96 Simple_file_storage::~Simple_file_storage ()