mirror of
https://github.com/citra-emu/citra.git
synced 2024-11-25 09:20:18 +00:00
Remove unnecessary code,using secure API
Signed-off-by: yami-hack <yami-hack@foxmail.com>
This commit is contained in:
parent
4f09c3f915
commit
1bad6bc4a2
@ -72,6 +72,10 @@ if (NOT MSVC)
|
|||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -msse4.1")
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -msse4.1")
|
||||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -msse4.1")
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -msse4.1")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
if (MINGW)
|
||||||
|
add_definitions(-DMINGW_HAS_SECURE_API)
|
||||||
|
endif()
|
||||||
else()
|
else()
|
||||||
# Silence "deprecation" warnings
|
# Silence "deprecation" warnings
|
||||||
add_definitions(/D_CRT_SECURE_NO_WARNINGS /D_CRT_NONSTDC_NO_DEPRECATE /D_SCL_SECURE_NO_WARNINGS)
|
add_definitions(/D_CRT_SECURE_NO_WARNINGS /D_CRT_NONSTDC_NO_DEPRECATE /D_SCL_SECURE_NO_WARNINGS)
|
||||||
|
@ -9,7 +9,6 @@
|
|||||||
#include "common/logging/log.h"
|
#include "common/logging/log.h"
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
#include <share.h>
|
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include <shlobj.h> // for SHGetFolderPath
|
#include <shlobj.h> // for SHGetFolderPath
|
||||||
#include <shellapi.h>
|
#include <shellapi.h>
|
||||||
@ -928,11 +927,7 @@ bool IOFile::Open(const std::string& filename, const char openmode[])
|
|||||||
{
|
{
|
||||||
Close();
|
Close();
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
#if defined(__MINGW64__) && !defined(MINGW_HAS_SECURE_API)
|
|
||||||
m_file = _wfsopen(Common::UTF8ToUTF16W(filename).c_str(), Common::UTF8ToUTF16W(openmode).c_str(), SH_DENYNO);
|
|
||||||
#else
|
|
||||||
_wfopen_s(&m_file, Common::UTF8ToUTF16W(filename).c_str(), Common::UTF8ToUTF16W(openmode).c_str());
|
_wfopen_s(&m_file, Common::UTF8ToUTF16W(filename).c_str(), Common::UTF8ToUTF16W(openmode).c_str());
|
||||||
#endif
|
|
||||||
#else
|
#else
|
||||||
m_file = fopen(filename.c_str(), openmode);
|
m_file = fopen(filename.c_str(), openmode);
|
||||||
#endif
|
#endif
|
||||||
@ -985,16 +980,10 @@ bool IOFile::Flush()
|
|||||||
bool IOFile::Resize(u64 size)
|
bool IOFile::Resize(u64 size)
|
||||||
{
|
{
|
||||||
if (!IsOpen() || 0 !=
|
if (!IsOpen() || 0 !=
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
#if defined(__MINGW64__) && !defined(MINGW_HAS_SECURE_API)
|
|
||||||
//TDM-GCC64 does not supports _chsize_s ?in <io_s.h>
|
|
||||||
_chsize(_fileno(m_file), size)
|
|
||||||
#else
|
|
||||||
// ector: _chsize sucks, not 64-bit safe
|
// ector: _chsize sucks, not 64-bit safe
|
||||||
// F|RES: changed to _chsize_s. i think it is 64-bit safe
|
// F|RES: changed to _chsize_s. i think it is 64-bit safe
|
||||||
_chsize_s(_fileno(m_file), size)
|
_chsize_s(_fileno(m_file), size)
|
||||||
#endif
|
|
||||||
#else
|
#else
|
||||||
// TODO: handle 64bit and growing
|
// TODO: handle 64bit and growing
|
||||||
ftruncate(fileno(m_file), size)
|
ftruncate(fileno(m_file), size)
|
||||||
|
@ -52,7 +52,7 @@ bool CharArrayFromFormatV(char* out, int outsize, const char* format, va_list ar
|
|||||||
{
|
{
|
||||||
int writtenCount;
|
int writtenCount;
|
||||||
|
|
||||||
#if defined(_MSC_VER)
|
#ifdef _MSC_VER
|
||||||
// You would think *printf are simple, right? Iterate on each character,
|
// You would think *printf are simple, right? Iterate on each character,
|
||||||
// if it's a format specifier handle it properly, etc.
|
// if it's a format specifier handle it properly, etc.
|
||||||
//
|
//
|
||||||
@ -296,7 +296,7 @@ std::string ReplaceAll(std::string result, const std::string& src, const std::st
|
|||||||
|
|
||||||
std::string UTF16ToUTF8(const std::u16string& input)
|
std::string UTF16ToUTF8(const std::u16string& input)
|
||||||
{
|
{
|
||||||
#if _MSC_VER >= 1900 || defined(__MINGW64__)
|
#if _MSC_VER >= 1900
|
||||||
// Workaround for missing char16_t/char32_t instantiations in MSVC2015
|
// Workaround for missing char16_t/char32_t instantiations in MSVC2015
|
||||||
std::wstring_convert<std::codecvt_utf8_utf16<__int16>, __int16> convert;
|
std::wstring_convert<std::codecvt_utf8_utf16<__int16>, __int16> convert;
|
||||||
std::basic_string<__int16> tmp_buffer(input.cbegin(), input.cend());
|
std::basic_string<__int16> tmp_buffer(input.cbegin(), input.cend());
|
||||||
@ -309,7 +309,7 @@ std::string UTF16ToUTF8(const std::u16string& input)
|
|||||||
|
|
||||||
std::u16string UTF8ToUTF16(const std::string& input)
|
std::u16string UTF8ToUTF16(const std::string& input)
|
||||||
{
|
{
|
||||||
#if _MSC_VER >= 1900 || defined(__MINGW64__)
|
#if _MSC_VER >= 1900
|
||||||
// Workaround for missing char16_t/char32_t instantiations in MSVC2015
|
// Workaround for missing char16_t/char32_t instantiations in MSVC2015
|
||||||
std::wstring_convert<std::codecvt_utf8_utf16<__int16>, __int16> convert;
|
std::wstring_convert<std::codecvt_utf8_utf16<__int16>, __int16> convert;
|
||||||
auto tmp_buffer = convert.from_bytes(input);
|
auto tmp_buffer = convert.from_bytes(input);
|
||||||
|
Loading…
Reference in New Issue
Block a user