Revision: 8956 https://osdn.net/projects/ttssh2/scm/svn/commits/8956 Author: zmatsuo Date: 2020-10-12 01:08:07 +0900 (Mon, 12 Oct 2020) Log Message: ----------- GetFSize64H(), GetFSize64W(), GetFSize64A() 追加 Modified Paths: -------------- trunk/teraterm/common/ttlib.h trunk/teraterm/common/ttlib_static_cpp.cpp -------------- next part -------------- Modified: trunk/teraterm/common/ttlib.h =================================================================== --- trunk/teraterm/common/ttlib.h 2020-10-05 14:48:47 UTC (rev 8955) +++ trunk/teraterm/common/ttlib.h 2020-10-11 16:08:07 UTC (rev 8956) @@ -53,6 +53,9 @@ BOOL DoesFileExist(PCHAR FName); BOOL DoesFolderExist(PCHAR FName); long GetFSize(PCHAR FName); +unsigned long long GetFSize64H(HANDLE hFile); +unsigned long long GetFSize64W(const wchar_t *FName); +unsigned long long GetFSize64A(const char *FName); long GetFMtime(PCHAR FName); BOOL SetFMtime(PCHAR FName, DWORD mtime); void uint2str(UINT i, PCHAR Str, int destlen, int len); Modified: trunk/teraterm/common/ttlib_static_cpp.cpp =================================================================== --- trunk/teraterm/common/ttlib_static_cpp.cpp 2020-10-05 14:48:47 UTC (rev 8955) +++ trunk/teraterm/common/ttlib_static_cpp.cpp 2020-10-11 16:08:07 UTC (rev 8956) @@ -577,3 +577,40 @@ return dest_top; } + +unsigned long long GetFSize64H(HANDLE hFile) +{ + DWORD file_size_hi; + DWORD file_size_low; + file_size_low = GetFileSize(hFile, &file_size_hi); + if (file_size_low == INVALID_FILE_SIZE && GetLastError() != NO_ERROR) { + // error + return 0; + } + unsigned long long file_size = ((unsigned long long)file_size_hi << 32) + file_size_low; + return file_size; +} + +unsigned long long GetFSize64W(const wchar_t *FName) +{ + HANDLE hFile = _CreateFileW(FName, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, + FILE_ATTRIBUTE_NORMAL, NULL); + if (hFile == INVALID_HANDLE_VALUE) { + return 0; + } + unsigned long long file_size = GetFSize64H(hFile); + CloseHandle(hFile); + return file_size; +} + +unsigned long long GetFSize64A(const char *FName) +{ + HANDLE hFile = CreateFileA(FName, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, + FILE_ATTRIBUTE_NORMAL, NULL); + if (hFile == INVALID_HANDLE_VALUE) { + return 0; + } + unsigned long long file_size = GetFSize64H(hFile); + CloseHandle(hFile); + return file_size; +}