diff --git a/Utilities/rFile.cpp b/Utilities/rFile.cpp index f4b323a737..9c7b180ae5 100644 --- a/Utilities/rFile.cpp +++ b/Utilities/rFile.cpp @@ -404,11 +404,14 @@ bool rfile_t::open(const std::string& filename, u32 mode) #ifdef _WIN32 DWORD access = 0; - switch (mode & (o_read | o_write)) + switch (mode & (o_read | o_write | o_append)) { case o_read: access |= GENERIC_READ; break; + case o_read | o_append: access |= GENERIC_READ; break; case o_write: access |= GENERIC_WRITE; break; + case o_write | o_append: access |= FILE_APPEND_DATA; break; case o_read | o_write: access |= GENERIC_READ | GENERIC_WRITE; break; + case o_read | o_write | o_append: access |= GENERIC_READ | FILE_APPEND_DATA; break; default: { LOG_ERROR(GENERAL, "rfile_t::open('%s') failed: neither o_read nor o_write specified (0x%x)", filename, mode); @@ -427,7 +430,7 @@ bool rfile_t::open(const std::string& filename, u32 mode) case o_create | o_excl | o_trunc: disp = CREATE_NEW; break; } - if (!disp || (mode & ~(o_read | o_write | o_create | o_trunc | o_excl))) + if (!disp || (mode & ~(o_read | o_write | o_append | o_create | o_trunc | o_excl))) { LOG_ERROR(GENERAL, "rfile_t::open('%s') failed: unknown mode specified (0x%x)", filename, mode); return false; @@ -449,11 +452,12 @@ bool rfile_t::open(const std::string& filename, u32 mode) } } + if (mode & o_append) flags |= O_APPEND; if (mode & o_create) flags |= O_CREAT; if (mode & o_trunc) flags |= O_TRUNC; if (mode & o_excl) flags |= O_EXCL; - if (((mode & o_excl) && !(mode & o_create)) || (mode & ~(o_read | o_write | o_create | o_trunc | o_excl))) + if (((mode & o_excl) && !(mode & o_create)) || (mode & ~(o_read | o_write | o_append | o_create | o_trunc | o_excl))) { LOG_ERROR(GENERAL, "rfile_t::open('%s') failed: unknown mode specified (0x%x)", filename, mode); return false; @@ -538,15 +542,17 @@ bool rfile_t::close() #ifdef _WIN32 if (CloseHandle(fd)) { - fd = INVALID_HANDLE_VALUE; return true; } + + fd = INVALID_HANDLE_VALUE; #else if (!::close(fd)) { - fd = -1; return true; } + + fd = -1; #endif return false; diff --git a/Utilities/rFile.h b/Utilities/rFile.h index bd7ca945c0..41dbaca396 100644 --- a/Utilities/rFile.h +++ b/Utilities/rFile.h @@ -34,9 +34,10 @@ enum rfile_open_mode : u32 { o_read = 1 << 0, o_write = 1 << 1, - o_create = 1 << 2, - o_trunc = 1 << 3, - o_excl = 1 << 4, + o_append = 1 << 2, + o_create = 1 << 3, + o_trunc = 1 << 4, + o_excl = 1 << 5, }; struct rfile_t final diff --git a/rpcs3/Emu/FS/VFS.cpp b/rpcs3/Emu/FS/VFS.cpp index aa2404447b..7e97a997f0 100644 --- a/rpcs3/Emu/FS/VFS.cpp +++ b/rpcs3/Emu/FS/VFS.cpp @@ -7,9 +7,6 @@ #include "Emu/System.h" #include "Utilities/Log.h" -#undef CreateFile -#undef CopyFile - std::vector simplify_path_blocks(const std::string& path) { // fmt::tolower() removed diff --git a/rpcs3/Emu/FS/VFS.h b/rpcs3/Emu/FS/VFS.h index b01cfe102a..c2f2d532df 100644 --- a/rpcs3/Emu/FS/VFS.h +++ b/rpcs3/Emu/FS/VFS.h @@ -45,9 +45,6 @@ struct VFSManagerEntry std::vector simplify_path_blocks(const std::string& path); std::string simplify_path(const std::string& path, bool is_dir, bool is_ps3); -#undef CreateFile -#undef CopyFile - struct VFS { ~VFS(); diff --git a/rpcs3/Emu/SysCalls/Modules/cellAvconfExt.cpp b/rpcs3/Emu/SysCalls/Modules/cellAvconfExt.cpp index 3cf9114e6a..4e51060ee0 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellAvconfExt.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellAvconfExt.cpp @@ -6,15 +6,15 @@ extern Module cellAvconfExt; -int cellVideoOutConvertCursorColor() +s32 cellVideoOutConvertCursorColor() { UNIMPLEMENTED_FUNC(cellAvconfExt); return CELL_OK; } -int cellVideoOutGetScreenSize(u32 videoOut, vm::ptr screenSize) +s32 cellVideoOutGetScreenSize(u32 videoOut, vm::ptr screenSize) { - cellAvconfExt.Warning("cellVideoOutGetScreenSize(videoOut=%d, screenSize_addr=0x%x)", videoOut, screenSize.addr()); + cellAvconfExt.Warning("cellVideoOutGetScreenSize(videoOut=%d, screenSize=*0x%x)", videoOut, screenSize); if (videoOut != CELL_VIDEO_OUT_PRIMARY) { @@ -23,8 +23,8 @@ int cellVideoOutGetScreenSize(u32 videoOut, vm::ptr screenSize) //TODO: Use virtual screen size #ifdef _WIN32 - HDC screen = GetDC(NULL); - float diagonal = roundf(sqrtf((powf(float(GetDeviceCaps(screen, HORZSIZE)), 2) + powf(float(GetDeviceCaps(screen, VERTSIZE)), 2))) * 0.0393f); + //HDC screen = GetDC(NULL); + //float diagonal = roundf(sqrtf((powf(float(GetDeviceCaps(screen, HORZSIZE)), 2) + powf(float(GetDeviceCaps(screen, VERTSIZE)), 2))) * 0.0393f); #else // TODO: Linux implementation, without using wx // float diagonal = roundf(sqrtf((powf(wxGetDisplaySizeMM().GetWidth(), 2) + powf(wxGetDisplaySizeMM().GetHeight(), 2))) * 0.0393f); @@ -32,22 +32,20 @@ int cellVideoOutGetScreenSize(u32 videoOut, vm::ptr screenSize) if (Ini.GS3DTV.GetValue()) { -#ifdef _WIN32 - *screenSize = diagonal; -#endif + *screenSize = 24.0f; return CELL_OK; } return CELL_VIDEO_OUT_ERROR_VALUE_IS_NOT_SET; } -int cellVideoOutGetGamma() +s32 cellVideoOutGetGamma() { UNIMPLEMENTED_FUNC(cellAvconfExt); return CELL_OK; } -int cellVideoOutSetGamma() +s32 cellVideoOutSetGamma() { UNIMPLEMENTED_FUNC(cellAvconfExt); return CELL_OK; diff --git a/rpcs3/Ini.cpp b/rpcs3/Ini.cpp index 609d3c2855..1b1d4d165b 100644 --- a/rpcs3/Ini.cpp +++ b/rpcs3/Ini.cpp @@ -1,6 +1,6 @@ #include "stdafx.h" #include "Utilities/rPlatform.h" -#include "Utilities/StrFmt.h" +#include "Utilities/simpleini/SimpleIni.h" #include "Ini.h" #include @@ -8,6 +8,7 @@ #define DEF_CONFIG_NAME "./rpcs3.ini" +//TODO: make thread safe/remove static singleton CSimpleIniCaseA *getIniFile() { static bool inited = false; @@ -98,7 +99,7 @@ static std::string WindowInfoToString(const WindowInfo& wind) //Ini Ini::Ini() { - m_Config = getIniFile(); + m_config = getIniFile(); } Ini::~Ini() @@ -109,55 +110,55 @@ Ini::~Ini() //TODO: saving the file after each change seems like overkill but that's how wx did it void Ini::Save(const std::string& section, const std::string& key, int value) { - m_Config->SetLongValue(section.c_str(), key.c_str(), value); + static_cast(m_config)->SetLongValue(section.c_str(), key.c_str(), value); saveIniFile(); } void Ini::Save(const std::string& section, const std::string& key, bool value) { - m_Config->SetBoolValue(section.c_str(), key.c_str(), value); + static_cast(m_config)->SetBoolValue(section.c_str(), key.c_str(), value); saveIniFile(); } void Ini::Save(const std::string& section, const std::string& key, std::pair value) { - m_Config->SetValue(section.c_str(), key.c_str(), SizeToString(value).c_str()); + static_cast(m_config)->SetValue(section.c_str(), key.c_str(), SizeToString(value).c_str()); saveIniFile(); } void Ini::Save(const std::string& section, const std::string& key, const std::string& value) { - m_Config->SetValue(section.c_str(), key.c_str(), value.c_str()); + static_cast(m_config)->SetValue(section.c_str(), key.c_str(), value.c_str()); saveIniFile(); } void Ini::Save(const std::string& section, const std::string& key, WindowInfo value) { - m_Config->SetValue(section.c_str(), key.c_str(), WindowInfoToString(value).c_str()); + static_cast(m_config)->SetValue(section.c_str(), key.c_str(), WindowInfoToString(value).c_str()); saveIniFile(); } int Ini::Load(const std::string& section, const std::string& key, const int def_value) { - return m_Config->GetLongValue(section.c_str(), key.c_str(), def_value); + return static_cast(m_config)->GetLongValue(section.c_str(), key.c_str(), def_value); } bool Ini::Load(const std::string& section, const std::string& key, const bool def_value) { - return StringToBool(m_Config->GetValue(section.c_str(), key.c_str(), BoolToString(def_value).c_str())); + return StringToBool(static_cast(m_config)->GetValue(section.c_str(), key.c_str(), BoolToString(def_value).c_str())); } std::pair Ini::Load(const std::string& section, const std::string& key, const std::pair def_value) { - return StringToSize(m_Config->GetValue(section.c_str(), key.c_str(), SizeToString(def_value).c_str())); + return StringToSize(static_cast(m_config)->GetValue(section.c_str(), key.c_str(), SizeToString(def_value).c_str())); } std::string Ini::Load(const std::string& section, const std::string& key, const std::string& def_value) { - return std::string(m_Config->GetValue(section.c_str(), key.c_str(), def_value.c_str())); + return std::string(static_cast(m_config)->GetValue(section.c_str(), key.c_str(), def_value.c_str())); } WindowInfo Ini::Load(const std::string& section, const std::string& key, const WindowInfo& def_value) { - return StringToWindowInfo(m_Config->GetValue(section.c_str(), key.c_str(), WindowInfoToString(def_value).c_str())); + return StringToWindowInfo(static_cast(m_config)->GetValue(section.c_str(), key.c_str(), WindowInfoToString(def_value).c_str())); } diff --git a/rpcs3/Ini.h b/rpcs3/Ini.h index 5f1155489d..19383577e5 100644 --- a/rpcs3/Ini.h +++ b/rpcs3/Ini.h @@ -1,11 +1,5 @@ #pragma once -#include -#include "Utilities/simpleini/SimpleIni.h" - -//TODO: make thread safe/remove static singleton -CSimpleIniCaseA *getIniFile(); - //TODO: move this to the gui module struct WindowInfo { @@ -26,7 +20,7 @@ public: virtual ~Ini(); protected: - CSimpleIniCaseA *m_Config; + void* m_config; Ini();