MCPcopy Create free account
hub / github.com/TASEmulators/fceux / FDSClose

Function FDSClose

src/fds.cpp:911–948  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

909}
910
911void FDSClose(void) {
912 FILE *fp;
913 int x;
914 isFDS = false;
915
916 if (!DiskWritten) return;
917
918 const std::string &fn = FCEU_MakeFName(FCEUMKF_FDS, 0, 0);
919 if (!(fp = FCEUD_UTF8fopen(fn.c_str(), "wb"))) {
920 return;
921 }
922
923 for (x = 0; x < TotalSides; x++) {
924 if (fwrite(diskdata[x], 1, 65500, fp) != 65500) {
925 FCEU_PrintError("Error saving FDS image!");
926 fclose(fp);
927 return;
928 }
929 }
930
931 for (x = 0; x < TotalSides; x++)
932 if (diskdatao[x]) {
933 free(diskdatao[x]);
934 diskdatao[x] = 0;
935 }
936
937 FreeFDSMemory();
938 if(FDSBIOS)
939 free(FDSBIOS);
940 FDSBIOS = NULL;
941 if(FDSRAM)
942 free(FDSRAM);
943 FDSRAM = NULL;
944 if(CHRRAM)
945 free(CHRRAM);
946 CHRRAM = NULL;
947 fclose(fp);
948}

Callers 1

FDSGIFunction · 0.85

Calls 4

FCEU_MakeFNameFunction · 0.85
FCEU_PrintErrorFunction · 0.85
FreeFDSMemoryFunction · 0.85
FCEUD_UTF8fopenFunction · 0.70

Tested by

no test coverage detected