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

Function LoadImportTable

source/asset_importer.cpp:471–543  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

469// ***********************************************************************
470
471AssetImportTable* LoadImportTable(String project) {
472 // create a new one if this project has no import table
473 String importTablePath = TempPrint("system/%S/import_table.txt", project);
474
475 Arena* pArena = ArenaCreate();
476 AssetImportTable* pImportTable = New(pArena, AssetImportTable);
477 pImportTable->pArena = pArena;
478 pImportTable->table.pArena = pArena;
479
480 if (!FileExists(importTablePath)) {
481 return pImportTable;
482 }
483
484 String fileContents;
485 fileContents.pData = ReadWholeFile(importTablePath, &fileContents.length, pArena);
486
487 // for each line
488 for (i64 i=0; i<fileContents.length;) {
489 if (fileContents[i] == '"') {
490 i64 start = ++i;
491 while (fileContents[i] != '"') i++;
492 String sourceAsset = SubStr(fileContents, start, i-start);
493
494 i++; // advance over ", and then skip whitespace
495 while (Scan::IsWhitespace(fileContents[i]) && i<fileContents.length) i++;
496
497 start = ++i;
498 while (fileContents[i] != '"' && i<fileContents.length) i++;
499 String outputPath = SubStr(fileContents, start, i-start);
500
501 i++; // advance over ", and then skip whitespace
502 while (Scan::IsWhitespace(fileContents[i]) && i<fileContents.length) i++;
503
504 start = i;
505 while (Scan::IsPartOfNumber(fileContents[i])) i++;
506 String importFormatStr = SubStr(fileContents, start, i-start);
507 u8 importFormat = (u8)atoi(importFormatStr.pData);
508
509 i++;
510 while (Scan::IsWhitespace(fileContents[i]) && i<fileContents.length) i++;
511
512 bool autoImport = false;
513 if (fileContents[i] == '0')
514 autoImport = false;
515 else if (fileContents[i] == '1')
516 autoImport = true;
517 else
518 Log::Warn("Unexpected value found while parsing import table");
519
520 i++; // advance over autoImport, and then skip whitespace
521 while (Scan::IsWhitespace(fileContents[i]) && i<fileContents.length) i++;
522
523 start = i;
524 while (Scan::IsPartOfNumber(fileContents[i])) i++;
525 String lastWriteTimeStr = SubStr(fileContents, start, i-start);
526 u64 lastWriteTime = strtoull(lastWriteTimeStr.pData, nullptr, 10);
527
528 i++; // advance over end of number, and then advance to start of next asset

Callers 2

LoadAppFunction · 0.85
mainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected