MFC64bitFix.cpp 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. //---------------------------------------------------------------------------
  2. #include "FileZillaPCH.h"
  3. __int64 GetLength64(CFile &file)
  4. {
  5. DWORD low;
  6. DWORD high;
  7. low=GetFileSize((void *)file.m_hFile, &high);
  8. _int64 size=((_int64)high<<32)+low;
  9. return size;
  10. }
  11. BOOL GetLength64(CString filename, _int64 &size)
  12. {
  13. WIN32_FIND_DATA findFileData;
  14. HANDLE hFind = FindFirstFile(filename, &findFileData);
  15. if (hFind == INVALID_HANDLE_VALUE)
  16. return FALSE;
  17. DebugCheck(FindClose(hFind));
  18. size=((_int64)findFileData.nFileSizeHigh<<32)+findFileData.nFileSizeLow;
  19. return TRUE;
  20. }
  21. BOOL PASCAL GetFileStatus(LPCTSTR lpszFileName, CFileStatus& rStatus)
  22. {
  23. WIN32_FIND_DATA findFileData;
  24. HANDLE hFind = FindFirstFile((LPTSTR)lpszFileName, &findFileData);
  25. if (hFind == INVALID_HANDLE_VALUE)
  26. {
  27. return FALSE;
  28. }
  29. DebugCheck(FindClose(hFind));
  30. // strip attribute of NORMAL bit, our API doesn't have a "normal" bit.
  31. rStatus.m_attribute = (BYTE)
  32. (findFileData.dwFileAttributes & ~FILE_ATTRIBUTE_NORMAL);
  33. // convert times as appropriate
  34. rStatus.m_mtime = CTime(findFileData.ftLastWriteTime);
  35. if (rStatus.m_mtime.GetTime() == 0)
  36. {
  37. rStatus.m_mtime = CTime(findFileData.ftCreationTime);
  38. }
  39. return TRUE;
  40. }