#include <sstream>
#include <string>
+void (*file_open_hook)(const std::filesystem::path &path, const FileOpenType ftype) = 0;
+
#ifdef SET_UID
#ifndef HAVE_USLEEP
* @param is_binary バイナリモードか否か (無指定の場合false:テキストモード)
* @return ファイルポインタ
*/
-FILE *angband_fopen(const std::filesystem::path &path, const FileOpenMode mode, const bool is_binary)
+FILE *angband_fopen(const std::filesystem::path &path, const FileOpenMode mode, const bool is_binary, const FileOpenType ftype)
{
+ FILE *result;
+
const auto &parsed_path = path_parse(path);
const auto &open_mode = make_file_mode(mode, is_binary);
- return fopen(parsed_path.string().data(), open_mode.data());
+ result = fopen(parsed_path.string().data(), open_mode.data());
+ if (result && mode != FileOpenMode::READ && file_open_hook) {
+ file_open_hook(path, ftype);
+ }
+ return result;
}
/*
guess_convert_to_system_encoding(file_read__tmp.data(), FILE_READ_BUFF_SIZE);
#endif
for (s = file_read__tmp.data(); *s; s++) {
+#ifdef MACH_O_COCOA
+ /*
+ * Be nice to the Macintosh, where a file can have Mac or Unix
+ * end of line, especially since the introduction of OS X.
+ * MPW tools were also very tolerant to the Unix EOL.
+ */
+ if (*s == '\r') *s = '\n';
+#endif /* MACH_O_COCOA */
if (*s == '\n') {
buf[i] = '\0';
return 0;