mirror of
https://github.com/dborth/snes9xgx.git
synced 2024-11-01 00:15:14 +01:00
bug fixes for smb - everything works now EXCEPT LoadSMBFile()
This commit is contained in:
parent
654c9b353b
commit
0ddf00e79e
@ -558,7 +558,7 @@ OpenSMB (int method)
|
|||||||
if(ConnectShare ())
|
if(ConnectShare ())
|
||||||
{
|
{
|
||||||
// change current dir to root dir
|
// change current dir to root dir
|
||||||
sprintf(currentdir, GCSettings.LoadFolder);
|
sprintf(currentdir, "/%s", GCSettings.LoadFolder);
|
||||||
|
|
||||||
if (maxfiles = parseSMBdirectory ())
|
if (maxfiles = parseSMBdirectory ())
|
||||||
{
|
{
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <fat.h>
|
#include <fat.h>
|
||||||
#include <zlib.h>
|
#include <zlib.h>
|
||||||
|
#include <smb.h>
|
||||||
|
|
||||||
#include "snes9x.h"
|
#include "snes9x.h"
|
||||||
#include "memmap.h"
|
#include "memmap.h"
|
||||||
@ -39,6 +40,7 @@ extern void S9xSRTCPreSaveState ();
|
|||||||
extern void NGCFreezeStruct ();
|
extern void NGCFreezeStruct ();
|
||||||
extern bool8 S9xUnfreezeGame (const char *filename);
|
extern bool8 S9xUnfreezeGame (const char *filename);
|
||||||
extern unsigned char savebuffer[];
|
extern unsigned char savebuffer[];
|
||||||
|
extern SMBCONN smbconn;
|
||||||
|
|
||||||
static int bufoffset;
|
static int bufoffset;
|
||||||
static char membuffer[MEMBUFFER];
|
static char membuffer[MEMBUFFER];
|
||||||
@ -133,9 +135,11 @@ NGCFreezeGame (int method, bool8 silent)
|
|||||||
method = autoSaveMethod();
|
method = autoSaveMethod();
|
||||||
|
|
||||||
char filename[1024];
|
char filename[1024];
|
||||||
//SMBFILE smbfile;
|
SMBFILE smbfile;
|
||||||
FILE *handle;
|
FILE *handle;
|
||||||
int len = 0;
|
int len = 0;
|
||||||
|
int wrote = 0;
|
||||||
|
int offset = 0;
|
||||||
|
|
||||||
char msg[100];
|
char msg[100];
|
||||||
|
|
||||||
@ -150,7 +154,7 @@ NGCFreezeGame (int method, bool8 silent)
|
|||||||
}
|
}
|
||||||
else if (method == METHOD_SMB) // SMB
|
else if (method == METHOD_SMB) // SMB
|
||||||
{
|
{
|
||||||
sprintf (filename, "/%s/%s.frz", GCSettings.SaveFolder, Memory.ROMFilename);
|
sprintf (filename, "%s/%s.frz", GCSettings.SaveFolder, Memory.ROMFilename);
|
||||||
}
|
}
|
||||||
|
|
||||||
S9xSetSoundMute (TRUE);
|
S9xSetSoundMute (TRUE);
|
||||||
@ -240,8 +244,7 @@ NGCFreezeGame (int method, bool8 silent)
|
|||||||
}
|
}
|
||||||
else if (method == METHOD_SMB) // SMB
|
else if (method == METHOD_SMB) // SMB
|
||||||
{
|
{
|
||||||
/*
|
smbfile = SMB_OpenFile (SMBPath(filename), SMB_OPEN_WRITING | SMB_DENY_NONE, SMB_OF_CREATE | SMB_OF_TRUNCATE, smbconn);
|
||||||
smbfile = SMB_OpenFile (filename, SMB_OPEN_WRITING, SMB_OF_CREATE | SMB_OF_TRUNCATE);
|
|
||||||
|
|
||||||
if (smbfile)
|
if (smbfile)
|
||||||
{
|
{
|
||||||
@ -254,11 +257,11 @@ NGCFreezeGame (int method, bool8 silent)
|
|||||||
{
|
{
|
||||||
if (len > 1024)
|
if (len > 1024)
|
||||||
wrote =
|
wrote =
|
||||||
SMB_Write ((char *) membuffer + offset, 1024, offset,
|
SMB_WriteFile ((char *) membuffer + offset, 1024, offset,
|
||||||
smbfile);
|
smbfile);
|
||||||
else
|
else
|
||||||
wrote =
|
wrote =
|
||||||
SMB_Write ((char *) membuffer + offset, len, offset,
|
SMB_WriteFile ((char *) membuffer + offset, len, offset,
|
||||||
smbfile);
|
smbfile);
|
||||||
|
|
||||||
offset += wrote;
|
offset += wrote;
|
||||||
@ -276,10 +279,9 @@ NGCFreezeGame (int method, bool8 silent)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
char msg[100];
|
char msg[100];
|
||||||
sprintf(msg, "Couldn't save to SMB:\\%s\\", GCSettings.SaveFolder);
|
sprintf(msg, "Couldn't save to SMB: %s", GCSettings.SaveFolder);
|
||||||
WaitPrompt (msg);
|
WaitPrompt (msg);
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -328,7 +330,7 @@ int
|
|||||||
NGCUnfreezeGame (int method, bool8 silent)
|
NGCUnfreezeGame (int method, bool8 silent)
|
||||||
{
|
{
|
||||||
char filename[1024];
|
char filename[1024];
|
||||||
//SMBFILE smbfile;
|
SMBFILE smbfile;
|
||||||
FILE *handle;
|
FILE *handle;
|
||||||
int read = 0;
|
int read = 0;
|
||||||
int offset = 0;
|
int offset = 0;
|
||||||
@ -436,8 +438,7 @@ NGCUnfreezeGame (int method, bool8 silent)
|
|||||||
sprintf (filename, "%s/%s.frz", GCSettings.SaveFolder, Memory.ROMFilename);
|
sprintf (filename, "%s/%s.frz", GCSettings.SaveFolder, Memory.ROMFilename);
|
||||||
|
|
||||||
// Read the file into memory
|
// Read the file into memory
|
||||||
/*smbfile =
|
smbfile = SMB_OpenFile (SMBPath(filename), SMB_OPEN_READING, SMB_OF_OPEN, smbconn);
|
||||||
SMB_OpenFile (filename, SMB_OPEN_READING | SMB_DENY_NONE, SMB_OF_OPEN);
|
|
||||||
|
|
||||||
if (smbfile)
|
if (smbfile)
|
||||||
{
|
{
|
||||||
@ -448,7 +449,7 @@ NGCUnfreezeGame (int method, bool8 silent)
|
|||||||
smbfile)) > 0)
|
smbfile)) > 0)
|
||||||
offset += read;
|
offset += read;
|
||||||
|
|
||||||
SMB_Close (smbfile);
|
SMB_CloseFile (smbfile);
|
||||||
|
|
||||||
if ( !silent )
|
if ( !silent )
|
||||||
ShowAction ((char*) "Unpacking freeze file");
|
ShowAction ((char*) "Unpacking freeze file");
|
||||||
@ -463,7 +464,7 @@ NGCUnfreezeGame (int method, bool8 silent)
|
|||||||
WaitPrompt((char*) "Freeze file not found");
|
WaitPrompt((char*) "Freeze file not found");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
return 1;*/
|
return 1;
|
||||||
}
|
}
|
||||||
return 0; // if we reached here, nothing was done!
|
return 0; // if we reached here, nothing was done!
|
||||||
}
|
}
|
||||||
|
@ -100,6 +100,22 @@ ConnectShare ()
|
|||||||
return networkShareInit;
|
return networkShareInit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* SMBPath
|
||||||
|
*
|
||||||
|
* Returns a SMB-style path
|
||||||
|
*****************************************************************************/
|
||||||
|
|
||||||
|
char * SMBPath(char * path)
|
||||||
|
{
|
||||||
|
// fix path - replace all '/' with '\'
|
||||||
|
for(uint i=0; i < strlen(path); i++)
|
||||||
|
if(path[i] == '/')
|
||||||
|
path[i] = '\\';
|
||||||
|
|
||||||
|
return path;
|
||||||
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* parseSMBDirectory
|
* parseSMBDirectory
|
||||||
*
|
*
|
||||||
@ -113,28 +129,24 @@ parseSMBdirectory ()
|
|||||||
|
|
||||||
SMBDIRENTRY smbdir;
|
SMBDIRENTRY smbdir;
|
||||||
|
|
||||||
sprintf(searchpath, "%s/*", currentdir);
|
if(strlen(searchpath) <= 1) // root
|
||||||
|
sprintf(searchpath, "*");
|
||||||
// fix path - replace all '/' with '\'
|
else
|
||||||
for(uint i=0; i < strlen(searchpath); i++)
|
sprintf(searchpath, "%s/*", currentdir);
|
||||||
if(searchpath[i] == '/')
|
|
||||||
searchpath[i] = '\\';
|
|
||||||
|
|
||||||
ShowAction((char*) "Loading...");
|
|
||||||
|
|
||||||
if (SMB_FindFirst
|
if (SMB_FindFirst
|
||||||
(searchpath, SMB_SRCH_READONLY | SMB_SRCH_DIRECTORY, &smbdir, smbconn) != SMB_SUCCESS)
|
(SMBPath(searchpath), SMB_SRCH_READONLY | SMB_SRCH_DIRECTORY, &smbdir, smbconn) != SMB_SUCCESS)
|
||||||
{
|
{
|
||||||
char msg[200];
|
char msg[200];
|
||||||
sprintf(msg, "Could not open %s", currentdir);
|
sprintf(msg, "Could not open %s", currentdir);
|
||||||
WaitPrompt (msg);
|
WaitPrompt (msg);
|
||||||
|
|
||||||
// if we can't open the dir, open root dir
|
// if we can't open the dir, open root dir
|
||||||
currentdir[0] = '\0';
|
sprintf(searchpath, "/");
|
||||||
sprintf(searchpath,"*");
|
sprintf(searchpath,"*");
|
||||||
|
|
||||||
if (SMB_FindFirst
|
if (SMB_FindFirst
|
||||||
(searchpath, SMB_SRCH_READONLY | SMB_SRCH_DIRECTORY, &smbdir, smbconn) != SMB_SUCCESS)
|
(SMBPath(searchpath), SMB_SRCH_READONLY | SMB_SRCH_DIRECTORY, &smbdir, smbconn) != SMB_SUCCESS)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -196,16 +208,11 @@ LoadSMBFile (char *filename, int length)
|
|||||||
else
|
else
|
||||||
sprintf(filepath, "%s/%s", currentdir, filename);
|
sprintf(filepath, "%s/%s", currentdir, filename);
|
||||||
|
|
||||||
// fix path - replace all '/' with '\'
|
|
||||||
for(uint i=0; i < strlen(filepath); i++)
|
|
||||||
if(filepath[i] == '/')
|
|
||||||
filepath[i] = '\\';
|
|
||||||
|
|
||||||
ShowAction((char *)"Loading...");
|
ShowAction((char *)"Loading...");
|
||||||
|
|
||||||
// Open the file for reading
|
// Open the file for reading
|
||||||
smbfile =
|
smbfile =
|
||||||
SMB_OpenFile (filepath, SMB_OPEN_READING, SMB_OF_OPEN, smbconn);
|
SMB_OpenFile (SMBPath(filepath), SMB_OPEN_READING, SMB_OF_OPEN, smbconn);
|
||||||
if (smbfile)
|
if (smbfile)
|
||||||
{
|
{
|
||||||
while (offset < length)
|
while (offset < length)
|
||||||
@ -301,7 +308,6 @@ LoadSMBFile (char *filename, int length)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Write savebuffer to SMB file
|
* Write savebuffer to SMB file
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
@ -313,13 +319,8 @@ SaveBufferToSMB (char *filepath, int datasize, bool8 silent)
|
|||||||
int wrote = 0;
|
int wrote = 0;
|
||||||
int offset = 0;
|
int offset = 0;
|
||||||
|
|
||||||
// fix path - replace all '/' with '\'
|
|
||||||
for(uint i=0; i < strlen(filepath); i++)
|
|
||||||
if(filepath[i] == '/')
|
|
||||||
filepath[i] = '\\';
|
|
||||||
|
|
||||||
smbfile =
|
smbfile =
|
||||||
SMB_OpenFile (filepath, SMB_OPEN_WRITING | SMB_DENY_NONE,
|
SMB_OpenFile (SMBPath(filepath), SMB_OPEN_WRITING | SMB_DENY_NONE,
|
||||||
SMB_OF_CREATE | SMB_OF_TRUNCATE, smbconn);
|
SMB_OF_CREATE | SMB_OF_TRUNCATE, smbconn);
|
||||||
|
|
||||||
if (smbfile)
|
if (smbfile)
|
||||||
@ -344,7 +345,7 @@ SaveBufferToSMB (char *filepath, int datasize, bool8 silent)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
char msg[100];
|
char msg[100];
|
||||||
sprintf(msg, "Couldn't save SMB: %s", filepath);
|
sprintf(msg, "Couldn't save SMB: %s", SMBPath(filepath));
|
||||||
WaitPrompt (msg);
|
WaitPrompt (msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -361,20 +362,15 @@ LoadBufferFromSMB (char *filepath, bool8 silent)
|
|||||||
int ret;
|
int ret;
|
||||||
int offset = 0;
|
int offset = 0;
|
||||||
|
|
||||||
// fix path - replace all '/' with '\'
|
|
||||||
for(uint i=0; i < strlen(filepath); i++)
|
|
||||||
if(filepath[i] == '/')
|
|
||||||
filepath[i] = '\\';
|
|
||||||
|
|
||||||
smbfile =
|
smbfile =
|
||||||
SMB_OpenFile (filepath, SMB_OPEN_READING, SMB_OF_OPEN, smbconn);
|
SMB_OpenFile (SMBPath(filepath), SMB_OPEN_READING, SMB_OF_OPEN, smbconn);
|
||||||
|
|
||||||
if (!smbfile)
|
if (!smbfile)
|
||||||
{
|
{
|
||||||
if (!silent)
|
if (!silent)
|
||||||
{
|
{
|
||||||
char msg[100];
|
char msg[100];
|
||||||
sprintf(msg, "Couldn't open SMB: %s", filepath);
|
sprintf(msg, "Couldn't open SMB: %s", SMBPath(filepath));
|
||||||
WaitPrompt (msg);
|
WaitPrompt (msg);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
|
|
||||||
bool InitializeNetwork(bool silent);
|
bool InitializeNetwork(bool silent);
|
||||||
bool ConnectShare ();
|
bool ConnectShare ();
|
||||||
|
char * SMBPath(char * path);
|
||||||
int updateSMBdirname();
|
int updateSMBdirname();
|
||||||
int parseSMBdirectory ();
|
int parseSMBdirectory ();
|
||||||
int LoadSMBFile (char *filename, int length);
|
int LoadSMBFile (char *filename, int length);
|
||||||
|
Loading…
Reference in New Issue
Block a user