Some minimal fixes and clean-ups.
This commit is contained in:
parent
153a3d6f23
commit
ce8c18789f
|
@ -383,7 +383,11 @@ if(GameInfo->type==GIT_NSF)
|
|||
}
|
||||
else
|
||||
{
|
||||
if(fwrite(&head,1,16,fp)!=16)return;
|
||||
if(fwrite(&head,1,16,fp)!=16)
|
||||
{
|
||||
fclose(fp);
|
||||
return;
|
||||
}
|
||||
|
||||
if(head.ROM_type&4) /* Trainer */
|
||||
{
|
||||
|
|
|
@ -585,8 +585,8 @@ BOOL CALLBACK ReplayDialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lP
|
|||
ArchiveScanRecord asr = FCEUD_ScanArchive(filename);
|
||||
if(!asr.isArchive()) {
|
||||
FCEUFILE* fp = FCEU_fopen(filename,0,"rb",0);
|
||||
fp->stream = fp->stream->memwrap();
|
||||
if(fp) {
|
||||
fp->stream = fp->stream->memwrap();
|
||||
HandleScan(hwndDlg,fp ,items);
|
||||
delete fp;
|
||||
}
|
||||
|
@ -787,11 +787,11 @@ static void UpdateRecordDialog(HWND hwndDlg)
|
|||
|
||||
static void UpdateRecordDialogPath(HWND hwndDlg, const std::string &fname)
|
||||
{
|
||||
char* baseMovieDir = strdup(FCEU_GetPath(FCEUMKF_MOVIE).c_str());
|
||||
const std::string &baseMovieDir = FCEU_GetPath(FCEUMKF_MOVIE);
|
||||
char* fn=0;
|
||||
|
||||
// display a shortened filename if the file exists in the base movie directory
|
||||
if(!strncmp(fname.c_str(), baseMovieDir, strlen(baseMovieDir)))
|
||||
if(!strncmp(fname.c_str(), baseMovieDir.c_str(), baseMovieDir.size()))
|
||||
{
|
||||
char szDrive[MAX_PATH]={0};
|
||||
char szDirectory[MAX_PATH]={0};
|
||||
|
|
|
@ -705,7 +705,7 @@ int TextHookerSaveTableFile(){
|
|||
FP = fopen(nameo,"wb");
|
||||
line = 0; //init the line counter
|
||||
|
||||
char hex[] = { 0 ,0 };
|
||||
char hex[3] = { 0, 0, 0 };
|
||||
|
||||
//write the table file to the file
|
||||
for ( i = 0; i < 256; i++ ) { //go through each possible hex value
|
||||
|
|
|
@ -409,17 +409,13 @@ FCEUGI *FCEUI_LoadGameVirtual(const char *name, int OverwriteVidMode)
|
|||
|
||||
const char* romextensions[] = {"nes","fds",0};
|
||||
fp=FCEU_fopen(name,0,"rb",0,-1,romextensions);
|
||||
if(!fp)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
GetFileBase(fp->filename.c_str());
|
||||
|
||||
if(!fp) {
|
||||
FCEU_PrintError("Error opening \"%s\"!",name);
|
||||
return 0;
|
||||
}
|
||||
|
||||
GetFileBase(fp->filename.c_str());
|
||||
//---------
|
||||
|
||||
//file opened ok. start loading.
|
||||
|
|
|
@ -890,16 +890,14 @@ void FDSClose(void)
|
|||
FILE *fp;
|
||||
int x;
|
||||
isFDS = false;
|
||||
char *fn=strdup(FCEU_MakeFName(FCEUMKF_FDS,0,0).c_str());
|
||||
|
||||
if(!DiskWritten) return;
|
||||
|
||||
if(!(fp=FCEUD_UTF8fopen(fn,"wb")))
|
||||
const std::string &fn = FCEU_MakeFName(FCEUMKF_FDS,0,0);
|
||||
if(!(fp=FCEUD_UTF8fopen(fn.c_str(),"wb")))
|
||||
{
|
||||
free(fn);
|
||||
return;
|
||||
}
|
||||
free(fn);
|
||||
|
||||
for(x=0;x<TotalSides;x++)
|
||||
{
|
||||
|
|
12
src/ines.cpp
12
src/ines.cpp
|
@ -845,7 +845,11 @@ int iNesSave(){
|
|||
|
||||
fp = fopen(name,"wb");
|
||||
|
||||
if(fwrite(&head,1,16,fp)!=16)return 0;
|
||||
if(fwrite(&head,1,16,fp)!=16)
|
||||
{
|
||||
fclose(fp);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if(head.ROM_type&4) /* Trainer */
|
||||
{
|
||||
|
@ -872,7 +876,11 @@ int iNesSaveAs(char* name)
|
|||
int x = 0;
|
||||
if (!fp)
|
||||
int x = 1;
|
||||
if(fwrite(&head,1,16,fp)!=16)return 0;
|
||||
if(fwrite(&head,1,16,fp)!=16)
|
||||
{
|
||||
fclose(fp);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if(head.ROM_type&4) /* Trainer */
|
||||
{
|
||||
|
|
|
@ -531,7 +531,6 @@ int SaveSnapshot(void)
|
|||
{
|
||||
unsigned int lastu=0;
|
||||
|
||||
char *fn=0;
|
||||
int totallines=FSettings.LastSLine-FSettings.FirstSLine+1;
|
||||
int x,u,y;
|
||||
FILE *pp=NULL;
|
||||
|
@ -543,20 +542,19 @@ int SaveSnapshot(void)
|
|||
|
||||
for(u=lastu;u<99999;u++)
|
||||
{
|
||||
pp=FCEUD_UTF8fopen((fn=strdup(FCEU_MakeFName(FCEUMKF_SNAP,u,"png").c_str())),"rb");
|
||||
pp=FCEUD_UTF8fopen(FCEU_MakeFName(FCEUMKF_SNAP,u,"png").c_str(),"rb");
|
||||
if(pp==NULL) break;
|
||||
fclose(pp);
|
||||
}
|
||||
|
||||
lastu=u;
|
||||
|
||||
if(!(pp=FCEUD_UTF8fopen(fn,"wb")))
|
||||
if(!(pp=FCEUD_UTF8fopen(FCEU_MakeFName(FCEUMKF_SNAP,u,"png").c_str(),"wb")))
|
||||
{
|
||||
free(fn);
|
||||
free(compmem);
|
||||
return 0;
|
||||
}
|
||||
free(fn);
|
||||
|
||||
{
|
||||
static uint8 header[8]={137,80,78,71,13,10,26,10};
|
||||
if(fwrite(header,8,1,pp)!=1)
|
||||
|
@ -644,8 +642,6 @@ int SaveSnapshot(char fileName[512])
|
|||
if(!(compmem=(uint8 *)FCEU_malloc(compmemsize)))
|
||||
return 0;
|
||||
|
||||
pp = fopen(fileName, "w");
|
||||
|
||||
if(!(pp=FCEUD_UTF8fopen(fileName,"wb")))
|
||||
{
|
||||
free(compmem);
|
||||
|
|
Loading…
Reference in New Issue