| 150 | |
| 151 | |
| 152 | bool |
| 153 | OSLCompilerImpl::preprocess_file (const std::string &filename, |
| 154 | const std::string &stdoslpath, |
| 155 | const std::vector<std::string> &defines, |
| 156 | const std::vector<std::string> &includepaths, |
| 157 | std::string &result) |
| 158 | { |
| 159 | // Read file contents into a string |
| 160 | std::ifstream instream; |
| 161 | OIIO::Filesystem::open(instream, filename); |
| 162 | if (! instream.is_open()) { |
| 163 | error (ustring(filename), 0, "Could not open \"%s\"\n", filename.c_str()); |
| 164 | return false; |
| 165 | } |
| 166 | |
| 167 | instream.unsetf (std::ios::skipws); |
| 168 | std::string instring (std::istreambuf_iterator<char>(instream.rdbuf()), |
| 169 | std::istreambuf_iterator<char>()); |
| 170 | instream.close (); |
| 171 | |
| 172 | return preprocess_buffer (instring, filename, stdoslpath, defines, |
| 173 | includepaths, result); |
| 174 | } |
| 175 | |
| 176 | |
| 177 | |