本文整理汇总了C++中MDFN_Error函数的典型用法代码示例。如果您正苦于以下问题:C++ MDFN_Error函数的具体用法?C++ MDFN_Error怎么用?C++ MDFN_Error使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了MDFN_Error函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: return
bool CDIF_ST::Eject(bool eject_status)
{
if(UnrecoverableError)
return(false);
try
{
int32_t old_de = DiscEjected;
DiscEjected = eject_status;
if(old_de != DiscEjected)
{
disc_cdaccess->Eject(eject_status);
if(!eject_status) // Re-read the TOC
{
disc_cdaccess->Read_TOC(&disc_toc);
if(disc_toc.first_track < 1 || disc_toc.last_track > 99 || disc_toc.first_track > disc_toc.last_track)
throw(MDFN_Error(0, _("TOC first(%d)/last(%d) track numbers bad."), disc_toc.first_track, disc_toc.last_track));
}
}
}
catch(std::exception &e)
{
log_cb(RETRO_LOG_ERROR, "%s\n", e.what());
return(false);
}
return(true);
}
示例2: data_buffer
MemoryStream::MemoryStream() : data_buffer(NULL), data_buffer_size(0), data_buffer_alloced(0), position(0)
{
data_buffer_size = 0;
data_buffer_alloced = 64;
if(!(data_buffer = (uint8*)realloc(data_buffer, data_buffer_alloced)))
throw MDFN_Error(ErrnoHolder(errno));
}
示例3: LoadPRG
static void LoadPRG(Stream *fp)
{
uint32 t;
unsigned z;
z = uchead.ID[3] - '0'; // FIXME hex
if(z > 15)
throw MDFN_Error(0, "Invalid PRG ROM index '%c'.\n", uchead.ID[3]);
MDFN_printf(_("PRG ROM %u size: %u\n"), z, uchead.info);
if(malloced[z])
free(malloced[z]);
t = FixRomSize(uchead.info, 2048);
malloced[z] = (uint8 *)MDFN_malloc_T(t, _("PRG ROM"));
mallocedsizes[z] = t;
memset(malloced[z] + uchead.info, 0xFF, t - uchead.info);
fp->read(malloced[z], uchead.info);
SetupCartPRGMapping(z,malloced[z],t,0);
}
示例4: va_start
void Stream::print_format(const char *format, ...)
{
char *str = NULL;
int rc;
va_list ap;
va_start(ap, format);
rc = trio_vasprintf(&str, format, ap);
va_end(ap);
if(rc < 0)
throw MDFN_Error(0, "Error in trio_vasprintf()");
else
{
try // Bleck
{
write(str, rc);
}
catch(...)
{
free(str);
throw;
}
free(str);
}
}
示例5: throw
void CDIF_MT::RT_EjectDisc(bool eject_status, bool skip_actual_eject)
{
int32_t old_de = DiscEjected;
DiscEjected = eject_status;
if(old_de != DiscEjected)
{
if(!skip_actual_eject)
disc_cdaccess->Eject(eject_status);
if(!eject_status) // Re-read the TOC
{
disc_cdaccess->Read_TOC(&disc_toc);
if(disc_toc.first_track < 1 || disc_toc.last_track > 99 || disc_toc.first_track > disc_toc.last_track)
throw(MDFN_Error(0, _("TOC first(%d)/last(%d) track numbers bad."), disc_toc.first_track, disc_toc.last_track));
}
SBWritePos = 0;
ra_lba = 0;
ra_count = 0;
last_read_lba = ~0U;
memset(SectorBuffers, 0, SBSize * sizeof(CDIF_Sector_Buffer));
}
}
示例6: slock_lock
// Returns FALSE if message not read, TRUE if it was read. Will always return TRUE if "blocking" is set.
// Will throw MDFN_Error if the read message code is CDIF_MSG_FATAL_ERROR
bool CDIF_Queue::Read(CDIF_Message *message, bool blocking)
{
bool ret = true;
slock_lock((slock_t*)ze_mutex);
if(blocking)
{
while(ze_queue.size() == 0) // while, not just if.
scond_wait((scond_t*)ze_cond, (slock_t*)ze_mutex);
}
if(ze_queue.size() == 0)
ret = false;
else
{
*message = ze_queue.front();
ze_queue.pop();
}
slock_unlock((slock_t*)ze_mutex);
if(ret && message->message == CDIF_MSG_FATAL_ERROR)
throw MDFN_Error(0, "%s", message->str_message.c_str());
return(ret);
}
示例7: SendIntegrity
// Integrity checking is experimental, and needs work to function properly(in the emulator cores).
static int SendIntegrity(void)
{
StateMem sm;
md5_context md5;
uint8 digest[16];
memset(&sm, 0, sizeof(StateMem));
// Do not do a raw/data-only state for speed, due to lack of endian and bool conversion.
if(!MDFNSS_SaveSM(&sm, 0, false))
{
throw MDFN_Error(0, _("Error during save state generation."));
}
md5.starts();
md5.update(sm.data, sm.len);
md5.finish(digest);
free(sm.data);
//for(int i = 15; i >= 0; i--)
// printf("%02x", digest[i]);
//puts("");
SendCommand(MDFNNPCMD_INTEGRITY_RES, 16, digest);
return(1);
}
示例8: data_buffer
MemoryStream::MemoryStream(uint64 size_hint) : data_buffer(NULL), data_buffer_size(0), data_buffer_alloced(0), position(0)
{
data_buffer_size = 0;
data_buffer_alloced = (size_hint > SIZE_MAX) ? SIZE_MAX : size_hint;
if(!(data_buffer = (uint8*)realloc(data_buffer, (size_t)data_buffer_alloced)))
throw MDFN_Error(ErrnoHolder(errno));
}
示例9: OpenedMode
FileWrapper::FileWrapper(const char *path, const int mode, const char *purpose) : OpenedMode(mode)
{
path_save = std::string(path);
if(mode == MODE_READ)
fp = fopen(path, "rb");
else if(mode == MODE_WRITE)
fp = fopen(path, "wb");
else if(mode == MODE_WRITE_SAFE) // SO ANNOYING
{
int open_flags = O_WRONLY | O_CREAT | O_EXCL;
#ifdef O_BINARY
open_flags |= O_BINARY;
#elif defined(_O_BINARY)
open_flags |= _O_BINARY;
#endif
#if defined(S_IRGRP) && defined(S_IROTH)
int tmpfd = open(path, open_flags, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
#else
int tmpfd = open(path, open_flags, S_IRUSR | S_IWUSR);
#endif
if(tmpfd == -1)
{
ErrnoHolder ene(errno);
if(purpose)
throw(MDFN_Error(ene.Errno(), _("Error opening file \"%s\" for \"%s\": %s"), path_save.c_str(), purpose, ene.StrError()));
else
throw(MDFN_Error(ene.Errno(), _("Error opening file \"%s\": %s"), path_save.c_str(), ene.StrError()));
}
fp = fdopen(tmpfd, "wb");
}
if(!fp)
{
ErrnoHolder ene(errno);
if(purpose)
throw(MDFN_Error(ene.Errno(), _("Error opening file \"%s\" for \"%s\": %s"), path_save.c_str(), purpose, ene.StrError()));
else
throw(MDFN_Error(ene.Errno(), _("Error opening file \"%s\": %s"), path_save.c_str(), ene.StrError()));
}
}
示例10: ene
void FileWrapper::flush(void)
{
if(fflush(fp) == EOF)
{
ErrnoHolder ene(errno);
throw(MDFN_Error(ene.Errno(), _("Error flushing to opened file \"%s\": %s"), path_save.c_str(), ene.StrError()));
}
}
示例11: ene
void FileStream::truncate(uint64 length)
{
if(fflush(fp) == EOF)
{
ErrnoHolder ene(errno);
throw(MDFN_Error(ene.Errno(), _("Error truncating opened file \"%s\": %s"), path_save.c_str(), ene.StrError()));
}
}
示例12: OpenedMode
FileStream::FileStream(const std::string& path, const int mode) : OpenedMode(mode), mapping(NULL), mapping_size(0)
{
path_save = path;
if(mode == MODE_READ)
fp = fopen(path.c_str(), "rb");
else if(mode == MODE_WRITE)
fp = fopen(path.c_str(), "wb");
else if(mode == MODE_WRITE_SAFE || mode == MODE_WRITE_INPLACE) // SO ANNOYING
{
int open_flags = O_WRONLY | O_CREAT;
if(mode == MODE_WRITE_SAFE)
open_flags |= O_EXCL;
#ifdef O_BINARY
open_flags |= O_BINARY;
#elif defined(_O_BINARY)
open_flags |= _O_BINARY;
#endif
#if defined(S_IRGRP) && defined(S_IROTH)
int tmpfd = open(path.c_str(), open_flags, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
#else
int tmpfd = open(path.c_str(), open_flags, S_IRUSR | S_IWUSR);
#endif
if(tmpfd == -1)
{
ErrnoHolder ene(errno);
throw(MDFN_Error(ene.Errno(), _("Error opening file \"%s\": %s"), path_save.c_str(), ene.StrError()));
}
fp = fdopen(tmpfd, "wb");
}
else
abort();
if(!fp)
{
ErrnoHolder ene(errno);
throw(MDFN_Error(ene.Errno(), _("Error opening file \"%s\": %s"), path_save.c_str(), ene.StrError()));
}
}
示例13: MDFN_Error
MCGenjin::MCGenjin(Blip_Buffer *bb, const uint8 *rr, uint32 rr_size)
{
uint8 revision, num256_pages, region, cs_di[2];
if(rr_size < 8192)
throw MDFN_Error(0, _("MCGenjin ROM size is too small!"));
if(memcmp(rr + 0x1FD0, "MCGENJIN", 8))
throw MDFN_Error(0, _("MC Genjin header magic missing!"));
rom.resize(round_up_pow2(rr_size));
memcpy(&rom[0], rr, rr_size);
revision = rom[0x1FD8];
num256_pages = rom[0x1FD9];
region = rom[0x1FDA];
cs_di[0] = rom[0x1FDB];
cs_di[1] = rom[0x1FDC];
for(unsigned i = 0; i < 2; i++)
{
switch(cs_di[i])
{
default:
for(unsigned si = 0; si < i; si++) // FIXME: auto ptr to make this not necessary
delete cs[si];
throw MDFN_Error(0, _("Unsupported MCGENJIN device on CS%d: 0x%02x"), i, cs_di[i]);
break;
case 0x00:
MDFN_printf(_("CS%d: Unused\n"), i);
cs[i] = new MCGenjin_CS_Device();
break;
case 0x10 ... 0x18:
case 0x20 ... 0x28:
MDFN_printf(_("CS%d: %uKiB %sRAM\n"), i, 8 << (cs_di[i] & 0xF), (cs_di[i] & 0x20) ? "Nonvolatile " : "");
cs[i] = new MCGenjin_CS_Device_RAM(8192 << (cs_di[i] & 0xF), (bool)(cs_di[i] & 0x20));
break;
}
}
}
示例14: ene
void FileStream::truncate(uint64 length)
{
//not needed by mednadisc
//if(fflush(fp) == EOF || ftruncate(fileno(fp), length) != 0)
{
ErrnoHolder ene(errno);
throw(MDFN_Error(ene.Errno(), _("Error truncating opened file \"%s\": %s"), path_save.c_str(), ene.StrError()));
}
}
示例15: RecvState
static void RecvState(const uint32 clen)
{
StateMem sm;
std::vector<uint8> cbuf;
std::vector<uint8> buf;
memset(&sm, 0, sizeof(StateMem));
if(clen < 4)
{
throw MDFN_Error(0, _("Compressed save state data is too small: %u"), clen);
}
if(clen > 8 * 1024 * 1024) // Compressed length sanity check - 8 MiB max.
{
throw MDFN_Error(0, _("Compressed save state data is too large: %u"), clen);
}
cbuf.resize(clen);
MDFND_RecvData(&cbuf[0], clen);
uLongf len = MDFN_de32lsb(&cbuf[0]);
if(len > 12 * 1024 * 1024) // Uncompressed length sanity check - 12 MiB max.
{
throw MDFN_Error(0, _("Uncompressed save state data is too large: %llu"), (unsigned long long)len);
}
buf.resize(len);
uncompress((Bytef *)&buf[0], &len, (Bytef *)&cbuf[0] + 4, clen - 4);
sm.data = &buf[0];
sm.len = len;
if(!MDFNSS_LoadSM(&sm, 0, 0))
{
throw MDFN_Error(0, _("Error during save state loading."));
}
if(MDFNMOV_IsRecording())
MDFNMOV_RecordState();
}