Index: src/libchcore/TBasePathData.cpp =================================================================== diff -u -N -rda877d1e0007d3dffa60111c79a1d8927174e6e9 -rf866db90e4b058a4f2e13cc6cf076d1e0bf2d956 --- src/libchcore/TBasePathData.cpp (.../TBasePathData.cpp) (revision da877d1e0007d3dffa60111c79a1d8927174e6e9) +++ src/libchcore/TBasePathData.cpp (.../TBasePathData.cpp) (revision f866db90e4b058a4f2e13cc6cf076d1e0bf2d956) @@ -132,6 +132,7 @@ void TBasePathData::SetSrcPath(const TSmartPath& pathSrc) { m_pathSrc = pathSrc; + m_pathSrc.Modify().StripSeparatorAtEnd(); } object_id_t TBasePathData::GetObjectID() const @@ -293,7 +294,10 @@ for (size_t stIndex = 0; stIndex < tPaths.GetCount(); ++stIndex) { - TBasePathDataPtr spPathData = boost::make_shared(++m_oidLastObjectID, tPaths.GetAt(stIndex)); + TSmartPath path = tPaths.GetAt(stIndex); + path.StripSeparatorAtEnd(); + + TBasePathDataPtr spPathData = boost::make_shared(++m_oidLastObjectID, path); m_vEntries.push_back(spPathData); } Index: src/libchcore/TFileInfo.cpp =================================================================== diff -u -N -rbe569bc86280887eeebb8d3e9489f6fc17c570e6 -rf866db90e4b058a4f2e13cc6cf076d1e0bf2d956 --- src/libchcore/TFileInfo.cpp (.../TFileInfo.cpp) (revision be569bc86280887eeebb8d3e9489f6fc17c570e6) +++ src/libchcore/TFileInfo.cpp (.../TFileInfo.cpp) (revision f866db90e4b058a4f2e13cc6cf076d1e0bf2d956) @@ -59,7 +59,7 @@ { } - TFileInfo::TFileInfo(const TBasePathDataPtr& spBasePathData, const TSmartPath& rpathFile, DWORD dwAttributes, ULONGLONG uhFileSize, FILETIME ftCreation, FILETIME ftLastAccess, FILETIME ftLastWrite, unsigned int uiFlags) : + TFileInfo::TFileInfo(const TBasePathDataPtr& spBasePathData, const TSmartPath& rpathFile, DWORD dwAttributes, ULONGLONG uhFileSize, const TFileTime& ftCreation, const TFileTime& ftLastAccess, const TFileTime& ftLastWrite, unsigned int uiFlags) : m_pathFile(m_setModifications, rpathFile), m_spBasePathData(m_setModifications, spBasePathData), m_dwAttributes(m_setModifications, dwAttributes), @@ -98,7 +98,7 @@ } void TFileInfo::Init(const TBasePathDataPtr& spBasePathData, const TSmartPath& rpathFile, - DWORD dwAttributes, ULONGLONG uhFileSize, FILETIME ftCreation, FILETIME ftLastAccess, FILETIME ftLastWrite, + DWORD dwAttributes, ULONGLONG uhFileSize, const TFileTime& ftCreation, const TFileTime& ftLastAccess, const TFileTime& ftLastWrite, unsigned int uiFlags) { m_pathFile = rpathFile; @@ -114,7 +114,7 @@ m_pathFile.Modify().MakeRelativePath(m_spBasePathData.Get()->GetSrcPath()); } - void TFileInfo::Init(const TSmartPath& rpathFile, DWORD dwAttributes, ULONGLONG uhFileSize, FILETIME ftCreation, FILETIME ftLastAccess, FILETIME ftLastWrite, + void TFileInfo::Init(const TSmartPath& rpathFile, DWORD dwAttributes, ULONGLONG uhFileSize, const TFileTime& ftCreation, const TFileTime& ftLastAccess, const TFileTime& ftLastWrite, unsigned int uiFlags) { m_pathFile = rpathFile; Index: src/libchcore/TFileInfo.h =================================================================== diff -u -N -rbe569bc86280887eeebb8d3e9489f6fc17c570e6 -rf866db90e4b058a4f2e13cc6cf076d1e0bf2d956 --- src/libchcore/TFileInfo.h (.../TFileInfo.h) (revision be569bc86280887eeebb8d3e9489f6fc17c570e6) +++ src/libchcore/TFileInfo.h (.../TFileInfo.h) (revision f866db90e4b058a4f2e13cc6cf076d1e0bf2d956) @@ -44,7 +44,7 @@ TFileInfo(); TFileInfo(const TFileInfo& rSrc); TFileInfo(const TBasePathDataPtr& spBasePathData, const TSmartPath& rpathFile, - DWORD dwAttributes, ULONGLONG uhFileSize, FILETIME ftCreation, FILETIME ftLastAccess, FILETIME ftLastWrite, + DWORD dwAttributes, ULONGLONG uhFileSize, const TFileTime& ftCreation, const TFileTime& ftLastAccess, const TFileTime& ftLastWrite, unsigned int uiFlags); ~TFileInfo(); @@ -55,12 +55,12 @@ // with base path void Init(const TBasePathDataPtr& spBasePathData, const TSmartPath& rpathFile, - DWORD dwAttributes, ULONGLONG uhFileSize, FILETIME ftCreation, FILETIME ftLastAccess, FILETIME ftLastWrite, + DWORD dwAttributes, ULONGLONG uhFileSize, const TFileTime& ftCreation, const TFileTime& ftLastAccess, const TFileTime& ftLastWrite, unsigned int uiFlags); // without base path - void Init(const TSmartPath& rpathFile, DWORD dwAttributes, ULONGLONG uhFileSize, FILETIME ftCreation, - FILETIME ftLastAccess, FILETIME ftLastWrite, unsigned int uiFlags); + void Init(const TSmartPath& rpathFile, DWORD dwAttributes, ULONGLONG uhFileSize, const TFileTime& ftCreation, + const TFileTime& ftLastAccess, const TFileTime& ftLastWrite, unsigned int uiFlags); // unique object id object_id_t GetObjectID() const; Index: src/libchcore/TFileTime.cpp =================================================================== diff -u -N -re96806b7f8ff7ca7e9f4afbea603e6351a3dc3e3 -rf866db90e4b058a4f2e13cc6cf076d1e0bf2d956 --- src/libchcore/TFileTime.cpp (.../TFileTime.cpp) (revision e96806b7f8ff7ca7e9f4afbea603e6351a3dc3e3) +++ src/libchcore/TFileTime.cpp (.../TFileTime.cpp) (revision f866db90e4b058a4f2e13cc6cf076d1e0bf2d956) @@ -86,6 +86,11 @@ return uli.QuadPart; } + void TFileTime::SetCurrentTime() + { + GetSystemTimeAsFileTime(&m_ftTime); + } + const FILETIME& TFileTime::GetAsFiletime() const { return m_ftTime; Index: src/libchcore/TFileTime.h =================================================================== diff -u -N -r5446395d3925e49d3e4cba82044bdfd4dffb6ee9 -rf866db90e4b058a4f2e13cc6cf076d1e0bf2d956 --- src/libchcore/TFileTime.h (.../TFileTime.h) (revision 5446395d3925e49d3e4cba82044bdfd4dffb6ee9) +++ src/libchcore/TFileTime.h (.../TFileTime.h) (revision f866db90e4b058a4f2e13cc6cf076d1e0bf2d956) @@ -38,6 +38,7 @@ bool operator==(const TFileTime& rSrc) const; bool operator!=(const TFileTime& rSrc) const; + void SetCurrentTime(); const FILETIME& GetAsFiletime() const; void FromUInt64(unsigned long long ullTime); Index: src/libchcore/TLocalFilesystem.cpp =================================================================== diff -u -N -rfa8e76fc12b88c7ad1c6bf87ac502ce79c31d0ae -rf866db90e4b058a4f2e13cc6cf076d1e0bf2d956 --- src/libchcore/TLocalFilesystem.cpp (.../TLocalFilesystem.cpp) (revision fa8e76fc12b88c7ad1c6bf87ac502ce79c31d0ae) +++ src/libchcore/TLocalFilesystem.cpp (.../TLocalFilesystem.cpp) (revision f866db90e4b058a4f2e13cc6cf076d1e0bf2d956) @@ -45,6 +45,7 @@ #include #include "TLocalFilesystemFind.h" #include "TFileException.h" +#include "TDateTime.h" namespace chcore { @@ -81,20 +82,17 @@ { WIN32_FIND_DATA fd; - // search by exact name - HANDLE hFind = FindFirstFile(PrependPathExtensionIfNeeded(pathToCheck).ToString(), &fd); - if (hFind != INVALID_HANDLE_VALUE) + TSmartPath findPath = pathToCheck; + bool bIsDrive = pathToCheck.IsDrive() || (pathToCheck.IsDriveWithRootDir()); + + if(bIsDrive) { - FindClose(hFind); - return true; + // add '\\' if needed and '*' for marking that we look for e.g. c:\* + // instead of c:\, which would never be found the other way + findPath.AppendIfNotExists(_T("*"), false); } - // another try (add '\\' if needed and '*' for marking that we look for ie. c:\* - // instead of c:\, which would never be found prev. way) - TSmartPath findPath = pathToCheck; - findPath.AppendIfNotExists(_T("*"), false); - - hFind = FindFirstFile(PrependPathExtensionIfNeeded(findPath).ToString(), &fd); + HANDLE hFind = FindFirstFile(PrependPathExtensionIfNeeded(findPath).ToString(), &fd); if (hFind != INVALID_HANDLE_VALUE) { ::FindClose(hFind); @@ -191,20 +189,39 @@ WIN32_FIND_DATA wfd; - HANDLE hFind = FindFirstFileEx(PrependPathExtensionIfNeeded(pathFile).ToString(), FindExInfoStandard, &wfd, FindExSearchNameMatch, nullptr, 0); + TSmartPath findPath = pathFile; + bool bIsDrive = pathFile.IsDrive() || (pathFile.IsDriveWithRootDir()); + if(bIsDrive) + { + // add '\\' if needed and '*' for marking that we look for e.g. c:\* + // instead of c:\, which would never be found the other way + findPath.AppendIfNotExists(_T("*"), false); + } + + HANDLE hFind = FindFirstFileEx(PrependPathExtensionIfNeeded(findPath).ToString(), FindExInfoStandard, &wfd, FindExSearchNameMatch, nullptr, 0); if (hFind != INVALID_HANDLE_VALUE) { FindClose(hFind); - // new instance of path to accommodate the corrected path (i.e. input path might have lower case names, but we'd like to - // preserve the original case contained in the file system) - TSmartPath pathNew(pathFile); - pathNew.DeleteFileName(); + if(bIsDrive) + { + TFileTime ftTime; + ftTime.SetCurrentTime(); - // copy data from W32_F_D - spFileInfo->Init(spBasePathData, pathNew + PathFromString(wfd.cFileName), - wfd.dwFileAttributes, (((ULONGLONG)wfd.nFileSizeHigh) << 32) + wfd.nFileSizeLow, wfd.ftCreationTime, - wfd.ftLastAccessTime, wfd.ftLastWriteTime, 0); + spFileInfo->Init(spBasePathData, pathFile, FILE_ATTRIBUTE_DIRECTORY, 0, ftTime, ftTime, ftTime, 0); + } + else + { + // new instance of path to accommodate the corrected path (i.e. input path might have lower case names, but we'd like to + // preserve the original case contained in the file system) + TSmartPath pathNew(pathFile); + pathNew.DeleteFileName(); + + // copy data from W32_F_D + spFileInfo->Init(spBasePathData, pathNew + PathFromString(wfd.cFileName), + wfd.dwFileAttributes, (((ULONGLONG)wfd.nFileSizeHigh) << 32) + wfd.nFileSizeLow, wfd.ftCreationTime, + wfd.ftLastAccessTime, wfd.ftLastWriteTime, 0); + } } else { Index: src/libchcore/TPath.cpp =================================================================== diff -u -N -re8f31b0f922b402878356e130c866c4f3682a7f5 -rf866db90e4b058a4f2e13cc6cf076d1e0bf2d956 --- src/libchcore/TPath.cpp (.../TPath.cpp) (revision e8f31b0f922b402878356e130c866c4f3682a7f5) +++ src/libchcore/TPath.cpp (.../TPath.cpp) (revision f866db90e4b058a4f2e13cc6cf076d1e0bf2d956) @@ -448,6 +448,11 @@ return (m_strPath.GetLength() == 2 && m_strPath.GetAt(1) == _T(':')); } + bool TSmartPath::IsDriveWithRootDir() const + { + return (m_strPath.GetLength() == 3 && m_strPath.GetAt(1) == _T(':') && m_strPath.GetAt(2) == _T('\\')); + } + // ============================================================================ /// TSmartPath::HasDrive /// @date 2010/10/16 @@ -500,6 +505,14 @@ return L'\0'; } + TSmartPath TSmartPath::GetDriveLetterAsPath() const + { + if(m_strPath.GetLength() >= 2 && m_strPath.GetAt(1) == _T(':')) + return PathFromWString(m_strPath.Left(1)); // c for c:\windows\test.cpp + + return TSmartPath(); + } + // ============================================================================ /// TSmartPath::IsServerName /// @date 2011/04/05 @@ -849,6 +862,11 @@ m_strPath.Delete(0, 1); } + void TSmartPath::StripPath(const wchar_t* pszToStrip) + { + m_strPath.Replace(pszToStrip, L""); + } + // ============================================================================ /// TSmartPath::IsEmpty /// @date 2010/10/07 Index: src/libchcore/TPath.h =================================================================== diff -u -N -r751648800daaa5e2e42a48075aae11265cfd6564 -rf866db90e4b058a4f2e13cc6cf076d1e0bf2d956 --- src/libchcore/TPath.h (.../TPath.h) (revision 751648800daaa5e2e42a48075aae11265cfd6564) +++ src/libchcore/TPath.h (.../TPath.h) (revision f866db90e4b058a4f2e13cc6cf076d1e0bf2d956) @@ -78,9 +78,11 @@ bool IsRelativePath() const; bool IsDrive() const; + bool IsDriveWithRootDir() const; bool HasDrive() const; TSmartPath GetDrive() const; // c: for c:\windows\test.txt wchar_t GetDriveLetter() const; // 'c' for c:\windows\test.txt, null for non-drive based paths + TSmartPath GetDriveLetterAsPath() const; // 'c' for c:\windows\test.txt, null for non-drive based paths bool IsServerName() const; bool HasServerName() const; @@ -112,6 +114,8 @@ void PrependSeparatorIfDoesNotExist(); void StripSeparatorAtFront(); + void StripPath(const wchar_t* pszToStrip); + bool StartsWith(const TSmartPath& rPath, bool bCaseSensitive = DefaultCaseSensitivity) const; bool IsEmpty() const; Index: src/libchcore/TSubTaskBase.cpp =================================================================== diff -u -N -rfb881f503caba7b2ade610ba7fc1a36a5aea5d01 -rf866db90e4b058a4f2e13cc6cf076d1e0bf2d956 --- src/libchcore/TSubTaskBase.cpp (.../TSubTaskBase.cpp) (revision fb881f503caba7b2ade610ba7fc1a36a5aea5d01) +++ src/libchcore/TSubTaskBase.cpp (.../TSubTaskBase.cpp) (revision f866db90e4b058a4f2e13cc6cf076d1e0bf2d956) @@ -78,13 +78,17 @@ spPathData->SetDestinationPath(pathSubst); } else - spPathData->SetDestinationPath(spFileInfo->GetFullFilePath().GetFileName()); + { + TSmartPath pathFilename = spFileInfo->GetFullFilePath().GetFileName(); + pathFilename.StripPath(L":"); + spPathData->SetDestinationPath(pathFilename); + } } return pathDst + spPathData->GetDestinationPath() + spFileInfo->GetFilePath(); } else - return pathDst + spFileInfo->GetFullFilePath().GetFileName(); + return pathDst + spFileInfo->GetFilePath(); } } @@ -98,6 +102,7 @@ pathSrcPath.StripSeparatorAtEnd(); TSmartPath pathFilename = pathSrcPath.GetFileName(); + pathFilename.StripPath(L":"); // set the dest path TString strCheckPath = GetTaskPropValue(rConfig);