X-Git-Url: http://vcs.maemo.org/git/?a=blobdiff_plain;f=memmap.cpp;fp=memmap.cpp;h=9113f411ec175f9bddc930e4f47cfeaa59a0cc52;hb=d9ca4f87ccfc9c17594e8baafde24516c08c80f4;hp=bb60d5ca10996f42d2f9df0d383021cbe0302ef2;hpb=f7eb91bfcf1ee302aaf116a5948d19c5bc298972;p=drnoksnes diff --git a/memmap.cpp b/memmap.cpp index bb60d5c..9113f41 100644 --- a/memmap.cpp +++ b/memmap.cpp @@ -41,9 +41,7 @@ #include #include -#ifdef __linux -//#include -#endif +/* Do not reencode this file. There are special chars on it. */ #include "snes9x.h" #include "memmap.h" @@ -1008,34 +1006,34 @@ bool8_32 CMemory::LoadSRAM (const char *filename) bool8_32 CMemory::SaveSRAM (const char *filename) { - int size = Memory.SRAMSize ? - (1 << (Memory.SRAMSize + 3)) * 128 : 0; - if (Settings.SRTC) - { - size += SRTC_SRAM_PAD; - S9xSRTCPreSaveState (); - } + size_t size = Memory.SRAMSize ? + (1 << (Memory.SRAMSize + 3)) * 128 : 0; - if (Settings.SDD1) - S9xSDD1SaveLoggedData (); + if (Settings.SRTC) + { + size += SRTC_SRAM_PAD; + S9xSRTCPreSaveState (); + } - if (size > 0x20000) - size = 0x20000; + if (Settings.SDD1) S9xSDD1SaveLoggedData (); - if (size && *Memory.ROMFilename) - { - FILE *file; - if ((file = fopen (filename, "wb"))) + if (size > 0x20000) size = 0x20000; + + if (size && *Memory.ROMFilename) { - fwrite ((char *) ::SRAM, size, 1, file); - fclose (file); -#if defined(__linux) - chown (filename, getuid (), getgid ()); -#endif - return (TRUE); - } + FILE *file; + if ((file = fopen (filename, "wb"))) + { + if (fwrite((char *) ::SRAM, size, 1, file) == size) { + fclose(file); + return TRUE; + } + fclose(file); + return FALSE; + } } - return (FALSE); + + return FALSE; } void CMemory::FixROMSpeed ()