mirror of
https://github.com/winscp/winscp.git
synced 2026-10-24 02:28:55 +03:00
49 lines
1.3 KiB
C++
49 lines
1.3 KiB
C++
//---------------------------------------------------------------------------
|
|
#include "FileZillaPCH.h"
|
|
|
|
__int64 GetLength64(CFile &file)
|
|
{
|
|
DWORD low;
|
|
DWORD high;
|
|
low=GetFileSize(file.m_hFile, &high);
|
|
__int64 size=(static_cast<__int64>(high)<<32)+low;
|
|
return size;
|
|
}
|
|
|
|
BOOL GetLength64(CString filename, __int64 &size)
|
|
{
|
|
WIN32_FIND_DATA findFileData;
|
|
HANDLE hFind = FindFirstFile(filename, &findFileData);
|
|
if (hFind == INVALID_HANDLE_VALUE)
|
|
return FALSE;
|
|
DebugCheck(FindClose(hFind));
|
|
|
|
size=(static_cast<__int64>(findFileData.nFileSizeHigh)<<32)+findFileData.nFileSizeLow;
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
BOOL PASCAL GetFileStatus(const wchar_t * lpszFileName, CFileStatus& rStatus)
|
|
{
|
|
WIN32_FIND_DATA findFileData;
|
|
HANDLE hFind = FindFirstFile(lpszFileName, &findFileData);
|
|
if (hFind == INVALID_HANDLE_VALUE)
|
|
{
|
|
return FALSE;
|
|
}
|
|
DebugCheck(FindClose(hFind));
|
|
|
|
// strip attribute of NORMAL bit, our API doesn't have a "normal" bit.
|
|
rStatus.m_attribute = static_cast<BYTE>(findFileData.dwFileAttributes & ~FILE_ATTRIBUTE_NORMAL);
|
|
|
|
// convert times as appropriate
|
|
rStatus.m_mtime = CTime(findFileData.ftLastWriteTime);
|
|
|
|
if (rStatus.m_mtime.GetTime() == 0)
|
|
{
|
|
rStatus.m_mtime = CTime(findFileData.ftCreationTime);
|
|
}
|
|
|
|
return TRUE;
|
|
}
|