diff --git a/desmume/src/NDSSystem.cpp b/desmume/src/NDSSystem.cpp index c9a2c5b60..63e68a262 100644 --- a/desmume/src/NDSSystem.cpp +++ b/desmume/src/NDSSystem.cpp @@ -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" diff --git a/desmume/src/cheatSystem.cpp b/desmume/src/cheatSystem.cpp index 4f5e88936..70690ece0 100644 --- a/desmume/src/cheatSystem.cpp +++ b/desmume/src/cheatSystem.cpp @@ -23,7 +23,6 @@ #include "mem.h" #include "MMU.h" #include "debug.h" -#include "utils/xstring.h" #ifndef _MSC_VER #include diff --git a/desmume/src/mc.cpp b/desmume/src/mc.cpp index 98c723f16..dbf97f297 100644 --- a/desmume/src/mc.cpp +++ b/desmume/src/mc.cpp @@ -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 diff --git a/desmume/src/path.cpp b/desmume/src/path.cpp index dd4690042..009302013 100644 --- a/desmume/src/path.cpp +++ b/desmume/src/path.cpp @@ -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 . */ -#include "types.h" - -#include "path.h" #include +#include +#include + +#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 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); +} \ No newline at end of file diff --git a/desmume/src/path.h b/desmume/src/path.h index 4832b0866..62302b816 100644 --- a/desmume/src/path.h +++ b/desmume/src/path.h @@ -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 +#include +#include #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 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 { diff --git a/desmume/src/saves.cpp b/desmume/src/saves.cpp index 6983c7cf9..0cd9cdf6f 100644 --- a/desmume/src/saves.cpp +++ b/desmume/src/saves.cpp @@ -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" diff --git a/desmume/src/windows/hotkey.cpp b/desmume/src/windows/hotkey.cpp index b201650aa..c2873f797 100644 --- a/desmume/src/windows/hotkey.cpp +++ b/desmume/src/windows/hotkey.cpp @@ -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