remove some dependencies from xstring.h

This commit is contained in:
zeromus 2016-08-16 05:20:21 -05:00
parent 45d07d41de
commit 63feee1190
7 changed files with 103 additions and 92 deletions

View File

@ -55,6 +55,7 @@
#include "path.h"
#include "slot1.h"
#include "slot2.h"
#include "emufile.h"
#include "SPU.h"
#include "wifi.h"
#include "Database.h"

View File

@ -23,7 +23,6 @@
#include "mem.h"
#include "MMU.h"
#include "debug.h"
#include "utils/xstring.h"
#ifndef _MSC_VER
#include <stdint.h>

View File

@ -1,7 +1,7 @@
/*
Copyright (C) 2006 thoduv
Copyright (C) 2006-2007 Theo Berkau
Copyright (C) 2008-2015 DeSmuME team
Copyright (C) 2008-2016 DeSmuME team
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@ -31,6 +31,7 @@
#include "NDSSystem.h"
#include "path.h"
#include "utils/advanscene.h"
#include "emufile.h"
//#define _DONT_SAVE_BACKUP
//#define _MCLOG

View File

@ -1,5 +1,5 @@
/*
Copyright (C) 2009-2011 DeSmuME team
Copyright (C) 2009-2016 DeSmuME team
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@ -15,10 +15,13 @@
along with the this software. If not, see <http://www.gnu.org/licenses/>.
*/
#include "types.h"
#include "path.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "types.h"
#include "path.h"
#include "utils/xstring.h"
//-----------------------------------
@ -181,3 +184,76 @@ void FCEUD_MakePathDirs(const char *fname)
}
#endif
//------------------------------
void PathInfo::init(const char *filename)
{
path = std::string(filename);
//extract the internal part of the logical rom name
std::vector<std::string> parts = tokenize_str(filename,"|");
SetRomName(parts[parts.size()-1].c_str());
LoadModulePath();
#if !defined(WIN32) && !defined(DESMUME_COCOA)
ReadPathSettings();
#endif
}
void PathInfo::formatname(char *output)
{
// Except 't' for tick and 'r' for random.
const char* strftimeArgs = "AbBcCdDeFgGhHIjmMnpRStTuUVwWxXyYzZ%";
std::string file;
time_t now = time(NULL);
tm *time_struct = localtime(&now);
srand((unsigned)now);
for (char* p = screenshotFormat,
*end = p + sizeof(screenshotFormat); p < end; p++)
{
if (*p != '%')
{
file.append(1, *p);
}
else
{
p++;
if (*p == 'f')
{
file.append(GetRomNameWithoutExtension());
}
else if (*p == 'r')
{
file.append(stditoa(rand()));
}
else if (*p == 't')
{
file.append(stditoa(clock() >> 5));
}
else if (strchr(strftimeArgs, *p))
{
char tmp[MAX_PATH];
char format[] = { '%', *p, '\0' };
strftime(tmp, MAX_PATH, format, time_struct);
file.append(tmp);
}
}
}
#ifdef WIN32
// Replace invalid file name character.
{
const char* invalids = "\\/:*?\"<>|";
size_t pos = 0;
while ((pos = file.find_first_of(invalids, pos)) != std::string::npos)
{
file[pos] = '-';
}
}
#endif
strncpy(output, file.c_str(), MAX_PATH);
}

View File

@ -1,5 +1,5 @@
/*
Copyright (C) 2009-2015 DeSmuME team
Copyright (C) 2009-2016 DeSmuME team
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@ -16,6 +16,8 @@
*/
#include <string>
#include <vector>
#include <string.h>
#include "types.h"
#if defined(HOST_WINDOWS)
@ -30,7 +32,6 @@
#endif /* HOST_WINDOWS */
#include "time.h"
#include "utils/xstring.h"
#ifdef HOST_WINDOWS
#define FILE_EXT_DELIMITER_CHAR '.'
@ -115,19 +116,7 @@ public:
char pathToLua[MAX_PATH];
char pathToSlot1D[MAX_PATH];
void init(const char *filename)
{
path = std::string(filename);
//extract the internal part of the logical rom name
std::vector<std::string> parts = tokenize_str(filename,"|");
SetRomName(parts[parts.size()-1].c_str());
LoadModulePath();
#if !defined(WIN32) && !defined(DESMUME_COCOA)
ReadPathSettings();
#endif
}
void init(const char *filename);
void LoadModulePath()
{
@ -333,64 +322,7 @@ public:
return romNameWithPath;
}
void formatname(char *output)
{
// Except 't' for tick and 'r' for random.
const char* strftimeArgs = "AbBcCdDeFgGhHIjmMnpRStTuUVwWxXyYzZ%";
std::string file;
time_t now = time(NULL);
tm *time_struct = localtime(&now);
srand((unsigned)now);
for (char* p = screenshotFormat,
*end = p + sizeof(screenshotFormat); p < end; p++)
{
if (*p != '%')
{
file.append(1, *p);
}
else
{
p++;
if (*p == 'f')
{
file.append(GetRomNameWithoutExtension());
}
else if (*p == 'r')
{
file.append(stditoa(rand()));
}
else if (*p == 't')
{
file.append(stditoa(clock() >> 5));
}
else if (strchr(strftimeArgs, *p))
{
char tmp[MAX_PATH];
char format[] = { '%', *p, '\0' };
strftime(tmp, MAX_PATH, format, time_struct);
file.append(tmp);
}
}
}
#ifdef WIN32
// Replace invalid file name character.
{
const char* invalids = "\\/:*?\"<>|";
size_t pos = 0;
while ((pos = file.find_first_of(invalids, pos)) != std::string::npos)
{
file[pos] = '-';
}
}
#endif
strncpy(output, file.c_str(), MAX_PATH);
}
void formatname(char *output);
enum R4Format
{

View File

@ -2,7 +2,7 @@
Copyright (C) 2006 Normmatt
Copyright (C) 2006 Theo Berkau
Copyright (C) 2007 Pascal Giard
Copyright (C) 2008-2015 DeSmuME team
Copyright (C) 2008-2016 DeSmuME team
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@ -36,6 +36,7 @@
#include "driver.h"
#include "saves.h"
#include "MMU.h"
#include "emufile.h"
#include "NDSSystem.h"
#include "render3D.h"
#include "cp15.h"

View File

@ -3,7 +3,7 @@
licensed under the terms supplied at the end of this file (for the terms are very long!)
Differences from that baseline version are:
Copyright (C) 2009-2015 DeSmuME team
Copyright (C) 2009-2016 DeSmuME team
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@ -21,17 +21,17 @@
#include "hotkey.h"
#include "../NDSSystem.h"
#include "../saves.h"
#include "../render3D.h"
#include "../arm_jit.h"
#include "../mic.h"
#include "../movie.h"
#include "../SPU.h"
#include "../GPU.h"
#include "../GPU_osd.h"
#include "../path.h"
#include "../frontend/modules/ImageOut.h"
#include "NDSSystem.h"
#include "saves.h"
#include "render3D.h"
#include "arm_jit.h"
#include "mic.h"
#include "movie.h"
#include "SPU.h"
#include "GPU.h"
#include "GPU_osd.h"
#include "path.h"
#include "frontend/modules/ImageOut.h"
#include "main.h"
#include "CheatsWin.h"
@ -45,6 +45,7 @@
#include "video.h"
#include "winutil.h"
#include "windriver.h"
#include "utils/xstring.h"
extern LRESULT OpenFile(); //adelikat: Made this an extern here instead of main.h Seemed icky not to limit the scope of this function