MCPcopy Create free account
hub / github.com/DavidColson/Polybox / readSource

Method readSource

source/cpu.cpp:261–282  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

259
260struct LuaFileResolver : Luau::FileResolver {
261 std::optional<Luau::SourceCode> readSource(const Luau::ModuleName& name) override {
262 Luau::SourceCode::Type sourceType;
263 std::optional<std::string> source = std::nullopt;
264
265 File file = OpenFile(String(name.c_str()), FM_READ);
266 defer(CloseFile(file));
267
268 if (!IsValid(file))
269 return std::nullopt;
270
271 i64 sourceSize = GetFileSize(file);
272 std::string result(sourceSize, 0);
273 ReadFromFile(file, result.data(), sourceSize);
274
275 source = result;
276 sourceType = Luau::SourceCode::Module;
277
278 if (!source)
279 return std::nullopt;
280
281 return Luau::SourceCode{*source, sourceType};
282 }
283
284 std::optional<Luau::ModuleInfo> resolveModule(const Luau::ModuleInfo* context, Luau::AstExpr* node) override {
285 if (Luau::AstExprConstantString* expr = node->as<Luau::AstExprConstantString>()) {

Callers

nothing calls this directly

Calls 1

StringClass · 0.70

Tested by

no test coverage detected