#include <string.h>
#include <ctype.h>
-#ifdef __linux
-//#include <unistd.h>
-#endif
+/* Do not reencode this file. There are special chars on it. */
#include "snes9x.h"
#include "memmap.h"
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 ()