Index: src/libchcore/IFilesystemFile.h =================================================================== diff -u -r27a43e40952cf2f3e0bb0e608a8f3142042ceb46 -r41383599835bbab64d854eed179a7db21a59c6bf --- src/libchcore/IFilesystemFile.h (.../IFilesystemFile.h) (revision 27a43e40952cf2f3e0bb0e608a8f3142042ceb46) +++ src/libchcore/IFilesystemFile.h (.../IFilesystemFile.h) (revision 41383599835bbab64d854eed179a7db21a59c6bf) @@ -26,6 +26,8 @@ namespace chcore { + class TFileInfo; + class LIBCHCORE_API IFilesystemFile { public: @@ -46,6 +48,7 @@ virtual bool IsOpen() const = 0; virtual file_size_t GetFileSize() const = 0; + virtual void GetFileInfo(TFileInfo& tFileInfo) const = 0; virtual void Close() = 0; Index: src/libchcore/TFakeFilesystemFile.cpp =================================================================== diff -u -r24d1cbf231e28e8c3fe3bce41365175f4cecdac9 -r41383599835bbab64d854eed179a7db21a59c6bf --- src/libchcore/TFakeFilesystemFile.cpp (.../TFakeFilesystemFile.cpp) (revision 24d1cbf231e28e8c3fe3bce41365175f4cecdac9) +++ src/libchcore/TFakeFilesystemFile.cpp (.../TFakeFilesystemFile.cpp) (revision 41383599835bbab64d854eed179a7db21a59c6bf) @@ -282,4 +282,13 @@ } } } + + void TFakeFilesystemFile::GetFileInfo(TFileInfo& tFileInfo) const + { + TFakeFileDescriptionPtr spFileDesc = m_pFilesystem->FindFileByLocation(m_pathFile); + if (!spFileDesc) + THROW_FILE_EXCEPTION(eErr_CannotGetFileInfo, ERROR_FILE_INVALID, m_pathFile, L"Cannot retrieve file info - file does not exist"); + + tFileInfo = spFileDesc->GetFileInfo(); + } } Index: src/libchcore/TFakeFilesystemFile.h =================================================================== diff -u -r27a43e40952cf2f3e0bb0e608a8f3142042ceb46 -r41383599835bbab64d854eed179a7db21a59c6bf --- src/libchcore/TFakeFilesystemFile.h (.../TFakeFilesystemFile.h) (revision 27a43e40952cf2f3e0bb0e608a8f3142042ceb46) +++ src/libchcore/TFakeFilesystemFile.h (.../TFakeFilesystemFile.h) (revision 41383599835bbab64d854eed179a7db21a59c6bf) @@ -43,6 +43,8 @@ virtual void FinalizeFile(TOverlappedDataBuffer& rBuffer) override; virtual bool IsOpen() const override; virtual unsigned long long GetFileSize() const override; + virtual void GetFileInfo(TFileInfo& tFileInfo) const override; + virtual void Close() override; virtual TSmartPath GetFilePath() const override; Index: src/libchcore/TFilesystemFileFeedbackWrapper.cpp =================================================================== diff -u -r6eefe6212611518e13af7771d406612c0a7a2bed -r41383599835bbab64d854eed179a7db21a59c6bf --- src/libchcore/TFilesystemFileFeedbackWrapper.cpp (.../TFilesystemFileFeedbackWrapper.cpp) (revision 6eefe6212611518e13af7771d406612c0a7a2bed) +++ src/libchcore/TFilesystemFileFeedbackWrapper.cpp (.../TFilesystemFileFeedbackWrapper.cpp) (revision 41383599835bbab64d854eed179a7db21a59c6bf) @@ -24,9 +24,8 @@ namespace chcore { - TFilesystemFileFeedbackWrapper::TFilesystemFileFeedbackWrapper(const IFeedbackHandlerPtr& spFeedbackHandler, const IFilesystemPtr& spFilesystem, icpf::log_file& rLog) : + TFilesystemFileFeedbackWrapper::TFilesystemFileFeedbackWrapper(const IFeedbackHandlerPtr& spFeedbackHandler, icpf::log_file& rLog) : m_spFeedbackHandler(spFeedbackHandler), - m_spFilesystem(spFilesystem), m_rLog(rLog) { } @@ -193,11 +192,8 @@ return TSubTaskBase::eSubResult_Continue; // read info about the existing destination file, - // NOTE: it is not known which one would be faster - reading file parameters - // by using spDstFileInfo->Create() (which uses FindFirstFile()) or by - // reading parameters using opened handle; need to be tested in the future TFileInfoPtr spDstFileInfo(boost::make_shared()); - m_spFilesystem->GetFileInfo(fileDst->GetFilePath(), spDstFileInfo); + fileDst->GetFileInfo(*spDstFileInfo); // src and dst files are the same EFeedbackResult frResult = m_spFeedbackHandler->FileAlreadyExists(spSrcFileInfo, spDstFileInfo); Index: src/libchcore/TFilesystemFileFeedbackWrapper.h =================================================================== diff -u -r6eefe6212611518e13af7771d406612c0a7a2bed -r41383599835bbab64d854eed179a7db21a59c6bf --- src/libchcore/TFilesystemFileFeedbackWrapper.h (.../TFilesystemFileFeedbackWrapper.h) (revision 6eefe6212611518e13af7771d406612c0a7a2bed) +++ src/libchcore/TFilesystemFileFeedbackWrapper.h (.../TFilesystemFileFeedbackWrapper.h) (revision 41383599835bbab64d854eed179a7db21a59c6bf) @@ -31,7 +31,7 @@ class TFilesystemFileFeedbackWrapper { public: - TFilesystemFileFeedbackWrapper(const IFeedbackHandlerPtr& spFeedbackHandler, const IFilesystemPtr& spFilesystem, icpf::log_file& rLog); + TFilesystemFileFeedbackWrapper(const IFeedbackHandlerPtr& spFeedbackHandler, icpf::log_file& rLog); TSubTaskBase::ESubOperationResult OpenSourceFileFB(const IFilesystemFilePtr& fileSrc); TSubTaskBase::ESubOperationResult OpenExistingDestinationFileFB(const IFilesystemFilePtr& fileDst); Index: src/libchcore/TLocalFilesystemFile.cpp =================================================================== diff -u -rf49b990b02af82798b59d35fec2374d23c6bb053 -r41383599835bbab64d854eed179a7db21a59c6bf --- src/libchcore/TLocalFilesystemFile.cpp (.../TLocalFilesystemFile.cpp) (revision f49b990b02af82798b59d35fec2374d23c6bb053) +++ src/libchcore/TLocalFilesystemFile.cpp (.../TLocalFilesystemFile.cpp) (revision 41383599835bbab64d854eed179a7db21a59c6bf) @@ -27,6 +27,7 @@ #include "TLocalFilesystem.h" #include "TCoreWin32Exception.h" #include "TFileException.h" +#include "TFileInfo.h" namespace chcore { @@ -243,6 +244,29 @@ return uli.QuadPart; } + void TLocalFilesystemFile::GetFileInfo(TFileInfo& tFileInfo) const + { + if (!IsOpen()) + THROW_FILE_EXCEPTION(eErr_FileNotOpen, ERROR_INVALID_HANDLE, m_pathFile, L"File not open. Cannot get file info."); + + BY_HANDLE_FILE_INFORMATION bhfi; + + if (!::GetFileInformationByHandle(m_hFile, &bhfi)) + { + DWORD dwLastError = GetLastError(); + THROW_FILE_EXCEPTION(eErr_CannotGetFileInfo, dwLastError, m_pathFile, L"Retrieving file info from handle failed."); + } + + ULARGE_INTEGER uli; + uli.HighPart = bhfi.nFileSizeHigh; + uli.LowPart = bhfi.nFileSizeLow; + + tFileInfo.SetFilePath(m_pathFile); + tFileInfo.SetAttributes(bhfi.dwFileAttributes); + tFileInfo.SetFileTimes(bhfi.ftCreationTime, bhfi.ftLastAccessTime, bhfi.ftLastWriteTime); + tFileInfo.SetLength64(uli.QuadPart); + } + TSmartPath TLocalFilesystemFile::GetFilePath() const { return m_pathFile; Index: src/libchcore/TLocalFilesystemFile.h =================================================================== diff -u -r27a43e40952cf2f3e0bb0e608a8f3142042ceb46 -r41383599835bbab64d854eed179a7db21a59c6bf --- src/libchcore/TLocalFilesystemFile.h (.../TLocalFilesystemFile.h) (revision 27a43e40952cf2f3e0bb0e608a8f3142042ceb46) +++ src/libchcore/TLocalFilesystemFile.h (.../TLocalFilesystemFile.h) (revision 41383599835bbab64d854eed179a7db21a59c6bf) @@ -26,6 +26,8 @@ namespace chcore { + class TFileInfo; + class LIBCHCORE_API TLocalFilesystemFile : public IFilesystemFile { public: @@ -43,6 +45,8 @@ virtual bool IsOpen() const override { return m_hFile != INVALID_HANDLE_VALUE; } virtual file_size_t GetFileSize() const override; + virtual void GetFileInfo(TFileInfo& tFileInfo) const; + virtual TSmartPath GetFilePath() const override; virtual void Close() override; Index: src/libchcore/TSubTaskCopyMove.cpp =================================================================== diff -u -r25722a1d39e5d4bb49c5a60cbee3dda6c02cb193 -r41383599835bbab64d854eed179a7db21a59c6bf --- src/libchcore/TSubTaskCopyMove.cpp (.../TSubTaskCopyMove.cpp) (revision 25722a1d39e5d4bb49c5a60cbee3dda6c02cb193) +++ src/libchcore/TSubTaskCopyMove.cpp (.../TSubTaskCopyMove.cpp) (revision 41383599835bbab64d854eed179a7db21a59c6bf) @@ -281,7 +281,7 @@ const TConfig& rConfig = GetContext().GetConfig(); IFilesystemPtr spFilesystem = GetContext().GetLocalFilesystem(); - TFilesystemFileFeedbackWrapper tFileFBWrapper(spFeedbackHandler, spFilesystem, rLog); + TFilesystemFileFeedbackWrapper tFileFBWrapper(spFeedbackHandler, rLog); TString strFormat; TSubTaskBase::ESubOperationResult eResult = TSubTaskBase::eSubResult_Continue; @@ -613,7 +613,7 @@ } catch (const TFileException&) { - bContinue = true; + bContinue = false; } if (bContinue && spDstFileInfo->GetLength64() != ullProcessedSize)