| 171 | } |
| 172 | |
| 173 | Buffer CompileOptions::read_optional(const char *path) |
| 174 | { |
| 175 | TempAllocator256 ta; |
| 176 | DynamicString source_dir(ta); |
| 177 | _data_compiler.source_dir(path, source_dir); |
| 178 | |
| 179 | FilesystemDisk source_filesystem(ta); |
| 180 | source_filesystem.set_prefix(source_dir.c_str()); |
| 181 | |
| 182 | Buffer buf(default_allocator()); |
| 183 | File *file = source_filesystem.open(path, FileOpenMode::READ); |
| 184 | |
| 185 | DynamicString path_str(ta); |
| 186 | path_str = path; |
| 187 | hash_map::set(_new_dependencies |
| 188 | , path_str |
| 189 | , DependencyFlags::OPTIONAL | (file->is_open() ? u32(DependencyFlags::EXISTS) : 0u) |
| 190 | ); |
| 191 | |
| 192 | if (file->is_open()) |
| 193 | file->read_all(buf); |
| 194 | source_filesystem.close(*file); |
| 195 | return buf; |
| 196 | } |
| 197 | |
| 198 | Buffer CompileOptions::read() |
| 199 | { |
no test coverage detected