MCPcopy Create free account
hub / github.com/BlitterStudio/amiberry / inprec_save

Function inprec_save

src/inputrecord.cpp:900–947  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

898}
899
900void inprec_save (const TCHAR *filename, const TCHAR *statefilename)
901{
902 TCHAR path[MAX_DPATH], file[MAX_DPATH];
903 if (!inprec_buffer)
904 return;
905 getpathpart (path, sizeof path / sizeof (TCHAR), filename);
906 getfilepart (file, sizeof file / sizeof (TCHAR), filename);
907 struct zfile *zf = zfile_fopen (filename, _T("wb"), 0);
908 if (zf) {
909 TCHAR fn[MAX_DPATH];
910 uae_u8 *data;
911 data = zfile_getdata (inprec_zf, 0, header_end, NULL);
912 zfile_fwrite (data, header_end, 1, zf);
913 xfree (data);
914 getfilepart (fn, MAX_DPATH, statefilename);
915 char *s = uutf8 (fn);
916 zfile_fwrite (s, strlen (s) + 1, 1, zf);
917 int len = zfile_size32(inprec_zf) - header_end2;
918 data = zfile_getdata (inprec_zf, header_end2, len, NULL);
919 uae_u8 *p = data;
920 uae_u8 *end = data + len;
921 while (p < end) {
922 uae_u8 tmp[MAX_DPATH];
923 int plen = (p[1] << 8) | (p[2] << 0);
924 int wlen = plen - HEADERSIZE;
925 memcpy (tmp, p + HEADERSIZE, wlen);
926 if (p[0] == INPREC_DISKINSERT) {
927 wlen = savedisk (path, file, p + HEADERSIZE, tmp);
928 }
929 if (wlen) {
930 wlen += HEADERSIZE;
931 p[1] = wlen >> 8;
932 p[2] = wlen;
933 zfile_fwrite (p, HEADERSIZE, 1, zf);
934 zfile_fwrite (tmp, wlen - HEADERSIZE, 1, zf);
935 } else {
936 zfile_fwrite (p, plen, 1, zf);
937 }
938 p += plen;
939 }
940 xfree (data);
941 zfile_fclose (zf);
942 savelog (path, file);
943 write_log (_T("inputfile '%s' saved\n"), filename);
944 } else {
945 write_log (_T("failed to open '%s'\n"), filename);
946 }
947}
948
949bool inprec_realtime (void)
950{

Callers

nothing calls this directly

Calls 11

getpathpartFunction · 0.85
getfilepartFunction · 0.85
zfile_fopenFunction · 0.85
zfile_getdataFunction · 0.85
zfile_fwriteFunction · 0.85
uutf8Function · 0.85
zfile_size32Function · 0.85
savediskFunction · 0.85
zfile_fcloseFunction · 0.85
savelogFunction · 0.85
write_logFunction · 0.70

Tested by

no test coverage detected