Revision: 9616 https://osdn.net/projects/ttssh2/scm/svn/commits/9616 Author: zmatsuo Date: 2021-12-23 22:18:48 +0900 (Thu, 23 Dec 2021) Log Message: ----------- DoesFolderExistW() 追加 - DoesFolderExist() は DoesFolderExistW() を利用するよう修正 - GetFSize() は GetFSize64A() を利用するよう修正 Modified Paths: -------------- trunk/teraterm/common/ttlib.c trunk/teraterm/common/ttlib.h -------------- next part -------------- Modified: trunk/teraterm/common/ttlib.c =================================================================== --- trunk/teraterm/common/ttlib.c 2021-12-23 13:18:38 UTC (rev 9615) +++ trunk/teraterm/common/ttlib.c 2021-12-23 13:18:48 UTC (rev 9616) @@ -464,35 +464,36 @@ return (_stat(FName,&st)==0); } -BOOL DoesFolderExist(const char *FName) +/** + * check if a folder exists or not + * \x83}\x83N\x83\x8D\x8C݊\xB7\x90\xAB\x82̂\xBD\x82\xDF + * DoesFileExist() \x82͏]\x97\x88\x92ʂ\xE8\x83t\x83H\x83\x8B\x83_\x82܂\xBD\x82̓t\x83@\x83C\x83\x8B\x82\xAA\x82\xA0\x82\xEA\x82\xCE TRUE \x82\xF0\x95Ԃ\xB5 + * DoesFolderExist() \x82̓t\x83H\x83\x8B\x83_\x82\xAA\x82\xA0\x82\xE9\x8Fꍇ\x82̂\xDD TRUE \x82\xF0\x95Ԃ\xB7\x81B + */ +BOOL DoesFolderExistW(const wchar_t *FName) { - // check if a folder exists or not - // \x83}\x83N\x83\x8D\x8C݊\xB7\x90\xAB\x82̂\xBD\x82\xDF - // DoesFileExist \x82͏]\x97\x88\x92ʂ\xE8\x83t\x83H\x83\x8B\x83_\x82܂\xBD\x82̓t\x83@\x83C\x83\x8B\x82\xAA\x82\xA0\x82\xEA\x82\xCE TRUE \x82\xF0\x95Ԃ\xB5 - // DoesFileExist \x82̓t\x83H\x83\x8B\x83_\x82\xAA\x82\xA0\x82\xE9\x8Fꍇ\x82̂\xDD TRUE \x82\xF0\x95Ԃ\xB7\x81B - struct _stat st; - - if (_stat(FName,&st)==0) { - if ((st.st_mode & _S_IFDIR) > 0) { - return TRUE; - } - else { - return FALSE; - } - } - else { + const DWORD r = GetFileAttributesW(FName); + if (r == INVALID_FILE_ATTRIBUTES) { return FALSE; } + if (r & FILE_ATTRIBUTE_DIRECTORY) { + return TRUE; + } + return FALSE; } +BOOL DoesFolderExist(const char *FName) +{ + wchar_t *FNameW = ToWcharA(FName); + BOOL r = DoesFolderExistW(FNameW); + free(FNameW); + return r; +} + long GetFSize(const char *FName) { - struct _stat st; - - if (_stat(FName,&st)==-1) { - return 0; - } - return (long)st.st_size; + unsigned long long size = GetFSize64A(FName); + return (long)size; } long GetFMtime(const char *FName) Modified: trunk/teraterm/common/ttlib.h =================================================================== --- trunk/teraterm/common/ttlib.h 2021-12-23 13:18:38 UTC (rev 9615) +++ trunk/teraterm/common/ttlib.h 2021-12-23 13:18:48 UTC (rev 9616) @@ -64,6 +64,7 @@ int Hex2StrW(const wchar_t *Hex, wchar_t *Str, size_t MaxLen); BOOL DoesFileExist(const char *FName); BOOL DoesFolderExist(const char *FName); +BOOL DoesFolderExistW(const wchar_t *FName); long GetFSize(const char *FName); unsigned long long GetFSize64H(HANDLE hFile); unsigned long long GetFSize64W(const wchar_t *FName);