diff --git a/Source/Core/AudioCommon/WaveFile.cpp b/Source/Core/AudioCommon/WaveFile.cpp index 2707e33d81..42ca8cd3b3 100644 --- a/Source/Core/AudioCommon/WaveFile.cpp +++ b/Source/Core/AudioCommon/WaveFile.cpp @@ -7,6 +7,8 @@ #include #include "Common/CommonTypes.h" +#include "Common/File.h" +#include "Common/FileUtil.h" #include "Common/MsgHandler.h" #include "Common/StringUtil.h" #include "Common/Swap.h" diff --git a/Source/Core/AudioCommon/WaveFile.h b/Source/Core/AudioCommon/WaveFile.h index 58028e84b4..7254ef82c5 100644 --- a/Source/Core/AudioCommon/WaveFile.h +++ b/Source/Core/AudioCommon/WaveFile.h @@ -16,8 +16,9 @@ #include #include + #include "Common/CommonTypes.h" -#include "Common/FileUtil.h" +#include "Common/File.h" #include "Common/NonCopyable.h" class WaveFileWriter : NonCopyable diff --git a/Source/Core/Common/CMakeLists.txt b/Source/Core/Common/CMakeLists.txt index 921074cb9f..b8c52b3db3 100644 --- a/Source/Core/Common/CMakeLists.txt +++ b/Source/Core/Common/CMakeLists.txt @@ -7,6 +7,7 @@ set(SRCS Config/Layer.cpp Config/Section.cpp ENetUtil.cpp + File.cpp FileSearch.cpp FileUtil.cpp GekkoDisassembler.cpp diff --git a/Source/Core/Common/ChunkFile.h b/Source/Core/Common/ChunkFile.h index 0fe2a81667..72832c5e97 100644 --- a/Source/Core/Common/ChunkFile.h +++ b/Source/Core/Common/ChunkFile.h @@ -27,6 +27,7 @@ #include "Common/Assert.h" #include "Common/Common.h" #include "Common/CommonTypes.h" +#include "Common/File.h" #include "Common/FileUtil.h" #include "Common/Flag.h" #include "Common/Logging/Log.h" diff --git a/Source/Core/Common/Common.vcxproj b/Source/Core/Common/Common.vcxproj index 5bb8ccf8cf..ed8a24bbc1 100644 --- a/Source/Core/Common/Common.vcxproj +++ b/Source/Core/Common/Common.vcxproj @@ -63,6 +63,7 @@ + @@ -166,6 +167,7 @@ + diff --git a/Source/Core/Common/Common.vcxproj.filters b/Source/Core/Common/Common.vcxproj.filters index dd404fe35d..7729f21960 100644 --- a/Source/Core/Common/Common.vcxproj.filters +++ b/Source/Core/Common/Common.vcxproj.filters @@ -252,6 +252,7 @@ GL\GLExtensions + @@ -319,6 +320,7 @@ + diff --git a/Source/Core/Common/File.cpp b/Source/Core/Common/File.cpp new file mode 100644 index 0000000000..361943b93e --- /dev/null +++ b/Source/Core/Common/File.cpp @@ -0,0 +1,133 @@ +// Copyright 2008 Dolphin Emulator Project +// Licensed under GPLv2+ +// Refer to the license.txt file included. + +#include +#include +#include + +#ifdef _WIN32 +#include + +#include "Common/CommonFuncs.h" +#include "Common/StringUtil.h" +#else +#include +#endif + +#include "Common/CommonTypes.h" +#include "Common/File.h" +#include "Common/FileUtil.h" + +namespace File +{ +IOFile::IOFile() : m_file(nullptr), m_good(true) +{ +} + +IOFile::IOFile(std::FILE* file) : m_file(file), m_good(true) +{ +} + +IOFile::IOFile(const std::string& filename, const char openmode[]) : m_file(nullptr), m_good(true) +{ + Open(filename, openmode); +} + +IOFile::~IOFile() +{ + Close(); +} + +IOFile::IOFile(IOFile&& other) noexcept : m_file(nullptr), m_good(true) +{ + Swap(other); +} + +IOFile& IOFile::operator=(IOFile&& other) noexcept +{ + Swap(other); + return *this; +} + +void IOFile::Swap(IOFile& other) noexcept +{ + std::swap(m_file, other.m_file); + std::swap(m_good, other.m_good); +} + +bool IOFile::Open(const std::string& filename, const char openmode[]) +{ + Close(); +#ifdef _WIN32 + _tfopen_s(&m_file, UTF8ToTStr(filename).c_str(), UTF8ToTStr(openmode).c_str()); +#else + m_file = fopen(filename.c_str(), openmode); +#endif + + m_good = IsOpen(); + return m_good; +} + +bool IOFile::Close() +{ + if (!IsOpen() || 0 != std::fclose(m_file)) + m_good = false; + + m_file = nullptr; + return m_good; +} + +void IOFile::SetHandle(std::FILE* file) +{ + Close(); + Clear(); + m_file = file; +} + +u64 IOFile::GetSize() +{ + if (IsOpen()) + return File::GetSize(m_file); + else + return 0; +} + +bool IOFile::Seek(s64 off, int origin) +{ + if (!IsOpen() || 0 != fseeko(m_file, off, origin)) + m_good = false; + + return m_good; +} + +u64 IOFile::Tell() const +{ + if (IsOpen()) + return ftello(m_file); + else + return UINT64_MAX; +} + +bool IOFile::Flush() +{ + if (!IsOpen() || 0 != std::fflush(m_file)) + m_good = false; + + return m_good; +} + +bool IOFile::Resize(u64 size) +{ +#ifdef _WIN32 + if (!IsOpen() || 0 != _chsize_s(_fileno(m_file), size)) +#else + // TODO: handle 64bit and growing + if (!IsOpen() || 0 != ftruncate(fileno(m_file), size)) +#endif + m_good = false; + + return m_good; +} + +} // namespace File diff --git a/Source/Core/Common/File.h b/Source/Core/Common/File.h new file mode 100644 index 0000000000..2b13da6bd6 --- /dev/null +++ b/Source/Core/Common/File.h @@ -0,0 +1,93 @@ +// Copyright 2008 Dolphin Emulator Project +// Licensed under GPLv2+ +// Refer to the license.txt file included. + +#pragma once + +#include +#include +#include + +#include "Common/CommonTypes.h" +#include "Common/NonCopyable.h" + +namespace File +{ +// simple wrapper for cstdlib file functions to +// hopefully will make error checking easier +// and make forgetting an fclose() harder +class IOFile : public NonCopyable +{ +public: + IOFile(); + IOFile(std::FILE* file); + IOFile(const std::string& filename, const char openmode[]); + + ~IOFile(); + + IOFile(IOFile&& other) noexcept; + IOFile& operator=(IOFile&& other) noexcept; + + void Swap(IOFile& other) noexcept; + + bool Open(const std::string& filename, const char openmode[]); + bool Close(); + + template + bool ReadArray(T* data, size_t length, size_t* pReadBytes = nullptr) + { + size_t read_bytes = 0; + if (!IsOpen() || length != (read_bytes = std::fread(data, sizeof(T), length, m_file))) + m_good = false; + + if (pReadBytes) + *pReadBytes = read_bytes; + + return m_good; + } + + template + bool WriteArray(const T* data, size_t length) + { + if (!IsOpen() || length != std::fwrite(data, sizeof(T), length, m_file)) + m_good = false; + + return m_good; + } + + bool ReadBytes(void* data, size_t length) + { + return ReadArray(reinterpret_cast(data), length); + } + + bool WriteBytes(const void* data, size_t length) + { + return WriteArray(reinterpret_cast(data), length); + } + + bool IsOpen() const { return nullptr != m_file; } + // m_good is set to false when a read, write or other function fails + bool IsGood() const { return m_good; } + explicit operator bool() const { return IsGood() && IsOpen(); } + std::FILE* GetHandle() { return m_file; } + void SetHandle(std::FILE* file); + + bool Seek(s64 off, int origin); + u64 Tell() const; + u64 GetSize(); + bool Resize(u64 size); + bool Flush(); + + // clear error state + void Clear() + { + m_good = true; + std::clearerr(m_file); + } + +private: + std::FILE* m_file; + bool m_good; +}; + +} // namespace File diff --git a/Source/Core/Common/FileUtil.cpp b/Source/Core/Common/FileUtil.cpp index 203ddbac4b..0a1a425830 100644 --- a/Source/Core/Common/FileUtil.cpp +++ b/Source/Core/Common/FileUtil.cpp @@ -16,6 +16,7 @@ #include "Common/CommonFuncs.h" #include "Common/CommonPaths.h" #include "Common/CommonTypes.h" +#include "Common/File.h" #include "Common/FileUtil.h" #include "Common/Logging/Log.h" @@ -901,118 +902,4 @@ bool ReadFileToString(const std::string& filename, std::string& str) return retval; } -IOFile::IOFile() : m_file(nullptr), m_good(true) -{ -} - -IOFile::IOFile(std::FILE* file) : m_file(file), m_good(true) -{ -} - -IOFile::IOFile(const std::string& filename, const char openmode[]) : m_file(nullptr), m_good(true) -{ - Open(filename, openmode); -} - -IOFile::~IOFile() -{ - Close(); -} - -IOFile::IOFile(IOFile&& other) noexcept : m_file(nullptr), m_good(true) -{ - Swap(other); -} - -IOFile& IOFile::operator=(IOFile&& other) noexcept -{ - Swap(other); - return *this; -} - -void IOFile::Swap(IOFile& other) noexcept -{ - std::swap(m_file, other.m_file); - std::swap(m_good, other.m_good); -} - -bool IOFile::Open(const std::string& filename, const char openmode[]) -{ - Close(); -#ifdef _WIN32 - _tfopen_s(&m_file, UTF8ToTStr(filename).c_str(), UTF8ToTStr(openmode).c_str()); -#else - m_file = fopen(filename.c_str(), openmode); -#endif - - m_good = IsOpen(); - return m_good; -} - -bool IOFile::Close() -{ - if (!IsOpen() || 0 != std::fclose(m_file)) - m_good = false; - - m_file = nullptr; - return m_good; -} - -void IOFile::SetHandle(std::FILE* file) -{ - Close(); - Clear(); - m_file = file; -} - -u64 IOFile::GetSize() -{ - if (IsOpen()) - return File::GetSize(m_file); - else - return 0; -} - -bool IOFile::Seek(s64 off, int origin) -{ - if (!IsOpen() || 0 != fseeko(m_file, off, origin)) - m_good = false; - - return m_good; -} - -u64 IOFile::Tell() const -{ - if (IsOpen()) - return ftello(m_file); - else - return UINT64_MAX; -} - -bool IOFile::Flush() -{ - if (!IsOpen() || 0 != std::fflush(m_file)) - m_good = false; - - return m_good; -} - -bool IOFile::Resize(u64 size) -{ - if (!IsOpen() || - 0 != -#ifdef _WIN32 - // ector: _chsize sucks, not 64-bit safe - // F|RES: changed to _chsize_s. i think it is 64-bit safe - _chsize_s(_fileno(m_file), size) -#else - // TODO: handle 64bit and growing - ftruncate(fileno(m_file), size) -#endif - ) - m_good = false; - - return m_good; -} - } // namespace diff --git a/Source/Core/Common/FileUtil.h b/Source/Core/Common/FileUtil.h index d0aca675dc..5eec5382ce 100644 --- a/Source/Core/Common/FileUtil.h +++ b/Source/Core/Common/FileUtil.h @@ -5,7 +5,6 @@ #pragma once #include -#include #include #include #include @@ -163,85 +162,6 @@ std::string& GetExeDirectory(); bool WriteStringToFile(const std::string& str, const std::string& filename); bool ReadFileToString(const std::string& filename, std::string& str); -// simple wrapper for cstdlib file functions to -// hopefully will make error checking easier -// and make forgetting an fclose() harder -class IOFile : public NonCopyable -{ -public: - IOFile(); - IOFile(std::FILE* file); - IOFile(const std::string& filename, const char openmode[]); - - ~IOFile(); - - IOFile(IOFile&& other) noexcept; - IOFile& operator=(IOFile&& other) noexcept; - - void Swap(IOFile& other) noexcept; - - bool Open(const std::string& filename, const char openmode[]); - bool Close(); - - template - bool ReadArray(T* data, size_t length, size_t* pReadBytes = nullptr) - { - size_t read_bytes = 0; - if (!IsOpen() || length != (read_bytes = std::fread(data, sizeof(T), length, m_file))) - m_good = false; - - if (pReadBytes) - *pReadBytes = read_bytes; - - return m_good; - } - - template - bool WriteArray(const T* data, size_t length) - { - if (!IsOpen() || length != std::fwrite(data, sizeof(T), length, m_file)) - m_good = false; - - return m_good; - } - - bool ReadBytes(void* data, size_t length) - { - return ReadArray(reinterpret_cast(data), length); - } - - bool WriteBytes(const void* data, size_t length) - { - return WriteArray(reinterpret_cast(data), length); - } - - bool IsOpen() const { return nullptr != m_file; } - // m_good is set to false when a read, write or other function fails - bool IsGood() const { return m_good; } - explicit operator bool() const { return IsGood() && IsOpen(); } - std::FILE* GetHandle() { return m_file; } - void SetHandle(std::FILE* file); - - bool Seek(s64 off, int origin); - u64 Tell() const; - u64 GetSize(); - bool Resize(u64 size); - bool Flush(); - - // clear error state - void Clear() - { - m_good = true; - std::clearerr(m_file); - } - -private: - std::FILE* m_file; - bool m_good; -}; - -} // namespace - // To deal with Windows being dumb at unicode: template void OpenFStream(T& fstream, const std::string& filename, std::ios_base::openmode openmode) @@ -252,3 +172,5 @@ void OpenFStream(T& fstream, const std::string& filename, std::ios_base::openmod fstream.open(filename.c_str(), openmode); #endif } + +} // namespace diff --git a/Source/Core/Common/IniFile.cpp b/Source/Core/Common/IniFile.cpp index 1543d0f96f..5c38dd6a19 100644 --- a/Source/Core/Common/IniFile.cpp +++ b/Source/Core/Common/IniFile.cpp @@ -401,7 +401,7 @@ bool IniFile::Load(const std::string& filename, bool keep_current_data) // Open file std::ifstream in; - OpenFStream(in, filename, std::ios::in); + File::OpenFStream(in, filename, std::ios::in); if (in.fail()) return false; @@ -474,7 +474,7 @@ bool IniFile::Save(const std::string& filename) { std::ofstream out; std::string temp = File::GetTempFilenameForAtomicWrite(filename); - OpenFStream(out, temp, std::ios::out); + File::OpenFStream(out, temp, std::ios::out); if (out.fail()) { diff --git a/Source/Core/Common/JitRegister.cpp b/Source/Core/Common/JitRegister.cpp index 45a04d6149..61d7e05685 100644 --- a/Source/Core/Common/JitRegister.cpp +++ b/Source/Core/Common/JitRegister.cpp @@ -10,7 +10,7 @@ #include #include "Common/CommonTypes.h" -#include "Common/FileUtil.h" +#include "Common/File.h" #include "Common/JitRegister.h" #include "Common/StringUtil.h" diff --git a/Source/Core/Common/LinearDiskCache.h b/Source/Core/Common/LinearDiskCache.h index 2db1a0ad82..630a624d6b 100644 --- a/Source/Core/Common/LinearDiskCache.h +++ b/Source/Core/Common/LinearDiskCache.h @@ -70,7 +70,7 @@ public: m_num_entries = 0; // try opening for reading/writing - OpenFStream(m_file, filename, ios_base::in | ios_base::out | ios_base::binary); + File::OpenFStream(m_file, filename, ios_base::in | ios_base::out | ios_base::binary); m_file.seekg(0, std::ios::end); std::fstream::pos_type end_pos = m_file.tellg(); diff --git a/Source/Core/Common/Logging/LogManager.cpp b/Source/Core/Common/Logging/LogManager.cpp index 3b2d925047..2c09bc5051 100644 --- a/Source/Core/Common/Logging/LogManager.cpp +++ b/Source/Core/Common/Logging/LogManager.cpp @@ -170,7 +170,7 @@ LogContainer::LogContainer(const std::string& shortName, const std::string& full FileLogListener::FileLogListener(const std::string& filename) { - OpenFStream(m_logfile, filename, std::ios::app); + File::OpenFStream(m_logfile, filename, std::ios::app); SetEnable(true); } diff --git a/Source/Core/Common/NandPaths.cpp b/Source/Core/Common/NandPaths.cpp index 21639fdcb9..1fcbab38be 100644 --- a/Source/Core/Common/NandPaths.cpp +++ b/Source/Core/Common/NandPaths.cpp @@ -9,6 +9,7 @@ #include #include "Common/CommonTypes.h" +#include "Common/File.h" #include "Common/FileUtil.h" #include "Common/Logging/Log.h" #include "Common/NandPaths.h" diff --git a/Source/Core/Common/PcapFile.cpp b/Source/Core/Common/PcapFile.cpp index e7be008c68..5ce626f279 100644 --- a/Source/Core/Common/PcapFile.cpp +++ b/Source/Core/Common/PcapFile.cpp @@ -5,7 +5,7 @@ #include #include "Common/CommonTypes.h" -#include "Common/FileUtil.h" +#include "Common/File.h" #include "Common/PcapFile.h" namespace diff --git a/Source/Core/Common/PcapFile.h b/Source/Core/Common/PcapFile.h index 823a974946..b37e0e845f 100644 --- a/Source/Core/Common/PcapFile.h +++ b/Source/Core/Common/PcapFile.h @@ -17,7 +17,7 @@ #include #include "Common/CommonTypes.h" -#include "Common/FileUtil.h" +#include "Common/File.h" #include "Common/NonCopyable.h" class PCAP final : public NonCopyable diff --git a/Source/Core/Common/SDCardUtil.cpp b/Source/Core/Common/SDCardUtil.cpp index 9e72990747..7e1d4ee04e 100644 --- a/Source/Core/Common/SDCardUtil.cpp +++ b/Source/Core/Common/SDCardUtil.cpp @@ -41,7 +41,7 @@ #include "Common/CommonFuncs.h" #include "Common/CommonTypes.h" -#include "Common/FileUtil.h" +#include "Common/File.h" #include "Common/Logging/Log.h" #include "Common/SDCardUtil.h" diff --git a/Source/Core/Common/SettingsHandler.cpp b/Source/Core/Common/SettingsHandler.cpp index 9d0bd84eb3..1629a017cf 100644 --- a/Source/Core/Common/SettingsHandler.cpp +++ b/Source/Core/Common/SettingsHandler.cpp @@ -17,6 +17,7 @@ #endif #include "Common/CommonTypes.h" +#include "Common/File.h" #include "Common/FileUtil.h" #include "Common/SettingsHandler.h" #include "Common/Timer.h" diff --git a/Source/Core/Common/SysConf.cpp b/Source/Core/Common/SysConf.cpp index 6b2b1eb6c1..a1865f7fc3 100644 --- a/Source/Core/Common/SysConf.cpp +++ b/Source/Core/Common/SysConf.cpp @@ -13,6 +13,7 @@ #include "Common/CommonPaths.h" #include "Common/CommonTypes.h" +#include "Common/File.h" #include "Common/FileUtil.h" #include "Common/Swap.h" #include "Core/Movie.h" diff --git a/Source/Core/Core/Boot/Boot.cpp b/Source/Core/Core/Boot/Boot.cpp index a703716abb..7e09f45e1f 100644 --- a/Source/Core/Core/Boot/Boot.cpp +++ b/Source/Core/Core/Boot/Boot.cpp @@ -17,6 +17,7 @@ #include "Common/CDUtils.h" #include "Common/CommonPaths.h" #include "Common/CommonTypes.h" +#include "Common/File.h" #include "Common/FileUtil.h" #include "Common/Logging/Log.h" #include "Common/MsgHandler.h" diff --git a/Source/Core/Core/Boot/Boot_BS2Emu.cpp b/Source/Core/Core/Boot/Boot_BS2Emu.cpp index 22737f4246..3e56831470 100644 --- a/Source/Core/Core/Boot/Boot_BS2Emu.cpp +++ b/Source/Core/Core/Boot/Boot_BS2Emu.cpp @@ -9,6 +9,7 @@ #include "Common/CommonPaths.h" #include "Common/CommonTypes.h" +#include "Common/File.h" #include "Common/FileUtil.h" #include "Common/Logging/Log.h" #include "Common/MsgHandler.h" diff --git a/Source/Core/Core/Boot/Boot_WiiWAD.cpp b/Source/Core/Core/Boot/Boot_WiiWAD.cpp index 889496ccb2..3a7cb62e8d 100644 --- a/Source/Core/Core/Boot/Boot_WiiWAD.cpp +++ b/Source/Core/Core/Boot/Boot_WiiWAD.cpp @@ -10,6 +10,7 @@ #include "Common/CommonPaths.h" #include "Common/CommonTypes.h" +#include "Common/File.h" #include "Common/FileUtil.h" #include "Common/MsgHandler.h" #include "Common/NandPaths.h" diff --git a/Source/Core/Core/Boot/DolReader.cpp b/Source/Core/Core/Boot/DolReader.cpp index 7f17696240..391aace573 100644 --- a/Source/Core/Core/Boot/DolReader.cpp +++ b/Source/Core/Core/Boot/DolReader.cpp @@ -8,6 +8,7 @@ #include #include +#include "Common/File.h" #include "Common/FileUtil.h" #include "Common/Swap.h" #include "Core/HW/Memmap.h" diff --git a/Source/Core/Core/Core.cpp b/Source/Core/Core/Core.cpp index 75b36ef0fd..6df1fddda6 100644 --- a/Source/Core/Core/Core.cpp +++ b/Source/Core/Core/Core.cpp @@ -21,6 +21,7 @@ #include "Common/CPUDetect.h" #include "Common/CommonPaths.h" #include "Common/CommonTypes.h" +#include "Common/FileUtil.h" #include "Common/Flag.h" #include "Common/Logging/LogManager.h" #include "Common/MemoryUtil.h" diff --git a/Source/Core/Core/DSP/DSPCaptureLogger.cpp b/Source/Core/Core/DSP/DSPCaptureLogger.cpp index 4b36b2ff41..84afed65b8 100644 --- a/Source/Core/Core/DSP/DSPCaptureLogger.cpp +++ b/Source/Core/Core/DSP/DSPCaptureLogger.cpp @@ -7,7 +7,7 @@ #include #include "Common/CommonTypes.h" -#include "Common/FileUtil.h" +#include "Common/File.h" #include "Common/PcapFile.h" #include "Core/DSP/DSPCaptureLogger.h" diff --git a/Source/Core/Core/DSP/DSPCodeUtil.cpp b/Source/Core/Core/DSP/DSPCodeUtil.cpp index cef0e12f63..b1ff9b7b8b 100644 --- a/Source/Core/Core/DSP/DSPCodeUtil.cpp +++ b/Source/Core/Core/DSP/DSPCodeUtil.cpp @@ -8,6 +8,7 @@ #include #include "Common/CommonTypes.h" +#include "Common/File.h" #include "Common/FileUtil.h" #include "Common/StringUtil.h" #include "Common/Swap.h" diff --git a/Source/Core/Core/DSP/DSPDisassembler.cpp b/Source/Core/Core/DSP/DSPDisassembler.cpp index c9627de3af..e43f400390 100644 --- a/Source/Core/Core/DSP/DSPDisassembler.cpp +++ b/Source/Core/Core/DSP/DSPDisassembler.cpp @@ -12,6 +12,7 @@ #include #include "Common/CommonTypes.h" +#include "Common/File.h" #include "Common/FileUtil.h" #include "Common/StringUtil.h" diff --git a/Source/Core/Core/Debugger/Dump.cpp b/Source/Core/Core/Debugger/Dump.cpp index a7ee736caf..fc5adef2f7 100644 --- a/Source/Core/Core/Debugger/Dump.cpp +++ b/Source/Core/Core/Debugger/Dump.cpp @@ -6,7 +6,7 @@ #include #include "Common/CommonTypes.h" -#include "Common/FileUtil.h" +#include "Common/File.h" #include "Core/Debugger/Dump.h" diff --git a/Source/Core/Core/FifoPlayer/FifoDataFile.cpp b/Source/Core/Core/FifoPlayer/FifoDataFile.cpp index 6e7899a78c..e827ffda3a 100644 --- a/Source/Core/Core/FifoPlayer/FifoDataFile.cpp +++ b/Source/Core/Core/FifoPlayer/FifoDataFile.cpp @@ -8,7 +8,7 @@ #include #include -#include "Common/FileUtil.h" +#include "Common/File.h" #include "Core/FifoPlayer/FifoDataFile.h" diff --git a/Source/Core/Core/HW/DSPHLE/UCodes/AX.cpp b/Source/Core/Core/HW/DSPHLE/UCodes/AX.cpp index 8cf4c33507..b9fbb6c5b4 100644 --- a/Source/Core/Core/HW/DSPHLE/UCodes/AX.cpp +++ b/Source/Core/Core/HW/DSPHLE/UCodes/AX.cpp @@ -6,6 +6,7 @@ #include "Common/ChunkFile.h" #include "Common/CommonTypes.h" +#include "Common/File.h" #include "Common/FileUtil.h" #include "Common/Logging/Log.h" #include "Common/MathUtil.h" diff --git a/Source/Core/Core/HW/DSPHLE/UCodes/ROM.cpp b/Source/Core/Core/HW/DSPHLE/UCodes/ROM.cpp index ae3e3d4dab..6154e885a1 100644 --- a/Source/Core/Core/HW/DSPHLE/UCodes/ROM.cpp +++ b/Source/Core/Core/HW/DSPHLE/UCodes/ROM.cpp @@ -12,6 +12,7 @@ #include "Common/ChunkFile.h" #include "Common/CommonTypes.h" +#include "Common/File.h" #include "Common/FileUtil.h" #include "Common/Hash.h" #include "Common/Logging/Log.h" diff --git a/Source/Core/Core/HW/DSPHLE/UCodes/UCodes.cpp b/Source/Core/Core/HW/DSPHLE/UCodes/UCodes.cpp index dff0f541b8..bc13291112 100644 --- a/Source/Core/Core/HW/DSPHLE/UCodes/UCodes.cpp +++ b/Source/Core/Core/HW/DSPHLE/UCodes/UCodes.cpp @@ -14,6 +14,7 @@ #include "Common/ChunkFile.h" #include "Common/CommonTypes.h" +#include "Common/File.h" #include "Common/FileUtil.h" #include "Common/Hash.h" #include "Common/Logging/Log.h" diff --git a/Source/Core/Core/HW/DSPLLE/DSPLLEGlobals.cpp b/Source/Core/Core/HW/DSPLLE/DSPLLEGlobals.cpp index 450131dcfa..c3914e1772 100644 --- a/Source/Core/Core/HW/DSPLLE/DSPLLEGlobals.cpp +++ b/Source/Core/Core/HW/DSPLLE/DSPLLEGlobals.cpp @@ -5,7 +5,7 @@ #include #include "Common/CommonTypes.h" -#include "Common/FileUtil.h" +#include "Common/File.h" #include "Core/DSP/DSPCore.h" #include "Core/HW/DSPLLE/DSPLLEGlobals.h" diff --git a/Source/Core/Core/HW/DSPLLE/DSPSymbols.cpp b/Source/Core/Core/HW/DSPLLE/DSPSymbols.cpp index 8f604c213f..abc2f4b0d2 100644 --- a/Source/Core/Core/HW/DSPLLE/DSPSymbols.cpp +++ b/Source/Core/Core/HW/DSPLLE/DSPSymbols.cpp @@ -8,7 +8,7 @@ #include #include "Common/CommonTypes.h" -#include "Common/FileUtil.h" +#include "Common/File.h" #include "Common/StringUtil.h" #include "Core/DSP/DSPCore.h" diff --git a/Source/Core/Core/HW/EXI/EXI_DeviceAGP.cpp b/Source/Core/Core/HW/EXI/EXI_DeviceAGP.cpp index 722f131603..064a61b024 100644 --- a/Source/Core/Core/HW/EXI/EXI_DeviceAGP.cpp +++ b/Source/Core/Core/HW/EXI/EXI_DeviceAGP.cpp @@ -11,7 +11,7 @@ #include "Common/ChunkFile.h" #include "Common/CommonTypes.h" -#include "Common/FileUtil.h" +#include "Common/File.h" #include "Common/Logging/Log.h" #include "Common/StringUtil.h" #include "Core/ConfigManager.h" diff --git a/Source/Core/Core/HW/EXI/EXI_DeviceIPL.cpp b/Source/Core/Core/HW/EXI/EXI_DeviceIPL.cpp index 7df96147b4..a5df52b53f 100644 --- a/Source/Core/Core/HW/EXI/EXI_DeviceIPL.cpp +++ b/Source/Core/Core/HW/EXI/EXI_DeviceIPL.cpp @@ -11,6 +11,7 @@ #include "Common/ChunkFile.h" #include "Common/CommonPaths.h" #include "Common/CommonTypes.h" +#include "Common/File.h" #include "Common/FileUtil.h" #include "Common/Logging/Log.h" #include "Common/MemoryUtil.h" diff --git a/Source/Core/Core/HW/GCMemcard/GCMemcard.cpp b/Source/Core/Core/HW/GCMemcard/GCMemcard.cpp index 29f6a8f595..b0acaf00bb 100644 --- a/Source/Core/Core/HW/GCMemcard/GCMemcard.cpp +++ b/Source/Core/Core/HW/GCMemcard/GCMemcard.cpp @@ -13,7 +13,7 @@ #include "Common/CommonFuncs.h" #include "Common/CommonPaths.h" #include "Common/CommonTypes.h" -#include "Common/FileUtil.h" +#include "Common/File.h" #include "Common/MsgHandler.h" #include "Common/StringUtil.h" #include "Common/Swap.h" diff --git a/Source/Core/Core/HW/GCMemcard/GCMemcardDirectory.cpp b/Source/Core/Core/HW/GCMemcard/GCMemcardDirectory.cpp index 0fc0a18b3d..f12751c8be 100644 --- a/Source/Core/Core/HW/GCMemcard/GCMemcardDirectory.cpp +++ b/Source/Core/Core/HW/GCMemcard/GCMemcardDirectory.cpp @@ -16,6 +16,7 @@ #include "Common/Assert.h" #include "Common/ChunkFile.h" #include "Common/CommonTypes.h" +#include "Common/File.h" #include "Common/FileSearch.h" #include "Common/FileUtil.h" #include "Common/Logging/Log.h" diff --git a/Source/Core/Core/HW/GCMemcard/GCMemcardRaw.cpp b/Source/Core/Core/HW/GCMemcard/GCMemcardRaw.cpp index 6895ff327c..4981aad225 100644 --- a/Source/Core/Core/HW/GCMemcard/GCMemcardRaw.cpp +++ b/Source/Core/Core/HW/GCMemcard/GCMemcardRaw.cpp @@ -13,6 +13,7 @@ #include "Common/ChunkFile.h" #include "Common/CommonTypes.h" +#include "Common/File.h" #include "Common/FileUtil.h" #include "Common/Logging/Log.h" #include "Common/StringUtil.h" diff --git a/Source/Core/Core/HW/Sram.cpp b/Source/Core/Core/HW/Sram.cpp index 79b92209d5..c27a09d1a4 100644 --- a/Source/Core/Core/HW/Sram.cpp +++ b/Source/Core/Core/HW/Sram.cpp @@ -5,7 +5,7 @@ #include "Core/HW/Sram.h" #include "Common/CommonTypes.h" -#include "Common/FileUtil.h" +#include "Common/File.h" #include "Common/Logging/Log.h" #include "Common/Swap.h" #include "Core/ConfigManager.h" diff --git a/Source/Core/Core/HW/WiiSaveCrypted.cpp b/Source/Core/Core/HW/WiiSaveCrypted.cpp index 46ba3fd33a..004a58ba33 100644 --- a/Source/Core/Core/HW/WiiSaveCrypted.cpp +++ b/Source/Core/Core/HW/WiiSaveCrypted.cpp @@ -23,6 +23,7 @@ #include "Common/Align.h" #include "Common/CommonTypes.h" #include "Common/Crypto/ec.h" +#include "Common/File.h" #include "Common/FileUtil.h" #include "Common/Logging/Log.h" #include "Common/MsgHandler.h" diff --git a/Source/Core/Core/HW/WiimoteEmu/EmuSubroutines.cpp b/Source/Core/Core/HW/WiimoteEmu/EmuSubroutines.cpp index 0e45f869b4..76d27f3714 100644 --- a/Source/Core/Core/HW/WiimoteEmu/EmuSubroutines.cpp +++ b/Source/Core/Core/HW/WiimoteEmu/EmuSubroutines.cpp @@ -268,8 +268,8 @@ void Wiimote::WriteData(const wm_write_data* const wd) { // TODO Only write parts of the Mii block std::ofstream file; - OpenFStream(file, File::GetUserPath(D_SESSION_WIIROOT_IDX) + "/mii.bin", - std::ios::binary | std::ios::out); + File::OpenFStream(file, File::GetUserPath(D_SESSION_WIIROOT_IDX) + "/mii.bin", + std::ios::binary | std::ios::out); file.write((char*)m_eeprom + 0x0FCA, 0x02f0); file.close(); } diff --git a/Source/Core/Core/HW/WiimoteEmu/Speaker.cpp b/Source/Core/Core/HW/WiimoteEmu/Speaker.cpp index adb2872e21..fb66bfb093 100644 --- a/Source/Core/Core/HW/WiimoteEmu/Speaker.cpp +++ b/Source/Core/Core/HW/WiimoteEmu/Speaker.cpp @@ -144,7 +144,7 @@ void Wiimote::SpeakerData(const wm_speaker_data* sd) File::Delete("rmtdump.wav"); File::Delete("rmtdump.bin"); atexit(stopdamnwav); - OpenFStream(ofile, "rmtdump.bin", ofile.binary | ofile.out); + File::OpenFStream(ofile, "rmtdump.bin", ofile.binary | ofile.out); wav.Start("rmtdump.wav", 6000); } wav.AddMonoSamples(samples.get(), sd->length * 2); diff --git a/Source/Core/Core/IOS/ES/ES.cpp b/Source/Core/Core/IOS/ES/ES.cpp index 629f093f23..c6930e1efc 100644 --- a/Source/Core/Core/IOS/ES/ES.cpp +++ b/Source/Core/Core/IOS/ES/ES.cpp @@ -12,6 +12,7 @@ #include #include "Common/ChunkFile.h" +#include "Common/File.h" #include "Common/FileUtil.h" #include "Common/Logging/Log.h" #include "Common/MsgHandler.h" diff --git a/Source/Core/Core/IOS/ES/Formats.cpp b/Source/Core/Core/IOS/ES/Formats.cpp index 3de8deb312..8790dd2ff1 100644 --- a/Source/Core/Core/IOS/ES/Formats.cpp +++ b/Source/Core/Core/IOS/ES/Formats.cpp @@ -19,6 +19,7 @@ #include "Common/Assert.h" #include "Common/ChunkFile.h" #include "Common/CommonTypes.h" +#include "Common/File.h" #include "Common/FileUtil.h" #include "Common/Logging/Log.h" #include "Common/StringUtil.h" diff --git a/Source/Core/Core/IOS/ES/NandUtils.cpp b/Source/Core/Core/IOS/ES/NandUtils.cpp index 7f5b3a026d..4bbbbfbb65 100644 --- a/Source/Core/Core/IOS/ES/NandUtils.cpp +++ b/Source/Core/Core/IOS/ES/NandUtils.cpp @@ -12,6 +12,7 @@ #include #include "Common/CommonTypes.h" +#include "Common/File.h" #include "Common/FileUtil.h" #include "Common/Logging/Log.h" #include "Common/NandPaths.h" diff --git a/Source/Core/Core/IOS/ES/TitleManagement.cpp b/Source/Core/Core/IOS/ES/TitleManagement.cpp index ca81b76333..f5206ef1a1 100644 --- a/Source/Core/Core/IOS/ES/TitleManagement.cpp +++ b/Source/Core/Core/IOS/ES/TitleManagement.cpp @@ -14,6 +14,7 @@ #include "Common/Align.h" #include "Common/Crypto/AES.h" +#include "Common/File.h" #include "Common/FileUtil.h" #include "Common/Logging/Log.h" #include "Common/NandPaths.h" @@ -36,6 +37,7 @@ static ReturnCode WriteTicket(const IOS::ES::TicketReader& ticket) const std::string ticket_path = Common::GetTicketFileName(title_id, Common::FROM_SESSION_ROOT); File::CreateFullPath(ticket_path); + File::IOFile ticket_file(ticket_path, "wb"); if (!ticket_file) return ES_EIO; diff --git a/Source/Core/Core/IOS/FS/FS.cpp b/Source/Core/Core/IOS/FS/FS.cpp index c23f450cd0..a34be31199 100644 --- a/Source/Core/Core/IOS/FS/FS.cpp +++ b/Source/Core/Core/IOS/FS/FS.cpp @@ -12,6 +12,7 @@ #include "Common/ChunkFile.h" #include "Common/CommonPaths.h" #include "Common/CommonTypes.h" +#include "Common/File.h" #include "Common/FileUtil.h" #include "Common/Logging/Log.h" #include "Common/MsgHandler.h" diff --git a/Source/Core/Core/IOS/FS/FileIO.cpp b/Source/Core/Core/IOS/FS/FileIO.cpp index fd0361bc64..0d8baa4c6f 100644 --- a/Source/Core/Core/IOS/FS/FileIO.cpp +++ b/Source/Core/Core/IOS/FS/FileIO.cpp @@ -11,6 +11,7 @@ #include "Common/Assert.h" #include "Common/ChunkFile.h" #include "Common/CommonTypes.h" +#include "Common/File.h" #include "Common/FileUtil.h" #include "Common/NandPaths.h" #include "Core/HW/Memmap.h" diff --git a/Source/Core/Core/IOS/Network/KD/NWC24Config.cpp b/Source/Core/Core/IOS/Network/KD/NWC24Config.cpp index 543b490429..8609e4b6ab 100644 --- a/Source/Core/Core/IOS/Network/KD/NWC24Config.cpp +++ b/Source/Core/Core/IOS/Network/KD/NWC24Config.cpp @@ -8,6 +8,7 @@ #include "Common/CommonPaths.h" #include "Common/CommonTypes.h" +#include "Common/File.h" #include "Common/FileUtil.h" #include "Common/Logging/Log.h" #include "Common/Swap.h" diff --git a/Source/Core/Core/IOS/Network/NCD/WiiNetConfig.cpp b/Source/Core/Core/IOS/Network/NCD/WiiNetConfig.cpp index e101f5be6c..3c18ace58a 100644 --- a/Source/Core/Core/IOS/Network/NCD/WiiNetConfig.cpp +++ b/Source/Core/Core/IOS/Network/NCD/WiiNetConfig.cpp @@ -8,6 +8,7 @@ #include "Common/CommonPaths.h" #include "Common/CommonTypes.h" +#include "Common/File.h" #include "Common/FileUtil.h" #include "Common/Logging/Log.h" #include "Core/HW/Memmap.h" diff --git a/Source/Core/Core/IOS/Network/SSL.cpp b/Source/Core/Core/IOS/Network/SSL.cpp index 925ab34f56..f135b4938a 100644 --- a/Source/Core/Core/IOS/Network/SSL.cpp +++ b/Source/Core/Core/IOS/Network/SSL.cpp @@ -10,6 +10,7 @@ #include #include +#include "Common/File.h" #include "Common/FileUtil.h" #include "Common/Logging/Log.h" #include "Common/MsgHandler.h" diff --git a/Source/Core/Core/IOS/Network/Socket.cpp b/Source/Core/Core/IOS/Network/Socket.cpp index ce79f8dfcb..6b57a1ebb3 100644 --- a/Source/Core/Core/IOS/Network/Socket.cpp +++ b/Source/Core/Core/IOS/Network/Socket.cpp @@ -12,6 +12,7 @@ #include #endif +#include "Common/File.h" #include "Common/FileUtil.h" #include "Core/ConfigManager.h" #include "Core/Core.h" diff --git a/Source/Core/Core/IOS/SDIO/SDIOSlot0.cpp b/Source/Core/Core/IOS/SDIO/SDIOSlot0.cpp index 14a739e601..0b894b1edf 100644 --- a/Source/Core/Core/IOS/SDIO/SDIOSlot0.cpp +++ b/Source/Core/Core/IOS/SDIO/SDIOSlot0.cpp @@ -9,6 +9,7 @@ #include "Common/ChunkFile.h" #include "Common/CommonTypes.h" +#include "Common/File.h" #include "Common/FileUtil.h" #include "Common/Logging/Log.h" #include "Common/SDCardUtil.h" diff --git a/Source/Core/Core/IOS/SDIO/SDIOSlot0.h b/Source/Core/Core/IOS/SDIO/SDIOSlot0.h index 5e69389b30..9ca7729dd0 100644 --- a/Source/Core/Core/IOS/SDIO/SDIOSlot0.h +++ b/Source/Core/Core/IOS/SDIO/SDIOSlot0.h @@ -10,7 +10,7 @@ #include #include "Common/CommonTypes.h" -#include "Common/FileUtil.h" +#include "Common/File.h" #include "Core/IOS/Device.h" #include "Core/IOS/IOS.h" diff --git a/Source/Core/Core/IOS/USB/Bluetooth/BTBase.cpp b/Source/Core/Core/IOS/USB/Bluetooth/BTBase.cpp index c4131f38a8..7622e967d4 100644 --- a/Source/Core/Core/IOS/USB/Bluetooth/BTBase.cpp +++ b/Source/Core/Core/IOS/USB/Bluetooth/BTBase.cpp @@ -10,6 +10,7 @@ #include "Common/CommonPaths.h" #include "Common/CommonTypes.h" +#include "Common/File.h" #include "Common/FileUtil.h" #include "Common/Logging/Log.h" #include "Common/SysConf.h" diff --git a/Source/Core/Core/IOS/USB/Bluetooth/BTEmu.cpp b/Source/Core/Core/IOS/USB/Bluetooth/BTEmu.cpp index c0296abcdf..876bcdff0c 100644 --- a/Source/Core/Core/IOS/USB/Bluetooth/BTEmu.cpp +++ b/Source/Core/Core/IOS/USB/Bluetooth/BTEmu.cpp @@ -10,7 +10,6 @@ #include "Common/Assert.h" #include "Common/CommonPaths.h" -#include "Common/FileUtil.h" #include "Common/Logging/Log.h" #include "Common/MsgHandler.h" #include "Common/NandPaths.h" diff --git a/Source/Core/Core/IOS/WFS/WFSI.cpp b/Source/Core/Core/IOS/WFS/WFSI.cpp index 34e4d4e8b7..905e7629e8 100644 --- a/Source/Core/Core/IOS/WFS/WFSI.cpp +++ b/Source/Core/Core/IOS/WFS/WFSI.cpp @@ -11,6 +11,7 @@ #include #include "Common/CommonTypes.h" +#include "Common/File.h" #include "Common/FileUtil.h" #include "Common/Logging/Log.h" #include "Core/HW/Memmap.h" diff --git a/Source/Core/Core/IOS/WFS/WFSSRV.cpp b/Source/Core/Core/IOS/WFS/WFSSRV.cpp index 54bdd806b7..81639e69ad 100644 --- a/Source/Core/Core/IOS/WFS/WFSSRV.cpp +++ b/Source/Core/Core/IOS/WFS/WFSSRV.cpp @@ -8,6 +8,7 @@ #include #include "Common/CommonTypes.h" +#include "Common/File.h" #include "Common/FileUtil.h" #include "Common/Logging/Log.h" #include "Common/NandPaths.h" diff --git a/Source/Core/Core/IOS/WFS/WFSSRV.h b/Source/Core/Core/IOS/WFS/WFSSRV.h index 097e086f0b..602d30777e 100644 --- a/Source/Core/Core/IOS/WFS/WFSSRV.h +++ b/Source/Core/Core/IOS/WFS/WFSSRV.h @@ -8,7 +8,7 @@ #include #include "Common/CommonTypes.h" -#include "Common/FileUtil.h" +#include "Common/File.h" #include "Core/IOS/Device.h" #include "Core/IOS/IOS.h" #include "DiscIO/Volume.h" diff --git a/Source/Core/Core/Movie.cpp b/Source/Core/Core/Movie.cpp index 8b31b029e7..b37386c1d8 100644 --- a/Source/Core/Core/Movie.cpp +++ b/Source/Core/Core/Movie.cpp @@ -21,11 +21,13 @@ #include "Common/Assert.h" #include "Common/ChunkFile.h" #include "Common/CommonPaths.h" +#include "Common/File.h" #include "Common/FileUtil.h" #include "Common/Hash.h" #include "Common/NandPaths.h" #include "Common/StringUtil.h" #include "Common/Timer.h" + #include "Core/Boot/Boot.h" #include "Core/ConfigManager.h" #include "Core/Core.h" @@ -45,8 +47,11 @@ #include "Core/NetPlayProto.h" #include "Core/PowerPC/PowerPC.h" #include "Core/State.h" + #include "DiscIO/Enums.h" + #include "InputCommon/GCPadStatus.h" + #include "VideoCommon/Fifo.h" #include "VideoCommon/VideoBackendBase.h" #include "VideoCommon/VideoConfig.h" diff --git a/Source/Core/Core/PatchEngine.cpp b/Source/Core/Core/PatchEngine.cpp index fca4c4104f..e2bb9ce143 100644 --- a/Source/Core/Core/PatchEngine.cpp +++ b/Source/Core/Core/PatchEngine.cpp @@ -13,7 +13,6 @@ #include #include "Common/Assert.h" -#include "Common/FileUtil.h" #include "Common/IniFile.h" #include "Common/StringUtil.h" diff --git a/Source/Core/Core/PowerPC/Jit64/Jit.cpp b/Source/Core/Core/PowerPC/Jit64/Jit.cpp index 02e58d1db4..9f45d150f6 100644 --- a/Source/Core/Core/PowerPC/Jit64/Jit.cpp +++ b/Source/Core/Core/PowerPC/Jit64/Jit.cpp @@ -13,7 +13,7 @@ #endif #include "Common/CommonTypes.h" -#include "Common/FileUtil.h" +#include "Common/File.h" #include "Common/Logging/Log.h" #include "Common/MemoryUtil.h" #include "Common/StringUtil.h" diff --git a/Source/Core/Core/PowerPC/JitInterface.cpp b/Source/Core/Core/PowerPC/JitInterface.cpp index 6f602ec3da..2369eb75d6 100644 --- a/Source/Core/Core/PowerPC/JitInterface.cpp +++ b/Source/Core/Core/PowerPC/JitInterface.cpp @@ -18,7 +18,7 @@ #include "Common/ChunkFile.h" #include "Common/CommonTypes.h" -#include "Common/FileUtil.h" +#include "Common/File.h" #include "Common/MsgHandler.h" #include "Core/Core.h" diff --git a/Source/Core/Core/PowerPC/PPCSymbolDB.cpp b/Source/Core/Core/PowerPC/PPCSymbolDB.cpp index 52c2bd5d4d..52408c6f62 100644 --- a/Source/Core/Core/PowerPC/PPCSymbolDB.cpp +++ b/Source/Core/Core/PowerPC/PPCSymbolDB.cpp @@ -8,7 +8,7 @@ #include #include "Common/CommonTypes.h" -#include "Common/FileUtil.h" +#include "Common/File.h" #include "Common/Logging/Log.h" #include "Common/MsgHandler.h" #include "Common/StringUtil.h" diff --git a/Source/Core/Core/PowerPC/PPCTables.cpp b/Source/Core/Core/PowerPC/PPCTables.cpp index 5cb53269a9..26c10d0a69 100644 --- a/Source/Core/Core/PowerPC/PPCTables.cpp +++ b/Source/Core/Core/PowerPC/PPCTables.cpp @@ -13,6 +13,7 @@ #include "Common/Assert.h" #include "Common/CommonTypes.h" +#include "Common/File.h" #include "Common/FileUtil.h" #include "Common/Logging/Log.h" #include "Common/StringUtil.h" diff --git a/Source/Core/Core/PowerPC/SignatureDB/CSVSignatureDB.cpp b/Source/Core/Core/PowerPC/SignatureDB/CSVSignatureDB.cpp index acd4441bbf..ee03ddeeb4 100644 --- a/Source/Core/Core/PowerPC/SignatureDB/CSVSignatureDB.cpp +++ b/Source/Core/Core/PowerPC/SignatureDB/CSVSignatureDB.cpp @@ -6,6 +6,7 @@ #include #include +#include "Common/File.h" #include "Common/FileUtil.h" #include "Common/Logging/Log.h" @@ -17,7 +18,7 @@ bool CSVSignatureDB::Load(const std::string& file_path) { std::string line; std::ifstream ifs; - OpenFStream(ifs, file_path, std::ios_base::in); + File::OpenFStream(ifs, file_path, std::ios_base::in); if (!ifs) return false; diff --git a/Source/Core/Core/PowerPC/SignatureDB/DSYSignatureDB.cpp b/Source/Core/Core/PowerPC/SignatureDB/DSYSignatureDB.cpp index f8f1fa7153..267d235738 100644 --- a/Source/Core/Core/PowerPC/SignatureDB/DSYSignatureDB.cpp +++ b/Source/Core/Core/PowerPC/SignatureDB/DSYSignatureDB.cpp @@ -7,7 +7,7 @@ #include #include "Common/CommonTypes.h" -#include "Common/FileUtil.h" +#include "Common/File.h" #include "Common/Logging/Log.h" #include "Core/PowerPC/SignatureDB/DSYSignatureDB.h" diff --git a/Source/Core/Core/PowerPC/SignatureDB/MEGASignatureDB.cpp b/Source/Core/Core/PowerPC/SignatureDB/MEGASignatureDB.cpp index 9e1a924667..80617f0ab3 100644 --- a/Source/Core/Core/PowerPC/SignatureDB/MEGASignatureDB.cpp +++ b/Source/Core/Core/PowerPC/SignatureDB/MEGASignatureDB.cpp @@ -128,7 +128,7 @@ void MEGASignatureDB::Clear() bool MEGASignatureDB::Load(const std::string& file_path) { std::ifstream ifs; - OpenFStream(ifs, file_path, std::ios_base::in); + File::OpenFStream(ifs, file_path, std::ios_base::in); if (!ifs) return false; diff --git a/Source/Core/Core/State.cpp b/Source/Core/Core/State.cpp index 01cbd1d2fe..931cad413e 100644 --- a/Source/Core/Core/State.cpp +++ b/Source/Core/Core/State.cpp @@ -13,6 +13,7 @@ #include "Common/ChunkFile.h" #include "Common/CommonTypes.h" #include "Common/Event.h" +#include "Common/File.h" #include "Common/FileUtil.h" #include "Common/MsgHandler.h" #include "Common/ScopeGuard.h" diff --git a/Source/Core/Core/TitleDatabase.cpp b/Source/Core/Core/TitleDatabase.cpp index 286aba930e..fee6e13f68 100644 --- a/Source/Core/Core/TitleDatabase.cpp +++ b/Source/Core/Core/TitleDatabase.cpp @@ -53,7 +53,7 @@ static bool LoadMap(const std::string& file_path, Map& map, std::function predicate) { std::ifstream txt; - OpenFStream(txt, file_path, std::ios::in); + File::OpenFStream(txt, file_path, std::ios::in); if (!txt.is_open()) return false; diff --git a/Source/Core/Core/ec_wii.cpp b/Source/Core/Core/ec_wii.cpp index 9049b0a493..f58ad8e05e 100644 --- a/Source/Core/Core/ec_wii.cpp +++ b/Source/Core/Core/ec_wii.cpp @@ -18,6 +18,7 @@ #include "Common/CommonTypes.h" #include "Common/Crypto/ec.h" +#include "Common/File.h" #include "Common/FileUtil.h" #include "Common/Logging/Log.h" #include "Common/Swap.h" diff --git a/Source/Core/DiscIO/Blob.cpp b/Source/Core/DiscIO/Blob.cpp index 9331ebee8a..da8640c7bc 100644 --- a/Source/Core/DiscIO/Blob.cpp +++ b/Source/Core/DiscIO/Blob.cpp @@ -11,7 +11,7 @@ #include "Common/CDUtils.h" #include "Common/CommonTypes.h" -#include "Common/FileUtil.h" +#include "Common/File.h" #include "DiscIO/Blob.h" #include "DiscIO/CISOBlob.h" diff --git a/Source/Core/DiscIO/Blob.h b/Source/Core/DiscIO/Blob.h index 417288346c..9e92b08ae4 100644 --- a/Source/Core/DiscIO/Blob.h +++ b/Source/Core/DiscIO/Blob.h @@ -18,6 +18,7 @@ #include #include #include +#include #include "Common/CommonTypes.h" #include "Common/Swap.h" diff --git a/Source/Core/DiscIO/CISOBlob.cpp b/Source/Core/DiscIO/CISOBlob.cpp index 846952ce8a..7964b5a7a8 100644 --- a/Source/Core/DiscIO/CISOBlob.cpp +++ b/Source/Core/DiscIO/CISOBlob.cpp @@ -8,7 +8,7 @@ #include #include "Common/CommonTypes.h" -#include "Common/FileUtil.h" +#include "Common/File.h" #include "DiscIO/CISOBlob.h" namespace DiscIO diff --git a/Source/Core/DiscIO/CISOBlob.h b/Source/Core/DiscIO/CISOBlob.h index a1c8c97b40..07a340fe1d 100644 --- a/Source/Core/DiscIO/CISOBlob.h +++ b/Source/Core/DiscIO/CISOBlob.h @@ -9,7 +9,7 @@ #include #include "Common/CommonTypes.h" -#include "Common/FileUtil.h" +#include "Common/File.h" #include "DiscIO/Blob.h" namespace DiscIO diff --git a/Source/Core/DiscIO/CompressedBlob.cpp b/Source/Core/DiscIO/CompressedBlob.cpp index e96d0160a5..285059e9c1 100644 --- a/Source/Core/DiscIO/CompressedBlob.cpp +++ b/Source/Core/DiscIO/CompressedBlob.cpp @@ -18,6 +18,7 @@ #include #include "Common/CommonTypes.h" +#include "Common/File.h" #include "Common/FileUtil.h" #include "Common/Hash.h" #include "Common/Logging/Log.h" diff --git a/Source/Core/DiscIO/CompressedBlob.h b/Source/Core/DiscIO/CompressedBlob.h index 281db6c64a..ecf8695c53 100644 --- a/Source/Core/DiscIO/CompressedBlob.h +++ b/Source/Core/DiscIO/CompressedBlob.h @@ -18,7 +18,7 @@ #include #include "Common/CommonTypes.h" -#include "Common/FileUtil.h" +#include "Common/File.h" #include "DiscIO/Blob.h" namespace DiscIO diff --git a/Source/Core/DiscIO/DiscScrubber.cpp b/Source/Core/DiscIO/DiscScrubber.cpp index 009081cbb6..838df208cf 100644 --- a/Source/Core/DiscIO/DiscScrubber.cpp +++ b/Source/Core/DiscIO/DiscScrubber.cpp @@ -12,7 +12,7 @@ #include #include "Common/CommonTypes.h" -#include "Common/FileUtil.h" +#include "Common/File.h" #include "Common/Logging/Log.h" #include "DiscIO/DiscScrubber.h" #include "DiscIO/Filesystem.h" diff --git a/Source/Core/DiscIO/DriveBlob.cpp b/Source/Core/DiscIO/DriveBlob.cpp index 5a4c5aa2f1..b406954114 100644 --- a/Source/Core/DiscIO/DriveBlob.cpp +++ b/Source/Core/DiscIO/DriveBlob.cpp @@ -10,7 +10,7 @@ #include #include "Common/CommonTypes.h" -#include "Common/FileUtil.h" +#include "Common/File.h" #include "Common/Logging/Log.h" #include "Common/MsgHandler.h" #include "DiscIO/Blob.h" diff --git a/Source/Core/DiscIO/DriveBlob.h b/Source/Core/DiscIO/DriveBlob.h index 01ef409111..fd36815600 100644 --- a/Source/Core/DiscIO/DriveBlob.h +++ b/Source/Core/DiscIO/DriveBlob.h @@ -8,7 +8,7 @@ #include #include "Common/CommonTypes.h" -#include "Common/FileUtil.h" +#include "Common/File.h" #include "DiscIO/Blob.h" #ifdef _WIN32 diff --git a/Source/Core/DiscIO/FileBlob.h b/Source/Core/DiscIO/FileBlob.h index 4008cb44cc..6543a2c218 100644 --- a/Source/Core/DiscIO/FileBlob.h +++ b/Source/Core/DiscIO/FileBlob.h @@ -9,7 +9,7 @@ #include #include "Common/CommonTypes.h" -#include "Common/FileUtil.h" +#include "Common/File.h" #include "DiscIO/Blob.h" namespace DiscIO diff --git a/Source/Core/DiscIO/FileSystemGCWii.cpp b/Source/Core/DiscIO/FileSystemGCWii.cpp index 09a171677d..fd70776069 100644 --- a/Source/Core/DiscIO/FileSystemGCWii.cpp +++ b/Source/Core/DiscIO/FileSystemGCWii.cpp @@ -14,7 +14,7 @@ #include "Common/CommonFuncs.h" #include "Common/CommonTypes.h" -#include "Common/FileUtil.h" +#include "Common/File.h" #include "Common/Logging/Log.h" #include "Common/MsgHandler.h" #include "Common/StringUtil.h" diff --git a/Source/Core/DiscIO/NANDContentLoader.cpp b/Source/Core/DiscIO/NANDContentLoader.cpp index 644d6e6caa..fe5d77d15e 100644 --- a/Source/Core/DiscIO/NANDContentLoader.cpp +++ b/Source/Core/DiscIO/NANDContentLoader.cpp @@ -19,6 +19,7 @@ #include "Common/Align.h" #include "Common/CommonTypes.h" #include "Common/Crypto/AES.h" +#include "Common/File.h" #include "Common/FileUtil.h" #include "Common/Logging/Log.h" #include "Common/MsgHandler.h" diff --git a/Source/Core/DiscIO/NANDImporter.cpp b/Source/Core/DiscIO/NANDImporter.cpp index 437640ce8a..1772b4f6f2 100644 --- a/Source/Core/DiscIO/NANDImporter.cpp +++ b/Source/Core/DiscIO/NANDImporter.cpp @@ -9,6 +9,7 @@ #include #include "Common/Crypto/AES.h" +#include "Common/File.h" #include "Common/FileUtil.h" #include "Common/Logging/Log.h" #include "Common/MsgHandler.h" diff --git a/Source/Core/DiscIO/TGCBlob.cpp b/Source/Core/DiscIO/TGCBlob.cpp index a3db368133..aed55f9c8a 100644 --- a/Source/Core/DiscIO/TGCBlob.cpp +++ b/Source/Core/DiscIO/TGCBlob.cpp @@ -8,7 +8,7 @@ #include #include -#include "Common/FileUtil.h" +#include "Common/File.h" #include "Common/Swap.h" namespace diff --git a/Source/Core/DiscIO/TGCBlob.h b/Source/Core/DiscIO/TGCBlob.h index 1fee37a3fd..1a2ef6f326 100644 --- a/Source/Core/DiscIO/TGCBlob.h +++ b/Source/Core/DiscIO/TGCBlob.h @@ -9,7 +9,7 @@ #include #include "Common/CommonTypes.h" -#include "Common/FileUtil.h" +#include "Common/File.h" #include "DiscIO/Blob.h" namespace DiscIO diff --git a/Source/Core/DiscIO/Volume.cpp b/Source/Core/DiscIO/Volume.cpp index 30b96d4ebf..876136e6b9 100644 --- a/Source/Core/DiscIO/Volume.cpp +++ b/Source/Core/DiscIO/Volume.cpp @@ -14,6 +14,7 @@ #include "Common/ColorUtil.h" #include "Common/CommonTypes.h" +#include "Common/File.h" #include "Common/FileUtil.h" #include "Common/NandPaths.h" #include "Common/StringUtil.h" @@ -43,13 +44,11 @@ std::vector Volume::GetWiiBanner(int* width, int* height, u64 title_id) const std::string file_name = Common::GetTitleDataPath(title_id, Common::FROM_CONFIGURED_ROOT) + "banner.bin"; - if (!File::Exists(file_name)) - return std::vector(); - - if (File::GetSize(file_name) < WII_BANNER_OFFSET + WII_BANNER_SIZE) - return std::vector(); File::IOFile file(file_name, "rb"); + if (file.GetSize() < WII_BANNER_OFFSET + WII_BANNER_SIZE) + return std::vector(); + if (!file.Seek(WII_BANNER_OFFSET, SEEK_SET)) return std::vector(); diff --git a/Source/Core/DiscIO/VolumeDirectory.cpp b/Source/Core/DiscIO/VolumeDirectory.cpp index a205f0126a..854aec3da6 100644 --- a/Source/Core/DiscIO/VolumeDirectory.cpp +++ b/Source/Core/DiscIO/VolumeDirectory.cpp @@ -16,6 +16,7 @@ #include "Common/Assert.h" #include "Common/CommonPaths.h" #include "Common/CommonTypes.h" +#include "Common/File.h" #include "Common/FileUtil.h" #include "Common/Logging/Log.h" #include "Common/StringUtil.h" diff --git a/Source/Core/DiscIO/WbfsBlob.cpp b/Source/Core/DiscIO/WbfsBlob.cpp index 7234978df0..ae379e6e51 100644 --- a/Source/Core/DiscIO/WbfsBlob.cpp +++ b/Source/Core/DiscIO/WbfsBlob.cpp @@ -15,7 +15,7 @@ #include "Common/Align.h" #include "Common/Assert.h" #include "Common/CommonTypes.h" -#include "Common/FileUtil.h" +#include "Common/File.h" #include "Common/MsgHandler.h" #include "Common/Swap.h" diff --git a/Source/Core/DiscIO/WbfsBlob.h b/Source/Core/DiscIO/WbfsBlob.h index 5f461899ce..181e32b6b3 100644 --- a/Source/Core/DiscIO/WbfsBlob.h +++ b/Source/Core/DiscIO/WbfsBlob.h @@ -9,7 +9,7 @@ #include #include "Common/CommonTypes.h" -#include "Common/FileUtil.h" +#include "Common/File.h" #include "DiscIO/Blob.h" namespace DiscIO diff --git a/Source/Core/DolphinWX/Debugger/CodeWindowFunctions.cpp b/Source/Core/DolphinWX/Debugger/CodeWindowFunctions.cpp index 2a536c95e6..77ecf38f55 100644 --- a/Source/Core/DolphinWX/Debugger/CodeWindowFunctions.cpp +++ b/Source/Core/DolphinWX/Debugger/CodeWindowFunctions.cpp @@ -321,7 +321,7 @@ void CCodeWindow::OnSymbolsMenu(wxCommandEvent& event) if (!path.IsEmpty()) { std::ifstream f; - OpenFStream(f, WxStrToStr(path), std::ios_base::in); + File::OpenFStream(f, WxStrToStr(path), std::ios_base::in); std::string line; while (std::getline(f, line)) diff --git a/Source/Core/DolphinWX/Debugger/MemoryWindow.cpp b/Source/Core/DolphinWX/Debugger/MemoryWindow.cpp index 16b8a2c1e4..8e45b32a66 100644 --- a/Source/Core/DolphinWX/Debugger/MemoryWindow.cpp +++ b/Source/Core/DolphinWX/Debugger/MemoryWindow.cpp @@ -22,6 +22,7 @@ #include #include "Common/CommonTypes.h" +#include "Common/File.h" #include "Common/FileUtil.h" #include "Common/IniFile.h" #include "Common/StringUtil.h" diff --git a/Source/Core/DolphinWX/NetPlay/NetPlayLauncher.cpp b/Source/Core/DolphinWX/NetPlay/NetPlayLauncher.cpp index 5d0a5b783b..eb6bade7a2 100644 --- a/Source/Core/DolphinWX/NetPlay/NetPlayLauncher.cpp +++ b/Source/Core/DolphinWX/NetPlay/NetPlayLauncher.cpp @@ -5,7 +5,6 @@ #include #include "Common/CommonTypes.h" -#include "Common/FileUtil.h" #include "Common/IniFile.h" #include "Common/StringUtil.h" #include "DolphinWX/NetPlay/NetPlayLauncher.h" diff --git a/Source/Core/VideoBackends/D3D/D3DShader.cpp b/Source/Core/VideoBackends/D3D/D3DShader.cpp index c1bdeb0d3c..cd9622b4a3 100644 --- a/Source/Core/VideoBackends/D3D/D3DShader.cpp +++ b/Source/Core/VideoBackends/D3D/D3DShader.cpp @@ -54,7 +54,7 @@ bool CompileVertexShader(const std::string& code, D3DBlob** blob) std::string filename = StringFromFormat("%sbad_vs_%04i.txt", File::GetUserPath(D_DUMP_IDX).c_str(), num_failures++); std::ofstream file; - OpenFStream(file, filename, std::ios_base::out); + File::OpenFStream(file, filename, std::ios_base::out); file << code; file.close(); @@ -112,7 +112,7 @@ bool CompileGeometryShader(const std::string& code, D3DBlob** blob, std::string filename = StringFromFormat("%sbad_gs_%04i.txt", File::GetUserPath(D_DUMP_IDX).c_str(), num_failures++); std::ofstream file; - OpenFStream(file, filename, std::ios_base::out); + File::OpenFStream(file, filename, std::ios_base::out); file << code; file.close(); @@ -169,7 +169,7 @@ bool CompilePixelShader(const std::string& code, D3DBlob** blob, const D3D_SHADE std::string filename = StringFromFormat("%sbad_ps_%04i.txt", File::GetUserPath(D_DUMP_IDX).c_str(), num_failures++); std::ofstream file; - OpenFStream(file, filename, std::ios_base::out); + File::OpenFStream(file, filename, std::ios_base::out); file << code; file.close(); diff --git a/Source/Core/VideoBackends/D3D/Render.cpp b/Source/Core/VideoBackends/D3D/Render.cpp index 1bf9270db5..3fef05973b 100644 --- a/Source/Core/VideoBackends/D3D/Render.cpp +++ b/Source/Core/VideoBackends/D3D/Render.cpp @@ -15,7 +15,6 @@ #include #include "Common/CommonTypes.h" -#include "Common/FileUtil.h" #include "Common/Logging/Log.h" #include "Common/MathUtil.h" diff --git a/Source/Core/VideoBackends/OGL/ProgramShaderCache.cpp b/Source/Core/VideoBackends/OGL/ProgramShaderCache.cpp index 3d4aeea2fc..44027314b7 100644 --- a/Source/Core/VideoBackends/OGL/ProgramShaderCache.cpp +++ b/Source/Core/VideoBackends/OGL/ProgramShaderCache.cpp @@ -9,6 +9,7 @@ #include "Common/Align.h" #include "Common/CommonTypes.h" +#include "Common/FileUtil.h" #include "Common/Logging/Log.h" #include "Common/MsgHandler.h" #include "Common/StringUtil.h" @@ -309,7 +310,7 @@ bool ProgramShaderCache::CompileShader(SHADER& shader, const std::string& vcode, std::string filename = StringFromFormat("%sbad_p_%d.txt", File::GetUserPath(D_DUMP_IDX).c_str(), num_failures++); std::ofstream file; - OpenFStream(file, filename, std::ios_base::out); + File::OpenFStream(file, filename, std::ios_base::out); file << s_glsl_header << vcode << s_glsl_header << pcode; if (!gcode.empty()) file << s_glsl_header << gcode; @@ -380,7 +381,7 @@ bool ProgramShaderCache::CompileComputeShader(SHADER& shader, const std::string& std::string filename = StringFromFormat("%sbad_p_%d.txt", File::GetUserPath(D_DUMP_IDX).c_str(), num_failures++); std::ofstream file; - OpenFStream(file, filename, std::ios_base::out); + File::OpenFStream(file, filename, std::ios_base::out); file << s_glsl_header << code; file << info_log; file.close(); @@ -447,7 +448,7 @@ GLuint ProgramShaderCache::CompileSingleShader(GLuint type, const std::string& c std::string filename = StringFromFormat( "%sbad_%s_%04i.txt", File::GetUserPath(D_DUMP_IDX).c_str(), prefix, num_failures++); std::ofstream file; - OpenFStream(file, filename, std::ios_base::out); + File::OpenFStream(file, filename, std::ios_base::out); file << s_glsl_header << code << info_log; file.close(); diff --git a/Source/Core/VideoBackends/OGL/Render.cpp b/Source/Core/VideoBackends/OGL/Render.cpp index 2c7665f134..cd160705f7 100644 --- a/Source/Core/VideoBackends/OGL/Render.cpp +++ b/Source/Core/VideoBackends/OGL/Render.cpp @@ -15,7 +15,6 @@ #include "Common/Atomic.h" #include "Common/CommonTypes.h" -#include "Common/FileUtil.h" #include "Common/GL/GLInterfaceBase.h" #include "Common/GL/GLUtil.h" #include "Common/Logging/LogManager.h" diff --git a/Source/Core/VideoBackends/OGL/VertexManager.cpp b/Source/Core/VideoBackends/OGL/VertexManager.cpp index 58d7b19ad9..eb7ce04c92 100644 --- a/Source/Core/VideoBackends/OGL/VertexManager.cpp +++ b/Source/Core/VideoBackends/OGL/VertexManager.cpp @@ -179,13 +179,13 @@ void VertexManager::vFlush() std::string filename = StringFromFormat( "%sps%.3d.txt", File::GetUserPath(D_DUMPFRAMES_IDX).c_str(), g_ActiveConfig.iSaveTargetId); std::ofstream fps; - OpenFStream(fps, filename, std::ios_base::out); + File::OpenFStream(fps, filename, std::ios_base::out); fps << prog.shader.strpprog; filename = StringFromFormat("%svs%.3d.txt", File::GetUserPath(D_DUMPFRAMES_IDX).c_str(), g_ActiveConfig.iSaveTargetId); std::ofstream fvs; - OpenFStream(fvs, filename, std::ios_base::out); + File::OpenFStream(fvs, filename, std::ios_base::out); fvs << prog.shader.strvprog; } #endif diff --git a/Source/Core/VideoBackends/Vulkan/ShaderCompiler.cpp b/Source/Core/VideoBackends/Vulkan/ShaderCompiler.cpp index d4d095bb78..75bf99a3ba 100644 --- a/Source/Core/VideoBackends/Vulkan/ShaderCompiler.cpp +++ b/Source/Core/VideoBackends/Vulkan/ShaderCompiler.cpp @@ -131,7 +131,7 @@ bool CompileShaderToSPV(SPIRVCodeVector* out_code, EShLanguage stage, const char "%sbad_%s_%04i.txt", File::GetUserPath(D_DUMP_IDX).c_str(), stage_filename, counter++); std::ofstream stream; - OpenFStream(stream, filename, std::ios_base::out); + File::OpenFStream(stream, filename, std::ios_base::out); if (stream.good()) { stream << full_source_code << std::endl; @@ -199,7 +199,7 @@ bool CompileShaderToSPV(SPIRVCodeVector* out_code, EShLanguage stage, const char stage_filename, counter++); std::ofstream stream; - OpenFStream(stream, filename, std::ios_base::out); + File::OpenFStream(stream, filename, std::ios_base::out); if (stream.good()) { stream << full_source_code << std::endl; diff --git a/Source/Core/VideoCommon/HiresTextures.cpp b/Source/Core/VideoCommon/HiresTextures.cpp index 654530dc20..95a70efc59 100644 --- a/Source/Core/VideoCommon/HiresTextures.cpp +++ b/Source/Core/VideoCommon/HiresTextures.cpp @@ -17,6 +17,7 @@ #include #include +#include "Common/File.h" #include "Common/FileSearch.h" #include "Common/FileUtil.h" #include "Common/Flag.h" diff --git a/Source/Core/VideoCommon/HiresTextures_DDSLoader.cpp b/Source/Core/VideoCommon/HiresTextures_DDSLoader.cpp index d58d699a56..27af3b6828 100644 --- a/Source/Core/VideoCommon/HiresTextures_DDSLoader.cpp +++ b/Source/Core/VideoCommon/HiresTextures_DDSLoader.cpp @@ -3,13 +3,15 @@ // Refer to the license.txt file included. #include "VideoCommon/HiresTextures.h" + #include #include #include #include #include + #include "Common/Align.h" -#include "Common/FileUtil.h" +#include "Common/File.h" #include "Common/Swap.h" #include "VideoCommon/VideoConfig.h" diff --git a/Source/Core/VideoCommon/ImageWrite.cpp b/Source/Core/VideoCommon/ImageWrite.cpp index e7930a18c6..585ba5e13b 100644 --- a/Source/Core/VideoCommon/ImageWrite.cpp +++ b/Source/Core/VideoCommon/ImageWrite.cpp @@ -7,6 +7,7 @@ #include #include "Common/CommonTypes.h" +#include "Common/File.h" #include "Common/FileUtil.h" #include "Common/MsgHandler.h" #include "VideoCommon/ImageWrite.h" @@ -15,7 +16,7 @@ bool SaveData(const std::string& filename, const std::string& data) { std::ofstream f; - OpenFStream(f, filename, std::ios::binary); + File::OpenFStream(f, filename, std::ios::binary); f << data; return true;