mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-22 22:00:39 -06:00
Reformat all the things. Have fun with merge conflicts.
This commit is contained in:
@ -18,55 +18,56 @@
|
||||
#endif
|
||||
|
||||
// User directory indices for GetUserPath
|
||||
enum {
|
||||
D_USER_IDX,
|
||||
D_GCUSER_IDX,
|
||||
D_WIIROOT_IDX, // always points to User/Wii or global user-configured directory
|
||||
D_SESSION_WIIROOT_IDX, // may point to minimal temporary directory for determinism
|
||||
D_CONFIG_IDX, // global settings
|
||||
D_GAMESETTINGS_IDX, // user-specified settings which override both the global and the default settings (per game)
|
||||
D_MAPS_IDX,
|
||||
D_CACHE_IDX,
|
||||
D_SHADERCACHE_IDX,
|
||||
D_SHADERS_IDX,
|
||||
D_STATESAVES_IDX,
|
||||
D_SCREENSHOTS_IDX,
|
||||
D_HIRESTEXTURES_IDX,
|
||||
D_DUMP_IDX,
|
||||
D_DUMPFRAMES_IDX,
|
||||
D_DUMPAUDIO_IDX,
|
||||
D_DUMPTEXTURES_IDX,
|
||||
D_DUMPDSP_IDX,
|
||||
D_LOAD_IDX,
|
||||
D_LOGS_IDX,
|
||||
D_MAILLOGS_IDX,
|
||||
D_THEMES_IDX,
|
||||
D_PIPES_IDX,
|
||||
D_MEMORYWATCHER_IDX,
|
||||
F_DOLPHINCONFIG_IDX,
|
||||
F_DEBUGGERCONFIG_IDX,
|
||||
F_LOGGERCONFIG_IDX,
|
||||
F_MAINLOG_IDX,
|
||||
F_RAMDUMP_IDX,
|
||||
F_ARAMDUMP_IDX,
|
||||
F_FAKEVMEMDUMP_IDX,
|
||||
F_GCSRAM_IDX,
|
||||
F_MEMORYWATCHERLOCATIONS_IDX,
|
||||
F_MEMORYWATCHERSOCKET_IDX,
|
||||
NUM_PATH_INDICES
|
||||
enum
|
||||
{
|
||||
D_USER_IDX,
|
||||
D_GCUSER_IDX,
|
||||
D_WIIROOT_IDX, // always points to User/Wii or global user-configured directory
|
||||
D_SESSION_WIIROOT_IDX, // may point to minimal temporary directory for determinism
|
||||
D_CONFIG_IDX, // global settings
|
||||
D_GAMESETTINGS_IDX, // user-specified settings which override both the global and the default
|
||||
// settings (per game)
|
||||
D_MAPS_IDX,
|
||||
D_CACHE_IDX,
|
||||
D_SHADERCACHE_IDX,
|
||||
D_SHADERS_IDX,
|
||||
D_STATESAVES_IDX,
|
||||
D_SCREENSHOTS_IDX,
|
||||
D_HIRESTEXTURES_IDX,
|
||||
D_DUMP_IDX,
|
||||
D_DUMPFRAMES_IDX,
|
||||
D_DUMPAUDIO_IDX,
|
||||
D_DUMPTEXTURES_IDX,
|
||||
D_DUMPDSP_IDX,
|
||||
D_LOAD_IDX,
|
||||
D_LOGS_IDX,
|
||||
D_MAILLOGS_IDX,
|
||||
D_THEMES_IDX,
|
||||
D_PIPES_IDX,
|
||||
D_MEMORYWATCHER_IDX,
|
||||
F_DOLPHINCONFIG_IDX,
|
||||
F_DEBUGGERCONFIG_IDX,
|
||||
F_LOGGERCONFIG_IDX,
|
||||
F_MAINLOG_IDX,
|
||||
F_RAMDUMP_IDX,
|
||||
F_ARAMDUMP_IDX,
|
||||
F_FAKEVMEMDUMP_IDX,
|
||||
F_GCSRAM_IDX,
|
||||
F_MEMORYWATCHERLOCATIONS_IDX,
|
||||
F_MEMORYWATCHERSOCKET_IDX,
|
||||
NUM_PATH_INDICES
|
||||
};
|
||||
|
||||
namespace File
|
||||
{
|
||||
|
||||
// FileSystem tree node/
|
||||
struct FSTEntry
|
||||
{
|
||||
bool isDirectory;
|
||||
u64 size; // File length, or for directories, recursive count of children
|
||||
std::string physicalName; // Name on disk
|
||||
std::string virtualName; // Name in FST names table
|
||||
std::vector<FSTEntry> children;
|
||||
bool isDirectory;
|
||||
u64 size; // File length, or for directories, recursive count of children
|
||||
std::string physicalName; // Name on disk
|
||||
std::string virtualName; // Name in FST names table
|
||||
std::vector<FSTEntry> children;
|
||||
};
|
||||
|
||||
// Returns true if file filename exists
|
||||
@ -159,78 +160,80 @@ bool ReadFileToString(const std::string& filename, std::string& str);
|
||||
class IOFile : public NonCopyable
|
||||
{
|
||||
public:
|
||||
IOFile();
|
||||
IOFile(std::FILE* file);
|
||||
IOFile(const std::string& filename, const char openmode[]);
|
||||
IOFile();
|
||||
IOFile(std::FILE* file);
|
||||
IOFile(const std::string& filename, const char openmode[]);
|
||||
|
||||
~IOFile();
|
||||
~IOFile();
|
||||
|
||||
IOFile(IOFile&& other);
|
||||
IOFile& operator=(IOFile&& other);
|
||||
IOFile(IOFile&& other);
|
||||
IOFile& operator=(IOFile&& other);
|
||||
|
||||
void Swap(IOFile& other);
|
||||
void Swap(IOFile& other);
|
||||
|
||||
bool Open(const std::string& filename, const char openmode[]);
|
||||
bool Close();
|
||||
bool Open(const std::string& filename, const char openmode[]);
|
||||
bool Close();
|
||||
|
||||
template <typename T>
|
||||
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;
|
||||
template <typename T>
|
||||
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;
|
||||
if (pReadBytes)
|
||||
*pReadBytes = read_bytes;
|
||||
|
||||
return m_good;
|
||||
}
|
||||
return m_good;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
bool WriteArray(const T* data, size_t length)
|
||||
{
|
||||
if (!IsOpen() || length != std::fwrite(data, sizeof(T), length, m_file))
|
||||
m_good = false;
|
||||
template <typename T>
|
||||
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;
|
||||
}
|
||||
return m_good;
|
||||
}
|
||||
|
||||
bool ReadBytes(void* data, size_t length)
|
||||
{
|
||||
return ReadArray(reinterpret_cast<char*>(data), length);
|
||||
}
|
||||
bool ReadBytes(void* data, size_t length)
|
||||
{
|
||||
return ReadArray(reinterpret_cast<char*>(data), length);
|
||||
}
|
||||
|
||||
bool WriteBytes(const void* data, size_t length)
|
||||
{
|
||||
return WriteArray(reinterpret_cast<const char*>(data), length);
|
||||
}
|
||||
bool WriteBytes(const void* data, size_t length)
|
||||
{
|
||||
return WriteArray(reinterpret_cast<const char*>(data), length);
|
||||
}
|
||||
|
||||
bool IsOpen() const { return nullptr != m_file; }
|
||||
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; }
|
||||
operator void*() { return m_good ? m_file : nullptr; }
|
||||
std::FILE* ReleaseHandle();
|
||||
|
||||
// m_good is set to false when a read, write or other function fails
|
||||
bool IsGood() const { return m_good; }
|
||||
operator void*() { return m_good ? m_file : nullptr; }
|
||||
std::FILE* GetHandle() { return m_file; }
|
||||
void SetHandle(std::FILE* file);
|
||||
|
||||
std::FILE* ReleaseHandle();
|
||||
bool Seek(s64 off, int origin);
|
||||
u64 Tell() const;
|
||||
u64 GetSize();
|
||||
bool Resize(u64 size);
|
||||
bool Flush();
|
||||
|
||||
std::FILE* GetHandle() { return m_file; }
|
||||
// clear error state
|
||||
void Clear()
|
||||
{
|
||||
m_good = true;
|
||||
std::clearerr(m_file);
|
||||
}
|
||||
|
||||
void SetHandle(std::FILE* file);
|
||||
std::FILE* m_file;
|
||||
bool m_good;
|
||||
|
||||
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); }
|
||||
|
||||
std::FILE* m_file;
|
||||
bool m_good;
|
||||
private:
|
||||
IOFile(IOFile&);
|
||||
IOFile& operator=(IOFile& other);
|
||||
IOFile(IOFile&);
|
||||
IOFile& operator=(IOFile& other);
|
||||
};
|
||||
|
||||
} // namespace
|
||||
@ -240,8 +243,8 @@ template <typename T>
|
||||
void OpenFStream(T& fstream, const std::string& filename, std::ios_base::openmode openmode)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
fstream.open(UTF8ToTStr(filename).c_str(), openmode);
|
||||
fstream.open(UTF8ToTStr(filename).c_str(), openmode);
|
||||
#else
|
||||
fstream.open(filename.c_str(), openmode);
|
||||
fstream.open(filename.c_str(), openmode);
|
||||
#endif
|
||||
}
|
||||
|
Reference in New Issue
Block a user