MCPcopy Create free account
hub / github.com/Moddable-OpenSource/moddable / Resource_constructor

Function Resource_constructor

modules/files/resource/Resource.c:32–47  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

30}
31
32void Resource_constructor(xsMachine *the)
33{
34 xsStringValue path = xsToString(xsArg(0));
35 const void *data = NULL;
36 size_t size;
37 if ((xsToInteger(xsArgc) > 1) && xsTest(xsArg(1)))
38 data = fxGetArchiveData(the, xsGetHostData(xsArg(1)), path, &size);
39 if (!data)
40 data = fxGetArchiveData(the, the->archive, path, &size);
41 if (!data)
42 data = mcGetResource(the, path, &size);
43 if (!data)
44 xsURIError("Resource not found: %s", path);
45 xsSetHostBuffer(xsThis, (void *)data, size);
46 xsPetrifyHostBuffer(xsThis);
47}
48
49void Resource_exists(xsMachine *the)
50{

Callers

nothing calls this directly

Calls 2

fxGetArchiveDataFunction · 0.85
mcGetResourceFunction · 0.50

Tested by

no test coverage detected