MCPcopy Create free account
hub / github.com/DacoTaco/priiloader / WriteV1UpdateFile

Function WriteV1UpdateFile

tools/HashGenerator/HashGenerator.cpp:51–83  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

49}
50
51char WriteV1UpdateFile(UpdateStructV1* update)
52{
53 //write the version file
54 printf("writing v1 version file...\n");
55 FILE* outputBin = fopen("version.bin", "wb");
56 FILE* outputDat = fopen("version.dat", "wb");
57 if (!outputBin || !outputDat)
58 {
59 if (outputBin)
60 fclose(outputBin);
61 if (outputDat)
62 fclose(outputDat);
63
64 printf("failed to open/create file!\n");
65 return -1;
66 }
67
68 if (Data_Need_Swapping())
69 {
70 printf("the machine is %s endian. a endian swap is needed before writing\n", Data_Need_Swapping() ? "Little" : "Big");
71 //swap hash to big endian
72 endian_swap(update->rc_version);
73 endian_swap(update->rc_number);
74 endian_swap(update->prod_version);
75 }
76
77 fwrite(update, 1, sizeof(UpdateStructV1), outputBin);
78 fwrite(update, 1, sizeof(UpdateStructV1), outputDat);
79 fclose(outputBin);
80 fclose(outputDat);
81 printf("done!\n");
82 return 1;
83}
84
85char WriteUpdateFile(UpdateStruct* update)
86{

Callers 1

mainFunction · 0.85

Calls 2

Data_Need_SwappingFunction · 0.85
endian_swapFunction · 0.85

Tested by

no test coverage detected