diff options
Diffstat (limited to 'src/common')
| -rw-r--r-- | src/common/common_paths.h | 44 | ||||
| -rw-r--r-- | src/common/emu_window.h | 10 | ||||
| -rw-r--r-- | src/common/file_util.cpp | 114 | ||||
| -rw-r--r-- | src/common/file_util.h | 25 | ||||
| -rw-r--r-- | src/common/log.h | 1 | ||||
| -rw-r--r-- | src/common/log_manager.cpp | 1 |
6 files changed, 126 insertions, 69 deletions
diff --git a/src/common/common_paths.h b/src/common/common_paths.h index 7cd5b1f35..ae08d082a 100644 --- a/src/common/common_paths.h +++ b/src/common/common_paths.h | |||
| @@ -7,25 +7,25 @@ | |||
| 7 | // Make sure we pick up USER_DIR if set in config.h | 7 | // Make sure we pick up USER_DIR if set in config.h |
| 8 | #include "common/common.h" | 8 | #include "common/common.h" |
| 9 | 9 | ||
| 10 | // Directory seperators, do we need this? | 10 | // Directory separators, do we need this? |
| 11 | #define DIR_SEP "/" | 11 | #define DIR_SEP "/" |
| 12 | #define DIR_SEP_CHR '/' | 12 | #define DIR_SEP_CHR '/' |
| 13 | 13 | ||
| 14 | #ifndef MAX_PATH | 14 | #ifndef MAX_PATH |
| 15 | #define MAX_PATH 260 | 15 | #define MAX_PATH 260 |
| 16 | #endif | 16 | #endif |
| 17 | 17 | ||
| 18 | // The user data dir | 18 | // The user data dir |
| 19 | #define ROOT_DIR "." | 19 | #define ROOT_DIR "." |
| 20 | #ifdef _WIN32 | 20 | #ifdef _WIN32 |
| 21 | #define USERDATA_DIR "user" | 21 | #define USERDATA_DIR "user" |
| 22 | #define EMU_DATA_DIR "emu" | 22 | #define EMU_DATA_DIR "Citra Emulator" |
| 23 | #else | 23 | #else |
| 24 | #define USERDATA_DIR "user" | 24 | #define USERDATA_DIR "user" |
| 25 | #ifdef USER_DIR | 25 | #ifdef USER_DIR |
| 26 | #define EMU_DATA_DIR USER_DIR | 26 | #define EMU_DATA_DIR USER_DIR |
| 27 | #else | 27 | #else |
| 28 | #define EMU_DATA_DIR ".emu" | 28 | #define EMU_DATA_DIR ".citra-emu" |
| 29 | #endif | 29 | #endif |
| 30 | #endif | 30 | #endif |
| 31 | 31 | ||
| @@ -48,30 +48,30 @@ | |||
| 48 | #define JAP_DIR "JAP" | 48 | #define JAP_DIR "JAP" |
| 49 | 49 | ||
| 50 | // Subdirs in the User dir returned by GetUserPath(D_USER_IDX) | 50 | // Subdirs in the User dir returned by GetUserPath(D_USER_IDX) |
| 51 | #define CONFIG_DIR "config" | 51 | #define CONFIG_DIR "config" |
| 52 | #define GAMECONFIG_DIR "game_config" | 52 | #define GAMECONFIG_DIR "game_config" |
| 53 | #define MAPS_DIR "maps" | 53 | #define MAPS_DIR "maps" |
| 54 | #define CACHE_DIR "cache" | 54 | #define CACHE_DIR "cache" |
| 55 | #define SDMC_DIR "sdmc" | 55 | #define SDMC_DIR "sdmc" |
| 56 | #define SHADERCACHE_DIR "shader_cache" | 56 | #define SHADERCACHE_DIR "shader_cache" |
| 57 | #define STATESAVES_DIR "state_saves" | 57 | #define STATESAVES_DIR "state_saves" |
| 58 | #define SCREENSHOTS_DIR "screenShots" | 58 | #define SCREENSHOTS_DIR "screenShots" |
| 59 | #define DUMP_DIR "dump" | 59 | #define DUMP_DIR "dump" |
| 60 | #define DUMP_TEXTURES_DIR "textures" | 60 | #define DUMP_TEXTURES_DIR "textures" |
| 61 | #define DUMP_FRAMES_DIR "frames" | 61 | #define DUMP_FRAMES_DIR "frames" |
| 62 | #define DUMP_AUDIO_DIR "audio" | 62 | #define DUMP_AUDIO_DIR "audio" |
| 63 | #define LOGS_DIR "logs" | 63 | #define LOGS_DIR "logs" |
| 64 | #define SHADERS_DIR "shaders" | 64 | #define SHADERS_DIR "shaders" |
| 65 | #define SYSCONF_DIR "sysconf" | 65 | #define SYSCONF_DIR "sysconf" |
| 66 | 66 | ||
| 67 | // Filenames | 67 | // Filenames |
| 68 | // Files in the directory returned by GetUserPath(D_CONFIG_IDX) | 68 | // Files in the directory returned by GetUserPath(D_CONFIG_IDX) |
| 69 | #define EMU_CONFIG "emu.ini" | 69 | #define EMU_CONFIG "emu.ini" |
| 70 | #define DEBUGGER_CONFIG "debugger.ini" | 70 | #define DEBUGGER_CONFIG "debugger.ini" |
| 71 | #define LOGGER_CONFIG "logger.ini" | 71 | #define LOGGER_CONFIG "logger.ini" |
| 72 | 72 | ||
| 73 | // Files in the directory returned by GetUserPath(D_LOGS_IDX) | 73 | // Files in the directory returned by GetUserPath(D_LOGS_IDX) |
| 74 | #define MAIN_LOG "emu.log" | 74 | #define MAIN_LOG "emu.log" |
| 75 | 75 | ||
| 76 | // Files in the directory returned by GetUserPath(D_SYSCONF_IDX) | 76 | // Files in the directory returned by GetUserPath(D_SYSCONF_IDX) |
| 77 | #define SYSCONF "SYSCONF" | 77 | #define SYSCONF "SYSCONF" |
diff --git a/src/common/emu_window.h b/src/common/emu_window.h index 23f178fdf..34cecb40b 100644 --- a/src/common/emu_window.h +++ b/src/common/emu_window.h | |||
| @@ -16,7 +16,7 @@ class EmuWindow | |||
| 16 | 16 | ||
| 17 | public: | 17 | public: |
| 18 | /// Data structure to store an emuwindow configuration | 18 | /// Data structure to store an emuwindow configuration |
| 19 | struct Config{ | 19 | struct WindowConfig { |
| 20 | bool fullscreen; | 20 | bool fullscreen; |
| 21 | int res_width; | 21 | int res_width; |
| 22 | int res_height; | 22 | int res_height; |
| @@ -34,17 +34,19 @@ public: | |||
| 34 | /// Releases (dunno if this is the "right" word) the GLFW context from the caller thread | 34 | /// Releases (dunno if this is the "right" word) the GLFW context from the caller thread |
| 35 | virtual void DoneCurrent() = 0; | 35 | virtual void DoneCurrent() = 0; |
| 36 | 36 | ||
| 37 | virtual void ReloadSetKeymaps() = 0; | ||
| 38 | |||
| 37 | /// Signals a key press action to the HID module | 39 | /// Signals a key press action to the HID module |
| 38 | static void KeyPressed(KeyMap::HostDeviceKey key); | 40 | static void KeyPressed(KeyMap::HostDeviceKey key); |
| 39 | 41 | ||
| 40 | /// Signals a key release action to the HID module | 42 | /// Signals a key release action to the HID module |
| 41 | static void KeyReleased(KeyMap::HostDeviceKey key); | 43 | static void KeyReleased(KeyMap::HostDeviceKey key); |
| 42 | 44 | ||
| 43 | Config GetConfig() const { | 45 | WindowConfig GetConfig() const { |
| 44 | return m_config; | 46 | return m_config; |
| 45 | } | 47 | } |
| 46 | 48 | ||
| 47 | void SetConfig(const Config& val) { | 49 | void SetConfig(const WindowConfig& val) { |
| 48 | m_config = val; | 50 | m_config = val; |
| 49 | } | 51 | } |
| 50 | 52 | ||
| @@ -86,6 +88,6 @@ protected: | |||
| 86 | int m_client_area_height; ///< Current client height, should be set by window impl. | 88 | int m_client_area_height; ///< Current client height, should be set by window impl. |
| 87 | 89 | ||
| 88 | private: | 90 | private: |
| 89 | Config m_config; ///< Internal configuration | 91 | WindowConfig m_config; ///< Internal configuration |
| 90 | 92 | ||
| 91 | }; | 93 | }; |
diff --git a/src/common/file_util.cpp b/src/common/file_util.cpp index 9292a1cd6..78a642599 100644 --- a/src/common/file_util.cpp +++ b/src/common/file_util.cpp | |||
| @@ -648,7 +648,7 @@ std::string GetSysDirectory() | |||
| 648 | return sysDir; | 648 | return sysDir; |
| 649 | } | 649 | } |
| 650 | 650 | ||
| 651 | // Returns a string with a Dolphin data dir or file in the user's home | 651 | // Returns a string with a Citra data dir or file in the user's home |
| 652 | // directory. To be used in "multi-user" mode (that is, installed). | 652 | // directory. To be used in "multi-user" mode (that is, installed). |
| 653 | const std::string& GetUserPath(const unsigned int DirIDX, const std::string &newPath) | 653 | const std::string& GetUserPath(const unsigned int DirIDX, const std::string &newPath) |
| 654 | { | 654 | { |
| @@ -668,22 +668,22 @@ const std::string& GetUserPath(const unsigned int DirIDX, const std::string &new | |||
| 668 | getenv("PWD") : "") + DIR_SEP EMU_DATA_DIR DIR_SEP; | 668 | getenv("PWD") : "") + DIR_SEP EMU_DATA_DIR DIR_SEP; |
| 669 | #endif | 669 | #endif |
| 670 | 670 | ||
| 671 | paths[D_CONFIG_IDX] = paths[D_USER_IDX] + CONFIG_DIR DIR_SEP; | 671 | paths[D_CONFIG_IDX] = paths[D_USER_IDX] + CONFIG_DIR DIR_SEP; |
| 672 | paths[D_GAMECONFIG_IDX] = paths[D_USER_IDX] + GAMECONFIG_DIR DIR_SEP; | 672 | paths[D_GAMECONFIG_IDX] = paths[D_USER_IDX] + GAMECONFIG_DIR DIR_SEP; |
| 673 | paths[D_MAPS_IDX] = paths[D_USER_IDX] + MAPS_DIR DIR_SEP; | 673 | paths[D_MAPS_IDX] = paths[D_USER_IDX] + MAPS_DIR DIR_SEP; |
| 674 | paths[D_CACHE_IDX] = paths[D_USER_IDX] + CACHE_DIR DIR_SEP; | 674 | paths[D_CACHE_IDX] = paths[D_USER_IDX] + CACHE_DIR DIR_SEP; |
| 675 | paths[D_SDMC_IDX] = paths[D_USER_IDX] + SDMC_DIR DIR_SEP; | 675 | paths[D_SDMC_IDX] = paths[D_USER_IDX] + SDMC_DIR DIR_SEP; |
| 676 | paths[D_SHADERCACHE_IDX] = paths[D_USER_IDX] + SHADERCACHE_DIR DIR_SEP; | 676 | paths[D_SHADERCACHE_IDX] = paths[D_USER_IDX] + SHADERCACHE_DIR DIR_SEP; |
| 677 | paths[D_SHADERS_IDX] = paths[D_USER_IDX] + SHADERS_DIR DIR_SEP; | 677 | paths[D_SHADERS_IDX] = paths[D_USER_IDX] + SHADERS_DIR DIR_SEP; |
| 678 | paths[D_STATESAVES_IDX] = paths[D_USER_IDX] + STATESAVES_DIR DIR_SEP; | 678 | paths[D_STATESAVES_IDX] = paths[D_USER_IDX] + STATESAVES_DIR DIR_SEP; |
| 679 | paths[D_SCREENSHOTS_IDX] = paths[D_USER_IDX] + SCREENSHOTS_DIR DIR_SEP; | 679 | paths[D_SCREENSHOTS_IDX] = paths[D_USER_IDX] + SCREENSHOTS_DIR DIR_SEP; |
| 680 | paths[D_DUMP_IDX] = paths[D_USER_IDX] + DUMP_DIR DIR_SEP; | 680 | paths[D_DUMP_IDX] = paths[D_USER_IDX] + DUMP_DIR DIR_SEP; |
| 681 | paths[D_DUMPFRAMES_IDX] = paths[D_DUMP_IDX] + DUMP_FRAMES_DIR DIR_SEP; | 681 | paths[D_DUMPFRAMES_IDX] = paths[D_DUMP_IDX] + DUMP_FRAMES_DIR DIR_SEP; |
| 682 | paths[D_DUMPAUDIO_IDX] = paths[D_DUMP_IDX] + DUMP_AUDIO_DIR DIR_SEP; | 682 | paths[D_DUMPAUDIO_IDX] = paths[D_DUMP_IDX] + DUMP_AUDIO_DIR DIR_SEP; |
| 683 | paths[D_DUMPTEXTURES_IDX] = paths[D_DUMP_IDX] + DUMP_TEXTURES_DIR DIR_SEP; | 683 | paths[D_DUMPTEXTURES_IDX] = paths[D_DUMP_IDX] + DUMP_TEXTURES_DIR DIR_SEP; |
| 684 | paths[D_LOGS_IDX] = paths[D_USER_IDX] + LOGS_DIR DIR_SEP; | 684 | paths[D_LOGS_IDX] = paths[D_USER_IDX] + LOGS_DIR DIR_SEP; |
| 685 | paths[F_DEBUGGERCONFIG_IDX] = paths[D_CONFIG_IDX] + DEBUGGER_CONFIG; | 685 | paths[F_DEBUGGERCONFIG_IDX] = paths[D_CONFIG_IDX] + DEBUGGER_CONFIG; |
| 686 | paths[F_LOGGERCONFIG_IDX] = paths[D_CONFIG_IDX] + LOGGER_CONFIG; | 686 | paths[F_LOGGERCONFIG_IDX] = paths[D_CONFIG_IDX] + LOGGER_CONFIG; |
| 687 | paths[F_MAINLOG_IDX] = paths[D_LOGS_IDX] + MAIN_LOG; | 687 | paths[F_MAINLOG_IDX] = paths[D_LOGS_IDX] + MAIN_LOG; |
| 688 | } | 688 | } |
| 689 | 689 | ||
| @@ -702,44 +702,44 @@ const std::string& GetUserPath(const unsigned int DirIDX, const std::string &new | |||
| 702 | switch (DirIDX) | 702 | switch (DirIDX) |
| 703 | { | 703 | { |
| 704 | case D_ROOT_IDX: | 704 | case D_ROOT_IDX: |
| 705 | paths[D_USER_IDX] = paths[D_ROOT_IDX] + DIR_SEP; | 705 | paths[D_USER_IDX] = paths[D_ROOT_IDX] + DIR_SEP; |
| 706 | paths[D_SYSCONF_IDX] = paths[D_USER_IDX] + SYSCONF_DIR + DIR_SEP; | 706 | paths[D_SYSCONF_IDX] = paths[D_USER_IDX] + SYSCONF_DIR + DIR_SEP; |
| 707 | paths[F_SYSCONF_IDX] = paths[D_SYSCONF_IDX] + SYSCONF; | 707 | paths[F_SYSCONF_IDX] = paths[D_SYSCONF_IDX] + SYSCONF; |
| 708 | break; | 708 | break; |
| 709 | 709 | ||
| 710 | case D_USER_IDX: | 710 | case D_USER_IDX: |
| 711 | paths[D_USER_IDX] = paths[D_ROOT_IDX] + DIR_SEP; | 711 | paths[D_USER_IDX] = paths[D_ROOT_IDX] + DIR_SEP; |
| 712 | paths[D_CONFIG_IDX] = paths[D_USER_IDX] + CONFIG_DIR DIR_SEP; | 712 | paths[D_CONFIG_IDX] = paths[D_USER_IDX] + CONFIG_DIR DIR_SEP; |
| 713 | paths[D_GAMECONFIG_IDX] = paths[D_USER_IDX] + GAMECONFIG_DIR DIR_SEP; | 713 | paths[D_GAMECONFIG_IDX] = paths[D_USER_IDX] + GAMECONFIG_DIR DIR_SEP; |
| 714 | paths[D_MAPS_IDX] = paths[D_USER_IDX] + MAPS_DIR DIR_SEP; | 714 | paths[D_MAPS_IDX] = paths[D_USER_IDX] + MAPS_DIR DIR_SEP; |
| 715 | paths[D_CACHE_IDX] = paths[D_USER_IDX] + CACHE_DIR DIR_SEP; | 715 | paths[D_CACHE_IDX] = paths[D_USER_IDX] + CACHE_DIR DIR_SEP; |
| 716 | paths[D_SDMC_IDX] = paths[D_USER_IDX] + SDMC_DIR DIR_SEP; | 716 | paths[D_SDMC_IDX] = paths[D_USER_IDX] + SDMC_DIR DIR_SEP; |
| 717 | paths[D_SHADERCACHE_IDX] = paths[D_USER_IDX] + SHADERCACHE_DIR DIR_SEP; | 717 | paths[D_SHADERCACHE_IDX] = paths[D_USER_IDX] + SHADERCACHE_DIR DIR_SEP; |
| 718 | paths[D_SHADERS_IDX] = paths[D_USER_IDX] + SHADERS_DIR DIR_SEP; | 718 | paths[D_SHADERS_IDX] = paths[D_USER_IDX] + SHADERS_DIR DIR_SEP; |
| 719 | paths[D_STATESAVES_IDX] = paths[D_USER_IDX] + STATESAVES_DIR DIR_SEP; | 719 | paths[D_STATESAVES_IDX] = paths[D_USER_IDX] + STATESAVES_DIR DIR_SEP; |
| 720 | paths[D_SCREENSHOTS_IDX] = paths[D_USER_IDX] + SCREENSHOTS_DIR DIR_SEP; | 720 | paths[D_SCREENSHOTS_IDX] = paths[D_USER_IDX] + SCREENSHOTS_DIR DIR_SEP; |
| 721 | paths[D_DUMP_IDX] = paths[D_USER_IDX] + DUMP_DIR DIR_SEP; | 721 | paths[D_DUMP_IDX] = paths[D_USER_IDX] + DUMP_DIR DIR_SEP; |
| 722 | paths[D_DUMPFRAMES_IDX] = paths[D_DUMP_IDX] + DUMP_FRAMES_DIR DIR_SEP; | 722 | paths[D_DUMPFRAMES_IDX] = paths[D_DUMP_IDX] + DUMP_FRAMES_DIR DIR_SEP; |
| 723 | paths[D_DUMPAUDIO_IDX] = paths[D_DUMP_IDX] + DUMP_AUDIO_DIR DIR_SEP; | 723 | paths[D_DUMPAUDIO_IDX] = paths[D_DUMP_IDX] + DUMP_AUDIO_DIR DIR_SEP; |
| 724 | paths[D_DUMPTEXTURES_IDX] = paths[D_DUMP_IDX] + DUMP_TEXTURES_DIR DIR_SEP; | 724 | paths[D_DUMPTEXTURES_IDX] = paths[D_DUMP_IDX] + DUMP_TEXTURES_DIR DIR_SEP; |
| 725 | paths[D_LOGS_IDX] = paths[D_USER_IDX] + LOGS_DIR DIR_SEP; | 725 | paths[D_LOGS_IDX] = paths[D_USER_IDX] + LOGS_DIR DIR_SEP; |
| 726 | paths[D_SYSCONF_IDX] = paths[D_USER_IDX] + SYSCONF_DIR DIR_SEP; | 726 | paths[D_SYSCONF_IDX] = paths[D_USER_IDX] + SYSCONF_DIR DIR_SEP; |
| 727 | paths[F_EMUCONFIG_IDX] = paths[D_CONFIG_IDX] + EMU_CONFIG; | 727 | paths[F_EMUCONFIG_IDX] = paths[D_CONFIG_IDX] + EMU_CONFIG; |
| 728 | paths[F_DEBUGGERCONFIG_IDX] = paths[D_CONFIG_IDX] + DEBUGGER_CONFIG; | 728 | paths[F_DEBUGGERCONFIG_IDX] = paths[D_CONFIG_IDX] + DEBUGGER_CONFIG; |
| 729 | paths[F_LOGGERCONFIG_IDX] = paths[D_CONFIG_IDX] + LOGGER_CONFIG; | 729 | paths[F_LOGGERCONFIG_IDX] = paths[D_CONFIG_IDX] + LOGGER_CONFIG; |
| 730 | paths[F_MAINLOG_IDX] = paths[D_LOGS_IDX] + MAIN_LOG; | 730 | paths[F_MAINLOG_IDX] = paths[D_LOGS_IDX] + MAIN_LOG; |
| 731 | break; | 731 | break; |
| 732 | 732 | ||
| 733 | case D_CONFIG_IDX: | 733 | case D_CONFIG_IDX: |
| 734 | paths[F_EMUCONFIG_IDX] = paths[D_CONFIG_IDX] + EMU_CONFIG; | 734 | paths[F_EMUCONFIG_IDX] = paths[D_CONFIG_IDX] + EMU_CONFIG; |
| 735 | paths[F_DEBUGGERCONFIG_IDX] = paths[D_CONFIG_IDX] + DEBUGGER_CONFIG; | 735 | paths[F_DEBUGGERCONFIG_IDX] = paths[D_CONFIG_IDX] + DEBUGGER_CONFIG; |
| 736 | paths[F_LOGGERCONFIG_IDX] = paths[D_CONFIG_IDX] + LOGGER_CONFIG; | 736 | paths[F_LOGGERCONFIG_IDX] = paths[D_CONFIG_IDX] + LOGGER_CONFIG; |
| 737 | break; | 737 | break; |
| 738 | 738 | ||
| 739 | case D_DUMP_IDX: | 739 | case D_DUMP_IDX: |
| 740 | paths[D_DUMPFRAMES_IDX] = paths[D_DUMP_IDX] + DUMP_FRAMES_DIR DIR_SEP; | 740 | paths[D_DUMPFRAMES_IDX] = paths[D_DUMP_IDX] + DUMP_FRAMES_DIR DIR_SEP; |
| 741 | paths[D_DUMPAUDIO_IDX] = paths[D_DUMP_IDX] + DUMP_AUDIO_DIR DIR_SEP; | 741 | paths[D_DUMPAUDIO_IDX] = paths[D_DUMP_IDX] + DUMP_AUDIO_DIR DIR_SEP; |
| 742 | paths[D_DUMPTEXTURES_IDX] = paths[D_DUMP_IDX] + DUMP_TEXTURES_DIR DIR_SEP; | 742 | paths[D_DUMPTEXTURES_IDX] = paths[D_DUMP_IDX] + DUMP_TEXTURES_DIR DIR_SEP; |
| 743 | break; | 743 | break; |
| 744 | 744 | ||
| 745 | case D_LOGS_IDX: | 745 | case D_LOGS_IDX: |
| @@ -780,6 +780,48 @@ size_t ReadFileToString(bool text_file, const char *filename, std::string &str) | |||
| 780 | return file.ReadArray(&str[0], str.size()); | 780 | return file.ReadArray(&str[0], str.size()); |
| 781 | } | 781 | } |
| 782 | 782 | ||
| 783 | /** | ||
| 784 | * Splits the filename into 8.3 format | ||
| 785 | * Loosely implemented following https://en.wikipedia.org/wiki/8.3_filename | ||
| 786 | * @param filename The normal filename to use | ||
| 787 | * @param short_name A 9-char array in which the short name will be written | ||
| 788 | * @param extension A 4-char array in which the extension will be written | ||
| 789 | */ | ||
| 790 | void SplitFilename83(const std::string& filename, std::array<char, 9>& short_name, | ||
| 791 | std::array<char, 4>& extension) { | ||
| 792 | const std::string forbidden_characters = ".\"/\\[]:;=, "; | ||
| 793 | |||
| 794 | // On a FAT32 partition, 8.3 names are stored as a 11 bytes array, filled with spaces. | ||
| 795 | short_name = {' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '\0'}; | ||
| 796 | extension = {' ', ' ', ' ', '\0'}; | ||
| 797 | |||
| 798 | std::string::size_type point = filename.rfind('.'); | ||
| 799 | if (point == filename.size() - 1) | ||
| 800 | point = filename.rfind('.', point); | ||
| 801 | |||
| 802 | // Get short name. | ||
| 803 | int j = 0; | ||
| 804 | for (char letter : filename.substr(0, point)) { | ||
| 805 | if (forbidden_characters.find(letter, 0) != std::string::npos) | ||
| 806 | continue; | ||
| 807 | if (j == 8) { | ||
| 808 | // TODO(Link Mauve): also do that for filenames containing a space. | ||
| 809 | // TODO(Link Mauve): handle multiple files having the same short name. | ||
| 810 | short_name[6] = '~'; | ||
| 811 | short_name[7] = '1'; | ||
| 812 | break; | ||
| 813 | } | ||
| 814 | short_name[j++] = toupper(letter); | ||
| 815 | } | ||
| 816 | |||
| 817 | // Get extension. | ||
| 818 | if (point != std::string::npos) { | ||
| 819 | j = 0; | ||
| 820 | for (char letter : filename.substr(point + 1, 3)) | ||
| 821 | extension[j++] = toupper(letter); | ||
| 822 | } | ||
| 823 | } | ||
| 824 | |||
| 783 | IOFile::IOFile() | 825 | IOFile::IOFile() |
| 784 | : m_file(NULL), m_good(true) | 826 | : m_file(NULL), m_good(true) |
| 785 | {} | 827 | {} |
diff --git a/src/common/file_util.h b/src/common/file_util.h index f9d91972f..173ce6623 100644 --- a/src/common/file_util.h +++ b/src/common/file_util.h | |||
| @@ -4,6 +4,7 @@ | |||
| 4 | 4 | ||
| 5 | #pragma once | 5 | #pragma once |
| 6 | 6 | ||
| 7 | #include <array> | ||
| 7 | #include <fstream> | 8 | #include <fstream> |
| 8 | #include <cstdio> | 9 | #include <cstdio> |
| 9 | #include <cstring> | 10 | #include <cstring> |
| @@ -47,7 +48,7 @@ enum { | |||
| 47 | namespace FileUtil | 48 | namespace FileUtil |
| 48 | { | 49 | { |
| 49 | 50 | ||
| 50 | // FileSystem tree node/ | 51 | // FileSystem tree node/ |
| 51 | struct FSTEntry | 52 | struct FSTEntry |
| 52 | { | 53 | { |
| 53 | bool isDirectory; | 54 | bool isDirectory; |
| @@ -85,13 +86,13 @@ bool Delete(const std::string &filename); | |||
| 85 | // Deletes a directory filename, returns true on success | 86 | // Deletes a directory filename, returns true on success |
| 86 | bool DeleteDir(const std::string &filename); | 87 | bool DeleteDir(const std::string &filename); |
| 87 | 88 | ||
| 88 | // renames file srcFilename to destFilename, returns true on success | 89 | // renames file srcFilename to destFilename, returns true on success |
| 89 | bool Rename(const std::string &srcFilename, const std::string &destFilename); | 90 | bool Rename(const std::string &srcFilename, const std::string &destFilename); |
| 90 | 91 | ||
| 91 | // copies file srcFilename to destFilename, returns true on success | 92 | // copies file srcFilename to destFilename, returns true on success |
| 92 | bool Copy(const std::string &srcFilename, const std::string &destFilename); | 93 | bool Copy(const std::string &srcFilename, const std::string &destFilename); |
| 93 | 94 | ||
| 94 | // creates an empty file filename, returns true on success | 95 | // creates an empty file filename, returns true on success |
| 95 | bool CreateEmptyFile(const std::string &filename); | 96 | bool CreateEmptyFile(const std::string &filename); |
| 96 | 97 | ||
| 97 | // Scans the directory tree gets, starting from _Directory and adds the | 98 | // Scans the directory tree gets, starting from _Directory and adds the |
| @@ -110,7 +111,7 @@ void CopyDir(const std::string &source_path, const std::string &dest_path); | |||
| 110 | // Set the current directory to given directory | 111 | // Set the current directory to given directory |
| 111 | bool SetCurrentDir(const std::string &directory); | 112 | bool SetCurrentDir(const std::string &directory); |
| 112 | 113 | ||
| 113 | // Returns a pointer to a string with a Dolphin data dir in the user's home | 114 | // Returns a pointer to a string with a Citra data dir in the user's home |
| 114 | // directory. To be used in "multi-user" mode (that is, installed). | 115 | // directory. To be used in "multi-user" mode (that is, installed). |
| 115 | const std::string& GetUserPath(const unsigned int DirIDX, const std::string &newPath=""); | 116 | const std::string& GetUserPath(const unsigned int DirIDX, const std::string &newPath=""); |
| 116 | 117 | ||
| @@ -131,6 +132,16 @@ std::string &GetExeDirectory(); | |||
| 131 | size_t WriteStringToFile(bool text_file, const std::string &str, const char *filename); | 132 | size_t WriteStringToFile(bool text_file, const std::string &str, const char *filename); |
| 132 | size_t ReadFileToString(bool text_file, const char *filename, std::string &str); | 133 | size_t ReadFileToString(bool text_file, const char *filename, std::string &str); |
| 133 | 134 | ||
| 135 | /** | ||
| 136 | * Splits the filename into 8.3 format | ||
| 137 | * Loosely implemented following https://en.wikipedia.org/wiki/8.3_filename | ||
| 138 | * @param filename The normal filename to use | ||
| 139 | * @param short_name A 9-char array in which the short name will be written | ||
| 140 | * @param extension A 4-char array in which the extension will be written | ||
| 141 | */ | ||
| 142 | void SplitFilename83(const std::string& filename, std::array<char, 9>& short_name, | ||
| 143 | std::array<char, 4>& extension); | ||
| 144 | |||
| 134 | // simple wrapper for cstdlib file functions to | 145 | // simple wrapper for cstdlib file functions to |
| 135 | // hopefully will make error checking easier | 146 | // hopefully will make error checking easier |
| 136 | // and make forgetting an fclose() harder | 147 | // and make forgetting an fclose() harder |
| @@ -142,10 +153,10 @@ public: | |||
| 142 | IOFile(const std::string& filename, const char openmode[]); | 153 | IOFile(const std::string& filename, const char openmode[]); |
| 143 | 154 | ||
| 144 | ~IOFile(); | 155 | ~IOFile(); |
| 145 | 156 | ||
| 146 | IOFile(IOFile&& other); | 157 | IOFile(IOFile&& other); |
| 147 | IOFile& operator=(IOFile&& other); | 158 | IOFile& operator=(IOFile&& other); |
| 148 | 159 | ||
| 149 | void Swap(IOFile& other); | 160 | void Swap(IOFile& other); |
| 150 | 161 | ||
| 151 | bool Open(const std::string& filename, const char openmode[]); | 162 | bool Open(const std::string& filename, const char openmode[]); |
diff --git a/src/common/log.h b/src/common/log.h index 291534c67..bfd73f8a5 100644 --- a/src/common/log.h +++ b/src/common/log.h | |||
| @@ -28,6 +28,7 @@ enum LOG_TYPE { | |||
| 28 | COMMANDPROCESSOR, | 28 | COMMANDPROCESSOR, |
| 29 | COMMON, | 29 | COMMON, |
| 30 | CONSOLE, | 30 | CONSOLE, |
| 31 | CONFIG, | ||
| 31 | DISCIO, | 32 | DISCIO, |
| 32 | FILEMON, | 33 | FILEMON, |
| 33 | DSPHLE, | 34 | DSPHLE, |
diff --git a/src/common/log_manager.cpp b/src/common/log_manager.cpp index 28b72fa20..4d590d98f 100644 --- a/src/common/log_manager.cpp +++ b/src/common/log_manager.cpp | |||
| @@ -30,6 +30,7 @@ LogManager::LogManager() | |||
| 30 | m_Log[LogTypes::MASTER_LOG] = new LogContainer("*", "Master Log"); | 30 | m_Log[LogTypes::MASTER_LOG] = new LogContainer("*", "Master Log"); |
| 31 | m_Log[LogTypes::BOOT] = new LogContainer("BOOT", "Boot"); | 31 | m_Log[LogTypes::BOOT] = new LogContainer("BOOT", "Boot"); |
| 32 | m_Log[LogTypes::COMMON] = new LogContainer("COMMON", "Common"); | 32 | m_Log[LogTypes::COMMON] = new LogContainer("COMMON", "Common"); |
| 33 | m_Log[LogTypes::CONFIG] = new LogContainer("CONFIG", "Configuration"); | ||
| 33 | m_Log[LogTypes::DISCIO] = new LogContainer("DIO", "Disc IO"); | 34 | m_Log[LogTypes::DISCIO] = new LogContainer("DIO", "Disc IO"); |
| 34 | m_Log[LogTypes::FILEMON] = new LogContainer("FileMon", "File Monitor"); | 35 | m_Log[LogTypes::FILEMON] = new LogContainer("FileMon", "File Monitor"); |
| 35 | m_Log[LogTypes::PAD] = new LogContainer("PAD", "Pad"); | 36 | m_Log[LogTypes::PAD] = new LogContainer("PAD", "Pad"); |