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

Function main

source/main.cpp:219–397  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

217// ***********************************************************************
218
219int main(int argc, char* argv[]) {
220 g_pArenaFrame = ArenaCreate();
221 g_pArenaPermenant = ArenaCreate();
222
223 Log::LogConfig log;
224 log.critCrashes = false;
225 log.customHandler1 = AssertHandler;
226 Log::SetConfig(log);
227
228 String startupAppName;
229
230 if (argc > 1) {
231 if (strcmp(argv[1], "-import") == 0) {
232 if (argc < 4) {
233 Log::Info("required format for import is \"import [-t|-b|-c|-bt] path/source_filename <projectname>/output_filename.file\"");
234 Log::Info("-t: text -b: binary uncompressed -c: binary compressed -bt: base64 encoded binary");
235 Log::Info("will default to -c");
236 return 1;
237 }
238 u8 format = 0x3;
239 u8 fileArg = 3;
240 if (strcmp(argv[2], "-t") == 0) {
241 format = 0;
242 }
243 else if (strcmp(argv[2], "-bt") == 0) {
244 format = 0x7;
245 }
246 else if (strcmp(argv[2], "-b") == 0) {
247 format = 0x1;
248 }
249 else if (strcmp(argv[2], "-c") == 0) {
250 format = 0x3;
251 }
252 else {
253 fileArg = 2;
254 }
255
256 // @TODO: if paths are given instead of files, process the whole folder instead
257 Arena* pArena = ArenaCreate();
258 String sourceFile = String(argv[fileArg]);
259 String outputFile = String(argv[fileArg+1]);
260
261 ResizableArray<String> outputPathSections = Split(pArena, outputFile, "/\\");
262 String projectName = outputPathSections[0];
263
264 String projectPath = TempPrint("system/%S/", projectName);
265 if (!FolderExists(projectPath)) {
266 Log::Warn("Project %S does not exist, cannot import", projectName);
267 return -1;
268 }
269
270 AssetImporter::AssetImportTable* pImportTable = AssetImporter::LoadImportTable(projectName);
271
272 i32 result = AssetImporter::ImportFile(pArena, format, sourceFile, outputFile);
273 if (result >= 0) {
274 Log::Info("Import succeeded");
275
276 File sourceFileHdl = OpenFile(sourceFile, FM_READ);

Callers

nothing calls this directly

Calls 15

LoadImportTableFunction · 0.85
ImportFileFunction · 0.85
SaveImportTableFunction · 0.85
GenerateProjectFunction · 0.85
InitFunction · 0.85
GraphicsInitFunction · 0.85
InputInitFunction · 0.85
LoadAppFunction · 0.85
StartFunction · 0.85
ClearStatesFunction · 0.85
ProcessEventFunction · 0.85
UpdateInputsFunction · 0.85

Tested by

no test coverage detected