refactor: refactor old IOHelper.
- move pointer left padding macro into single header file. - move utf8 fopen into single header but not finished. - add testbench for pointer left padding macro. - add system pointer size detector according to new migrated features requested.
This commit is contained in:
35
src/yycc/patch/fopen.cpp
Normal file
35
src/yycc/patch/fopen.cpp
Normal file
@ -0,0 +1,35 @@
|
||||
#include "fopen.hpp"
|
||||
#include "../macro/os_detector.hpp"
|
||||
#include "../string/reinterpret.hpp"
|
||||
|
||||
#if defined(YYCC_OS_WINDOWS)
|
||||
#include "../windows/import_guard_head.hpp"
|
||||
#include <Windows.h>
|
||||
#include "../windows/import_guard_tail.hpp"
|
||||
#endif
|
||||
|
||||
#define REINTERPRET ::yycc::string::reinterpret
|
||||
|
||||
namespace yycc::patch::fopen {
|
||||
|
||||
std::FILE* fopen(const char8_t* u8_filepath, const char8_t* u8_mode) {
|
||||
// TODO: Fix this after finish Windows encoding
|
||||
// #if defined(YYCC_OS_WINDOWS)
|
||||
|
||||
// // convert mode and file path to wchar
|
||||
// std::wstring wmode, wpath;
|
||||
// if (!YYCC::EncodingHelper::UTF8ToWchar(u8_mode, wmode))
|
||||
// return nullptr;
|
||||
// if (!YYCC::EncodingHelper::UTF8ToWchar(u8_filepath, wpath))
|
||||
// return nullptr;
|
||||
|
||||
// // call microsoft specified fopen which support wchar as argument.
|
||||
// return _wfopen(wpath.c_str(), wmode.c_str());
|
||||
|
||||
// #else
|
||||
// return std::fopen(REINTERPRET::as_ordinary(u8_filepath), REINTERPRET::as_ordinary(u8_mode));
|
||||
// #endif
|
||||
return std::fopen(REINTERPRET::as_ordinary(u8_filepath), REINTERPRET::as_ordinary(u8_mode));
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user