Revision: 9308 https://osdn.net/projects/ttssh2/scm/svn/commits/9308 Author: zmatsuo Date: 2021-06-13 00:29:49 +0900 (Sun, 13 Jun 2021) Log Message: ----------- __wfopen_s() を layer_for_unicode_crt へ移動 Modified Paths: -------------- trunk/teraterm/common/fileread.cpp trunk/teraterm/common/layer_for_unicode_crt.cpp trunk/teraterm/common/layer_for_unicode_crt.h -------------- next part -------------- Modified: trunk/teraterm/common/fileread.cpp =================================================================== --- trunk/teraterm/common/fileread.cpp 2021-06-12 15:29:41 UTC (rev 9307) +++ trunk/teraterm/common/fileread.cpp 2021-06-12 15:29:49 UTC (rev 9308) @@ -37,6 +37,7 @@ #include "codeconv.h" #include "ttlib.h" +#include "layer_for_unicode_crt.h" #include "fileread.h" @@ -44,25 +45,6 @@ typedef unsigned char uint8_t; #endif -static void __wfopen_s(FILE **fp, wchar_t const* filename, wchar_t const* mode) -{ - if (IsWindowsNTKernel()) { - // \x91\xBD\x95\xAA\x93\xE0\x95\x94\x82\xC5 CreateFileW() \x82\xF0\x8Eg\x97p\x82\xB5\x82Ă\xA2\x82\xE9 - // NT\x82ł̂ݎg\x97p\x82\xB7\x82\xE9 - _wfopen_s(fp, filename, mode); - if (fp != NULL) { - return; - } - // \x94O\x82̈\xD7 ANSI \x82ł\xE0\x83I\x81[\x83v\x83\x93\x82\xB7\x82\xE9 - } - // ANSI \x82ŃI\x81[\x83v\x83\x93 - char *filenameA = ToCharW(filename); - char *modeA = ToCharW(mode); - fopen_s(fp, filenameA, modeA); - free(filenameA); - free(modeA); -} - /** * \x83t\x83@\x83C\x83\x8B\x82\xF0\x83\x81\x83\x82\x83\x8A\x82ɓǂݍ\x9E\x82\xDE * @param[out] *_len \x83T\x83C\x83Y(terminater\x8A܂\xDE) Modified: trunk/teraterm/common/layer_for_unicode_crt.cpp =================================================================== --- trunk/teraterm/common/layer_for_unicode_crt.cpp 2021-06-12 15:29:41 UTC (rev 9307) +++ trunk/teraterm/common/layer_for_unicode_crt.cpp 2021-06-12 15:29:49 UTC (rev 9308) @@ -29,12 +29,12 @@ #include <stdlib.h> #include "codeconv.h" +#include "ttlib.h" #include "layer_for_unicode_crt.h" /** - * fopen \x82\xCC wchar_t, char \x97\xBC\x91Ή\x9E\x94\xC5 - * TODO __wfopen_s()#fileread.cpp \x82\xE0\x82\xB1\x82̃t\x83@\x83C\x83\x8B\x82Ɉړ\xAE\x82\xB7\x82\xE9 + * fopen \x82\xCC wchar_t\x94\xC5 */ FILE *__wfopen(const wchar_t *fname, const wchar_t *mode) { @@ -49,3 +49,22 @@ free(modeA); return fp; } + +void __wfopen_s(FILE **fp, wchar_t const* filename, wchar_t const* mode) +{ + if (IsWindowsNTKernel()) { + // \x91\xBD\x95\xAA\x93\xE0\x95\x94\x82\xC5 CreateFileW() \x82\xF0\x8Eg\x97p\x82\xB5\x82Ă\xA2\x82\xE9 + // NT\x82ł̂ݎg\x97p\x82\xB7\x82\xE9 + _wfopen_s(fp, filename, mode); + if (fp != NULL) { + return; + } + // \x94O\x82̈\xD7 ANSI \x82ł\xE0\x83I\x81[\x83v\x83\x93\x82\xB7\x82\xE9 + } + // ANSI \x82ŃI\x81[\x83v\x83\x93 + char *filenameA = ToCharW(filename); + char *modeA = ToCharW(mode); + fopen_s(fp, filenameA, modeA); + free(filenameA); + free(modeA); +} Modified: trunk/teraterm/common/layer_for_unicode_crt.h =================================================================== --- trunk/teraterm/common/layer_for_unicode_crt.h 2021-06-12 15:29:41 UTC (rev 9307) +++ trunk/teraterm/common/layer_for_unicode_crt.h 2021-06-12 15:29:49 UTC (rev 9308) @@ -35,6 +35,7 @@ #endif FILE *__wfopen(const wchar_t *fname, const wchar_t *mode); +void __wfopen_s(FILE **fp, wchar_t const* filename, wchar_t const* mode); #ifdef __cplusplus }