This commit is contained in:
twinaphex 2015-07-23 18:11:15 +02:00
parent 247bcdf1fa
commit adee4dbb33
12 changed files with 2 additions and 231 deletions

View File

@ -253,7 +253,6 @@ ifeq ($(NEED_DEINTERLACER), 1)
endif
MEDNAFEN_SOURCES := $(MEDNAFEN_DIR)/mednafen.cpp \
$(MEDNAFEN_DIR)/error.cpp \
$(MEDNAFEN_DIR)/math_ops.cpp \
$(MEDNAFEN_DIR)/settings.cpp \
$(MEDNAFEN_DIR)/general.cpp \

View File

@ -61,7 +61,6 @@ CORE_SOURCES += $(MEDNAFEN_LIBRETRO_DIR)/scrc32.cpp
endif
MEDNAFEN_SOURCES := $(MEDNAFEN_DIR)/mednafen.cpp \
$(MEDNAFEN_DIR)/error.cpp \
$(MEDNAFEN_DIR)/math_ops.cpp \
$(MEDNAFEN_DIR)/settings.cpp \
$(MEDNAFEN_DIR)/general.cpp \

View File

@ -1,130 +0,0 @@
/* Mednafen - Multi-system Emulator
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "mednafen.h"
#include "error.h"
#include <string.h>
#include <stdarg.h>
#include "include/trio/trio.h"
#include "../libretro.h"
extern retro_log_printf_t log_cb;
MDFN_Error::MDFN_Error() throw()
{
abort();
}
MDFN_Error::MDFN_Error(int errno_code_new, const char *format, ...) throw()
{
errno_code = errno_code_new;
va_list ap;
va_start(ap, format);
error_message = trio_vaprintf(format, ap);
va_end(ap);
if (log_cb)
log_cb(RETRO_LOG_ERROR, "%s\n", error_message);
}
MDFN_Error::MDFN_Error(const ErrnoHolder &enh)
{
errno_code = enh.Errno();
error_message = trio_aprintf("%s", enh.StrError());
}
MDFN_Error::~MDFN_Error() throw()
{
if(error_message)
{
free(error_message);
error_message = NULL;
}
}
MDFN_Error::MDFN_Error(const MDFN_Error &ze_error) throw()
{
if(ze_error.error_message)
error_message = strdup(ze_error.error_message);
else
error_message = NULL;
errno_code = ze_error.errno_code;
}
MDFN_Error& MDFN_Error::operator=(const MDFN_Error &ze_error) throw()
{
char *new_error_message = ze_error.error_message ? strdup(ze_error.error_message) : NULL;
int new_errno_code = ze_error.errno_code;
if(error_message)
free(error_message);
error_message = new_error_message;
errno_code = new_errno_code;
return(*this);
}
const char * MDFN_Error::what(void) const throw()
{
if(!error_message)
return("Error allocating memory for the error message!");
return(error_message);
}
int MDFN_Error::GetErrno(void) const throw()
{
return(errno_code);
}
static const char *srr_wrap(int ret, const char *local_strerror)
{
if(ret == -1)
return("ERROR IN strerror_r()!!!");
return(local_strerror);
}
static const char *srr_wrap(const char *ret, const char *local_strerror)
{
if(ret == NULL)
return("ERROR IN strerror_r()!!!");
return(ret);
}
void ErrnoHolder::SetErrno(int the_errno)
{
local_errno = the_errno;
if(the_errno == 0)
local_strerror[0] = 0;
else
{
strncpy(local_strerror, strerror(the_errno), 255);
local_strerror[255] = 0;
}
}

View File

@ -1,74 +0,0 @@
#ifndef __MDFN_ERROR_H
#define __MDFN_ERROR_H
#include <errno.h>
#include <string.h>
#include <stdexcept>
#ifdef __cplusplus
class ErrnoHolder;
class MDFN_Error : public std::exception
{
public:
MDFN_Error() throw();
MDFN_Error(int errno_code_new, const char *format, ...) throw();
MDFN_Error(const ErrnoHolder &enh);
~MDFN_Error() throw();
MDFN_Error(const MDFN_Error &ze_error) throw();
MDFN_Error & operator=(const MDFN_Error &ze_error) throw();
virtual const char *what(void) const throw();
int GetErrno(void) const throw();
private:
int errno_code;
char *error_message;
};
class ErrnoHolder
{
public:
ErrnoHolder()
{
local_errno = 0;
local_strerror[0] = 0;
}
ErrnoHolder(int the_errno)
{
SetErrno(the_errno);
}
inline int Errno(void) const
{
return(local_errno);
}
const char *StrError(void) const
{
return(local_strerror);
}
void operator=(int the_errno)
{
SetErrno(the_errno);
}
private:
void SetErrno(int the_errno);
int local_errno;
char local_strerror[256];
};
#endif
#endif

View File

@ -65,8 +65,7 @@ MDFNFILE::MDFNFILE()
MDFNFILE::MDFNFILE(const char *path, const void *known_ext, const char *purpose)
{
(void)known_ext;
if (!Open(path, known_ext, purpose, false))
throw(MDFN_Error(0, "TODO ERROR"));
Open(path, known_ext, purpose, false);
}

View File

@ -144,13 +144,9 @@ std::string MDFN_EvalFIP(const std::string &dir_path, const std::string &rel_pat
slash = '/';
#endif
if(!skip_safety_check && !MDFN_IsFIROPSafe(rel_path))
throw MDFN_Error(0, _("Referenced path \"%s\" is potentially unsafe. See \"filesys.untrusted_fip_check\" setting.\n"), rel_path.c_str());
if(IsAbsolutePath(rel_path.c_str()))
return(rel_path);
else
return(dir_path + slash + rel_path);
return(dir_path + slash + rel_path);
}
const char * GetFNComponent(const char *str)

View File

@ -230,11 +230,7 @@ void MDFN_LoadGameCheats(void *override_ptr)
std::string fn = MDFN_MakeFName(MDFNMKF_CHEAT,0,0).c_str();
if(!(fp = fopen(fn.c_str(),"rb")))
{
/* Error opening file. */
ErrnoHolder ene(errno);
return;
}
}
if(SeekToOurSection(fp))
@ -441,10 +437,7 @@ int MDFNI_AddCheat(const char *name, uint32 addr, uint64 val, uint64 compare, ch
char *t;
if(!(t = strdup(name)))
{
/* Error allocating memory for cheat data */
return(0);
}
if(!AddCheatEntry(t, NULL, addr,val,compare,1,type, length, bigendian))
{

View File

@ -205,9 +205,6 @@
<File
RelativePath="..\..\mednafen\endian.cpp">
</File>
<File
RelativePath="..\..\mednafen\error.cpp">
</File>
<File
RelativePath="..\..\mednafen\file.cpp">
</File>

View File

@ -29,7 +29,6 @@
<ItemGroup>
<ClCompile Include="..\..\libretro.cpp" />
<ClCompile Include="..\..\mednafen\endian.cpp" />
<ClCompile Include="..\..\mednafen\error.cpp" />
<ClCompile Include="..\..\mednafen\file.cpp" />
<ClCompile Include="..\..\mednafen\general.cpp" />
<ClCompile Include="..\..\mednafen\math_ops.cpp" />

View File

@ -35,9 +35,6 @@
<ClCompile Include="..\..\mednafen\endian.cpp">
<Filter>Source Files\mednafen</Filter>
</ClCompile>
<ClCompile Include="..\..\mednafen\error.cpp">
<Filter>Source Files\mednafen</Filter>
</ClCompile>
<ClCompile Include="..\..\mednafen\file.cpp">
<Filter>Source Files\mednafen</Filter>
</ClCompile>

View File

@ -13,7 +13,6 @@
<ItemGroup>
<ClCompile Include="..\..\libretro.cpp" />
<ClCompile Include="..\..\mednafen\endian.cpp" />
<ClCompile Include="..\..\mednafen\error.cpp" />
<ClCompile Include="..\..\mednafen\file.cpp" />
<ClCompile Include="..\..\mednafen\general.cpp" />
<ClCompile Include="..\..\mednafen\math_ops.cpp" />

View File

@ -35,9 +35,6 @@
<ClCompile Include="..\..\mednafen\endian.cpp">
<Filter>Source Files\mednafen</Filter>
</ClCompile>
<ClCompile Include="..\..\mednafen\error.cpp">
<Filter>Source Files\mednafen</Filter>
</ClCompile>
<ClCompile Include="..\..\mednafen\file.cpp">
<Filter>Source Files\mednafen</Filter>
</ClCompile>