• R/O
  • SSH
  • HTTPS

ttssh2: Commit


Commit MetaInfo

Revision9308 (tree)
Time2021-06-13 00:29:49
Authorzmatsuo

Log Message

wfopen_s() を layer_for_unicode_crt へ移動

Change Summary

Incremental Difference

--- trunk/teraterm/common/fileread.cpp (revision 9307)
+++ trunk/teraterm/common/fileread.cpp (revision 9308)
@@ -37,6 +37,7 @@
3737
3838 #include "codeconv.h"
3939 #include "ttlib.h"
40+#include "layer_for_unicode_crt.h"
4041
4142 #include "fileread.h"
4243
@@ -44,25 +45,6 @@
4445 typedef unsigned char uint8_t;
4546 #endif
4647
47-static void __wfopen_s(FILE **fp, wchar_t const* filename, wchar_t const* mode)
48-{
49- if (IsWindowsNTKernel()) {
50- // 多分内部で CreateFileW() を使用している
51- // NTでのみ使用する
52- _wfopen_s(fp, filename, mode);
53- if (fp != NULL) {
54- return;
55- }
56- // 念の為 ANSI でもオープンする
57- }
58- // ANSI でオープン
59- char *filenameA = ToCharW(filename);
60- char *modeA = ToCharW(mode);
61- fopen_s(fp, filenameA, modeA);
62- free(filenameA);
63- free(modeA);
64-}
65-
6648 /**
6749 * ファイルをメモリに読み込む
6850 * @param[out] *_len サイズ(terminater含む)
--- trunk/teraterm/common/layer_for_unicode_crt.cpp (revision 9307)
+++ trunk/teraterm/common/layer_for_unicode_crt.cpp (revision 9308)
@@ -29,12 +29,12 @@
2929 #include <stdlib.h>
3030
3131 #include "codeconv.h"
32+#include "ttlib.h"
3233
3334 #include "layer_for_unicode_crt.h"
3435
3536 /**
36- * fopen の wchar_t, char 両対応版
37- * TODO __wfopen_s()#fileread.cpp もこのファイルに移動する
37+ * fopen の wchar_t版
3838 */
3939 FILE *__wfopen(const wchar_t *fname, const wchar_t *mode)
4040 {
@@ -49,3 +49,22 @@
4949 free(modeA);
5050 return fp;
5151 }
52+
53+void __wfopen_s(FILE **fp, wchar_t const* filename, wchar_t const* mode)
54+{
55+ if (IsWindowsNTKernel()) {
56+ // 多分内部で CreateFileW() を使用している
57+ // NTでのみ使用する
58+ _wfopen_s(fp, filename, mode);
59+ if (fp != NULL) {
60+ return;
61+ }
62+ // 念の為 ANSI でもオープンする
63+ }
64+ // ANSI でオープン
65+ char *filenameA = ToCharW(filename);
66+ char *modeA = ToCharW(mode);
67+ fopen_s(fp, filenameA, modeA);
68+ free(filenameA);
69+ free(modeA);
70+}
--- trunk/teraterm/common/layer_for_unicode_crt.h (revision 9307)
+++ trunk/teraterm/common/layer_for_unicode_crt.h (revision 9308)
@@ -35,6 +35,7 @@
3535 #endif
3636
3737 FILE *__wfopen(const wchar_t *fname, const wchar_t *mode);
38+void __wfopen_s(FILE **fp, wchar_t const* filename, wchar_t const* mode);
3839
3940 #ifdef __cplusplus
4041 }
Show on old repository browser