MCPcopy Create free account
hub / github.com/crownengine/crown / read_optional

Method read_optional

src/resource/compile_options.cpp:173–196  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

171}
172
173Buffer 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
198Buffer CompileOptions::read()
199{

Callers 1

writeFunction · 0.80

Calls 8

setClass · 0.85
source_dirMethod · 0.80
set_prefixMethod · 0.80
read_allMethod · 0.80
c_strMethod · 0.45
openMethod · 0.45
is_openMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected