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

Function SaveINESFile

src/drivers/win/header_editor.cpp:1873–1912  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1871}
1872
1873bool SaveINESFile(HWND hwnd, char* path, iNES_HEADER* header)
1874{
1875 char buf[4096];
1876 const char* ext[] = { "nes", 0 };
1877
1878 // Source file
1879 FCEUFILE* source = FCEU_fopen(LoadedRomFName, NULL, "rb", 0, -1, ext);
1880 if (!source)
1881 {
1882 sprintf(buf, "Opening source file %s failed.", LoadedRomFName);
1883 MessageBox(hwnd, buf, "NES Header Editor", MB_OK | MB_ICONERROR);
1884 return false;
1885 }
1886
1887 // Destination file
1888 FILE* target = FCEUD_UTF8fopen(path, "wb");
1889 if (!target)
1890 {
1891 sprintf(buf, "Creating target file %s failed.", path);
1892 MessageBox(hwnd, buf, "NES Header Editor", MB_OK | MB_ICONERROR);
1893 FCEU_fclose(source);
1894 return false;
1895 }
1896
1897 memset(buf, 0, sizeof(buf));
1898
1899 // Write the header first
1900 fwrite(header, 1, sizeof(iNES_HEADER), target);
1901 // Skip the original header
1902 FCEU_fseek(source, sizeof(iNES_HEADER), SEEK_SET);
1903 int len;
1904 while (len = FCEU_fread(buf, 1, sizeof(buf), source))
1905 fwrite(buf, len, 1, target);
1906
1907 FCEU_fclose(source);
1908 fclose(target);
1909
1910 return true;
1911
1912}
1913
1914bool SearchByString(HWND hwnd, UINT id, int* value, char* buf, iNES_HEADER* header)
1915{

Callers 2

HeaderEditorProcFunction · 0.85
saveFileAsMethod · 0.85

Calls 5

FCEU_fopenFunction · 0.85
FCEU_fcloseFunction · 0.85
FCEU_fseekFunction · 0.85
FCEU_freadFunction · 0.85
FCEUD_UTF8fopenFunction · 0.70

Tested by

no test coverage detected