#pragma once #pragma warning(disable : 4996) #include #include #include #include #include namespace Jenga{ namespace Common{ class File { const std::string filePath; public: File( const std::string &filePath ) : filePath( filePath ) { } std::string Read() { HANDLE hFile = CreateFile( filePath.c_str(), GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL ); if( hFile == INVALID_HANDLE_VALUE ) { Jenga::Throw( filePath + " がオープンできません" ); } int size = GetFileSize( hFile, NULL ); char *temp = static_cast(calloc( size + 1, 1 )); DWORD dummy; ReadFile( hFile, temp, size, &dummy, NULL ); CloseHandle(hFile); std::string result = temp; free( temp ); return result; } }; }}