MCPcopy Index your code
hub / github.com/4ian/GDevelop / loadVariableFromJSONFileAsync

Function loadVariableFromJSONFileAsync

Extensions/FileSystem/filesystemtools.ts:484–509  ·  view source on GitHub ↗
(
      variable: gdjs.Variable,
      loadPath: string,
      resultVar: gdjs.Variable,
      removeCRCharacters: boolean
    )

Source from the content-addressed store, hash-verified

482 * @param removeCRCharacters If true, will remove \r characters usually added by Windows when editing files
483 */
484 export const loadVariableFromJSONFileAsync = function (
485 variable: gdjs.Variable,
486 loadPath: string,
487 resultVar: gdjs.Variable,
488 removeCRCharacters: boolean
489 ) {
490 if (fs) {
491 fs.readFile(loadPath, 'utf8', (err, data) => {
492 if (data) {
493 variable.fromJSON(
494 removeCRCharacters ? data.replace(/\r/g, '') : data
495 );
496 resultVar.setString('ok');
497 }
498 if (err) {
499 logger.error(
500 "Unable to load variable from the file at path: '" +
501 loadPath +
502 "': ",
503 err
504 );
505 resultVar.setString('error');
506 }
507 });
508 }
509 };
510
511 export const loadVariableFromJSONFileAsyncTask = (
512 variable: gdjs.Variable,

Callers

nothing calls this directly

Calls 4

replaceMethod · 0.80
errorMethod · 0.65
fromJSONMethod · 0.45
setStringMethod · 0.45

Tested by

no test coverage detected