Index: src/ch/FileInfo.h =================================================================== diff -u -r3c7ff3a44a80802d86725064af4bf1d5a16bdfc7 -r920ccbb7d5163da9980901b4c6fa9ac69b85ad6d --- src/ch/FileInfo.h (.../FileInfo.h) (revision 3c7ff3a44a80802d86725064af4bf1d5a16bdfc7) +++ src/ch/FileInfo.h (.../FileInfo.h) (revision 920ccbb7d5163da9980901b4c6fa9ac69b85ad6d) @@ -21,9 +21,9 @@ #ifndef __FILEINFO_H__ #define __FILEINFO_H__ +class CDestPath; +//#include "DestPath.h" -#include "DestPath.h" - void FindFreeSubstituteName(CString strSrcPath, CString strDstPath, CString* pstrResult); extern void GetDriveData(LPCTSTR lpszPath, int *piDrvNum, UINT *puiDrvType); @@ -105,39 +105,39 @@ void Create(const WIN32_FIND_DATA* pwfd, LPCTSTR pszFilePath, int iSrcIndex); bool Create(CString strFilePath, int iSrcIndex); - ULONGLONG GetLength64(void) const { return m_uhFileSize; }; - void SetLength64(ULONGLONG uhSize) { m_uhFileSize=uhSize; }; + ULONGLONG GetLength64() const { return m_uhFileSize; } + void SetLength64(ULONGLONG uhSize) { m_uhFileSize=uhSize; } // disk - path and disk number (-1 if none - ie. net disk) CString GetFileDrive(void) const; // returns string with src disk int GetDriveNumber() const; // disk number A - 0, b-1, c-2, ... UINT GetDriveType() const; // drive type - CString GetFileDir(void) const; // @rdesc Returns \WINDOWS\ for C:\WINDOWS\WIN.INI - CString GetFileTitle(void) const; // @cmember returns WIN for C:\WINDOWS\WIN.INI - CString GetFileExt(void) const; /** @cmember returns INI for C:\WINDOWS\WIN.INI */ - CString GetFileRoot(void) const; /** @cmember returns C:\WINDOWS\ for C:\WINDOWS\WIN.INI */ - CString GetFileName(void) const; /** @cmember returns WIN.INI for C:\WINDOWS\WIN.INI */ + CString GetFileDir() const; // @rdesc Returns \WINDOWS\ for C:\WINDOWS\WIN.INI + CString GetFileTitle() const; // @cmember returns WIN for C:\WINDOWS\WIN.INI + CString GetFileExt() const; /** @cmember returns INI for C:\WINDOWS\WIN.INI */ + CString GetFileRoot() const; /** @cmember returns C:\WINDOWS\ for C:\WINDOWS\WIN.INI */ + CString GetFileName() const; /** @cmember returns WIN.INI for C:\WINDOWS\WIN.INI */ const CString& GetFilePath(void) const { return m_strFilePath; } // returns path with m_strFilePath (probably not full) CString GetFullFilePath() const; /** @cmember returns C:\WINDOWS\WIN.INI for C:\WINDOWS\WIN.INI */ void SetFilePath(LPCTSTR lpszPath) { m_strFilePath=lpszPath; }; /* Get File times info (equivalent to CFindFile members) */ - const COleDateTime& GetCreationTime(void) const { return m_timCreation; }; /** @cmember returns creation time */ - const COleDateTime& GetLastAccessTime(void) const { return m_timLastAccess; }; /** @cmember returns last access time */ - const COleDateTime& GetLastWriteTime(void) const { return m_timLastWrite; }; /** @cmember returns las write time */ + const COleDateTime& GetCreationTime() const { return m_timCreation; }; + const COleDateTime& GetLastAccessTime() const { return m_timLastAccess; }; + const COleDateTime& GetLastWriteTime() const { return m_timLastWrite; }; /* Get File attributes info (equivalent to CFindFile members) */ - DWORD GetAttributes(void) const { return m_dwAttributes; }; /** @cmember returns file attributes */ - bool IsDirectory(void) const { return (m_dwAttributes & FILE_ATTRIBUTE_DIRECTORY) != 0; }; /** @cmember returns TRUE if the file is a directory */ - bool IsArchived(void) const { return (m_dwAttributes & FILE_ATTRIBUTE_ARCHIVE) != 0; }; /** @cmember Returns TRUE if the file has archive bit set */ - bool IsReadOnly(void) const { return (m_dwAttributes & FILE_ATTRIBUTE_READONLY) != 0; }; /** @cmember Returns TRUE if the file is read-only */ - bool IsCompressed(void) const { return (m_dwAttributes & FILE_ATTRIBUTE_COMPRESSED) != 0; }; /** @cmember Returns TRUE if the file is compressed */ - bool IsSystem(void) const { return (m_dwAttributes & FILE_ATTRIBUTE_SYSTEM) != 0; }; /** @cmember Returns TRUE if the file is a system file */ - bool IsHidden(void) const { return (m_dwAttributes & FILE_ATTRIBUTE_HIDDEN) != 0; }; /** @cmember Returns TRUE if the file is hidden */ - bool IsTemporary(void) const { return (m_dwAttributes & FILE_ATTRIBUTE_TEMPORARY) != 0; }; /** @cmember Returns TRUE if the file is temporary */ - bool IsNormal(void) const { return m_dwAttributes == 0; }; /** @cmember Returns TRUE if the file is a normal file */ + DWORD GetAttributes(void) const { return m_dwAttributes; } + bool IsDirectory(void) const { return (m_dwAttributes & FILE_ATTRIBUTE_DIRECTORY) != 0; } + bool IsArchived(void) const { return (m_dwAttributes & FILE_ATTRIBUTE_ARCHIVE) != 0; } + bool IsReadOnly(void) const { return (m_dwAttributes & FILE_ATTRIBUTE_READONLY) != 0; } + bool IsCompressed(void) const { return (m_dwAttributes & FILE_ATTRIBUTE_COMPRESSED) != 0; } + bool IsSystem(void) const { return (m_dwAttributes & FILE_ATTRIBUTE_SYSTEM) != 0; } + bool IsHidden(void) const { return (m_dwAttributes & FILE_ATTRIBUTE_HIDDEN) != 0; } + bool IsTemporary(void) const { return (m_dwAttributes & FILE_ATTRIBUTE_TEMPORARY) != 0; } + bool IsNormal(void) const { return m_dwAttributes == 0; } uint_t GetFlags() const { return m_uiFlags; } void SetFlags(uint_t uiFlags, uint_t uiMask = 0xffffffff) { m_uiFlags = (m_uiFlags & ~(uiFlags & uiMask)) | (uiFlags & uiMask); } @@ -165,10 +165,10 @@ int m_iSrcIndex; // index in CClipboardArray table (which contains the first part of the path) DWORD m_dwAttributes; // attributes - ULONGLONG m_uhFileSize; /** @cmember File of size. (COM states LONGLONG as hyper, so "uh" means unsigned hyper) */ - COleDateTime m_timCreation; /** @cmember Creation time */ - COleDateTime m_timLastAccess; /** @cmember Last Access time */ - COleDateTime m_timLastWrite; /** @cmember Last write time */ + ULONGLONG m_uhFileSize; + COleDateTime m_timCreation; + COleDateTime m_timLastAccess; + COleDateTime m_timLastWrite; uint_t m_uiFlags; // ptrs to elements providing data Index: src/ch/task.h =================================================================== diff -u -r3c7ff3a44a80802d86725064af4bf1d5a16bdfc7 -r920ccbb7d5163da9980901b4c6fa9ac69b85ad6d --- src/ch/task.h (.../task.h) (revision 3c7ff3a44a80802d86725064af4bf1d5a16bdfc7) +++ src/ch/task.h (.../task.h) (revision 920ccbb7d5163da9980901b4c6fa9ac69b85ad6d) @@ -24,6 +24,8 @@ #include "../libchcore/FeedbackHandlerBase.h" #include "FileFilter.h" +class CDestPath; + #define ST_NULL_STATUS 0x00000000 #define ST_WRITE_MASK 0x000fffff Index: src/libchcore/TPath.cpp =================================================================== diff -u --- src/libchcore/TPath.cpp (revision 0) +++ src/libchcore/TPath.cpp (revision 920ccbb7d5163da9980901b4c6fa9ac69b85ad6d) @@ -0,0 +1,385 @@ +/*************************************************************************** +* Copyright (C) 2001-2008 by J�zef Starosczyk * +* ixen@copyhandler.com * +* * +* This program is free software; you can redistribute it and/or modify * +* it under the terms of the GNU Library General Public License * +* (version 2) as published by the Free Software Foundation; * +* * +* This program is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU General Public License for more details. * +* * +* You should have received a copy of the GNU Library General Public * +* License along with this program; if not, write to the * +* Free Software Foundation, Inc., * +* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * +***************************************************************************/ +#include "stdafx.h" +#include "TPath.h" +#include + +// ============================================================================ +/// TPath::TPath +/// @date 2009/11/29 +/// +/// @brief Constructs the TPath object. +// ============================================================================ +TPath::TPath() : + m_lRefCount(1), + m_strPath() +{ +} + +// ============================================================================ +/// TPath::~TPath +/// @date 2009/11/29 +/// +/// @brief Destructs the TPath object. +// ============================================================================ +TPath::~TPath() +{ +} + +// ============================================================================ +/// TPath::Release +/// @date 2009/11/29 +/// +/// @brief Releases a reference to this object. Deletes the object if no reference exists. +/// @return Current reference count. +// ============================================================================ +long TPath::Release() +{ + if(--m_lRefCount == 0) + { + delete this; + return 0; + } + return m_lRefCount; +} + +// ============================================================================ +/// TPath::New +/// @date 2009/11/29 +/// +/// @brief Allocates a new, empty TPath object. +/// @return Pointer to the newly allocated object. +// ============================================================================ +TPath* TPath::New() +{ + return new TPath(); +} + +// ============================================================================ +/// TPath::Delete +/// @date 2009/11/29 +/// +/// @brief Deletes the TPath object +/// @param[in] pPath - pointer to the object to delete. +// ============================================================================ +void TPath::Delete(TPath* pPath) +{ + delete pPath; +} + +// ============================================================================ +/// TSmartPath::TSmartPath +/// @date 2009/11/29 +/// +/// @brief Constructs an empty path. +// ============================================================================ +TSmartPath::TSmartPath() : + m_pPath(NULL) +{ +} + +// ============================================================================ +/// TSmartPath::TSmartPath +/// @date 2009/11/29 +/// +/// @brief Constructs path from stl string object. +/// @param[in] strPath - string containing a path. +// ============================================================================ +TSmartPath::TSmartPath(const tstring_t& strPath) : + m_pPath(TPath::New()) +{ + if(m_pPath) + m_pPath->m_strPath = strPath; +} + +// ============================================================================ +/// TSmartPath::TSmartPath +/// @date 2009/11/29 +/// +/// @brief Constructs a path object from string. +/// @param[in] pszPath - string with path. +// ============================================================================ +TSmartPath::TSmartPath(const tchar_t* pszPath) : + m_pPath(TPath::New()) +{ + if(m_pPath) + m_pPath->m_strPath = pszPath; +} + +// ============================================================================ +/// TSmartPath::TSmartPath +/// @date 2009/11/29 +/// +/// @brief Constructs path object from another path object. +/// @param[in] spPath - reference to another path object. +// ============================================================================ +TSmartPath::TSmartPath(const TSmartPath& spPath) : + m_pPath(spPath.m_pPath) +{ +} + +// ============================================================================ +/// TSmartPath::~TSmartPath +/// @date 2009/11/29 +/// +/// @brief +/// @return +// ============================================================================ +TSmartPath::~TSmartPath() +{ + Clear(); +} + +// ============================================================================ +/// TSmartPath::Clear +/// @date 2009/11/29 +/// +/// @brief Clears this object. +// ============================================================================ +void TSmartPath::Clear() throw() +{ + if(m_pPath) + { + m_pPath->Release(); // Release will delete object if unused anymore + m_pPath = NULL; + } +} + +// ============================================================================ +/// TSmartPath::operator= +/// @date 2009/11/29 +/// +/// @brief Assigns a path from string. +/// @param[in] strPath - string containing a path. +/// @return Reference to this object. +// ============================================================================ +TSmartPath& TSmartPath::operator=(const tstring_t& strPath) +{ + // can we get exclusive access to the member? + // if not, clear this object + if(m_pPath && m_pPath->IsShared()) + Clear(); + + // create new internal path if does not exist + if(!m_pPath) + m_pPath = TPath::New(); + + m_pPath->m_strPath = strPath; + + return *this; +} + +// ============================================================================ +/// TSmartPath::operator= +/// @date 2009/11/29 +/// +/// @brief Assigns a path from string. +/// @param[in] strPath - string containing a path. +/// @return Reference to this object. +// ============================================================================ +TSmartPath& TSmartPath::operator=(const tchar_t* pszPath) +{ + // can we get exclusive access to the member? + // if not, clear this object + if(m_pPath && m_pPath->IsShared()) + Clear(); + + // create new internal path if does not exist + if(!m_pPath) + m_pPath = TPath::New(); + + m_pPath->m_strPath = pszPath; + + return *this; +} + +// ============================================================================ +/// TSmartPath::operator= +/// @date 2009/11/29 +/// +/// @brief Assigns a path from other path object. +/// @param[in] spPath - path object from which we want to get path. +/// @return Reference to this object. +// ============================================================================ +TSmartPath& TSmartPath::operator=(const TSmartPath& spPath) +{ + if(this != &spPath && m_pPath != spPath.m_pPath) + { + Clear(); + m_pPath = spPath.m_pPath; + m_pPath->AddRef(); + } + + return *this; +} + +// ============================================================================ +/// TSmartPath::operator== +/// @date 2009/11/29 +/// +/// @brief Compares paths (case sensitive). +/// @param[in] rPath - path to compare this object to. +/// @return True if equal, false otherwise. +// ============================================================================ +bool TSmartPath::operator==(const TSmartPath& rPath) const +{ + if(m_pPath == rPath.m_pPath) + return true; + else if(m_pPath == NULL || rPath.m_pPath == NULL) + return false; + else + return m_pPath->m_strPath == rPath.m_pPath->m_strPath; +} + +// ============================================================================ +/// TSmartPath::operator< +/// @date 2009/11/29 +/// +/// @brief Compares paths (case sensitive). +/// @param[in] rPath - input path to compare. +/// @return True if this object is less than rPath, false otherwise. +// ============================================================================ +bool TSmartPath::operator<(const TSmartPath& rPath) const +{ + if(m_pPath == rPath.m_pPath) + return false; + else if(m_pPath == NULL || rPath.m_pPath == NULL) + return m_pPath < rPath.m_pPath; + else + return m_pPath->m_strPath < rPath.m_pPath->m_strPath; +} + +// ============================================================================ +/// TSmartPath::operator> +/// @date 2009/11/29 +/// +/// @brief Compares paths (case sensitive). +/// @param[in] rPath - input path to compare. +/// @return True if this object is less than rPath, false otherwise. +// ============================================================================ +bool TSmartPath::operator>(const TSmartPath& rPath) const +{ + if(m_pPath == rPath.m_pPath) + return false; + else if(m_pPath == NULL || rPath.m_pPath == NULL) + return m_pPath > rPath.m_pPath; + else + return m_pPath->m_strPath > rPath.m_pPath->m_strPath; +} + +// ============================================================================ +/// TSmartPath::operator+ +/// @date 2009/11/29 +/// +/// @brief Concatenates two paths, returns the result. +/// @param[in] rPath - path to concatenate. +/// @return New path object with the results of concatenation. +// ============================================================================ +TSmartPath TSmartPath::operator+(const TSmartPath& rPath) const +{ + TSmartPath spNewPath(*this); + if(rPath.m_pPath) + spNewPath += rPath.m_pPath->m_strPath; + + return spNewPath; +} + +// ============================================================================ +/// TSmartPath::operator+= +/// @date 2009/11/29 +/// +/// @brief Concatenates provided path to our own. +/// @param[in] rPath - path to concatenate. +/// @return Reference to this object. +// ============================================================================ +TSmartPath& TSmartPath::operator+=(const TSmartPath& rPath) +{ + // if there is no path inside rPath, then there is no point in doing anything + if(rPath.m_pPath) + { + // can we use this object exclusively? + if(m_pPath && m_pPath->IsShared()) + Clear(); + + if(!m_pPath) + m_pPath = TPath::New(); + + m_pPath->m_strPath += rPath.m_pPath->m_strPath; + } + + return *this; +} + +// ============================================================================ +/// TSmartPath::operator tstring_t +/// @date 2009/11/29 +/// +/// @brief +/// @return +// ============================================================================ +TSmartPath::operator tstring_t() const +{ + tstring_t strPath; + if(m_pPath) + strPath = m_pPath->m_strPath; + + return strPath; +} + +// ============================================================================ +/// TSmartPath::Compare +/// @date 2009/11/29 +/// +/// @brief Compares paths. +/// @param[in] rPath - path to compare to. +/// @return Result of the comparison. +// ============================================================================ +bool TSmartPath::Compare(const TSmartPath& rPath, bool bCaseSensitive) const +{ + if(m_pPath == rPath.m_pPath) + return true; + else if(m_pPath == NULL || rPath.m_pPath == NULL) + return m_pPath == rPath.m_pPath; + else + { + if(bCaseSensitive) + return boost::equals(m_pPath->m_strPath, rPath.m_pPath->m_strPath); + else + return boost::iequals(m_pPath->m_strPath, rPath.m_pPath->m_strPath); + } +} + +// ============================================================================ +/// TSmartPath::IsChildOf +/// @date 2009/11/29 +/// +/// @brief Checks if this path starts with the path specified as parameter. +/// @param[in] rPath - path to check this one against. +/// @return True if this path starts with the provided one, false otherwise. +// ============================================================================ +bool TSmartPath::IsChildOf(const TSmartPath& rPath, bool bCaseSensitive) const +{ + if(!m_pPath || !rPath.m_pPath) + return false; + + if(bCaseSensitive) + return boost::starts_with(m_pPath->m_strPath, rPath.m_pPath->m_strPath); + else + return boost::istarts_with(m_pPath->m_strPath, rPath.m_pPath->m_strPath); +} Index: src/libchcore/TPath.h =================================================================== diff -u --- src/libchcore/TPath.h (revision 0) +++ src/libchcore/TPath.h (revision 920ccbb7d5163da9980901b4c6fa9ac69b85ad6d) @@ -0,0 +1,77 @@ +/*************************************************************************** +* Copyright (C) 2001-2008 by J�zef Starosczyk * +* ixen@copyhandler.com * +* * +* This program is free software; you can redistribute it and/or modify * +* it under the terms of the GNU Library General Public License * +* (version 2) as published by the Free Software Foundation; * +* * +* This program is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU General Public License for more details. * +* * +* You should have received a copy of the GNU Library General Public * +* License along with this program; if not, write to the * +* Free Software Foundation, Inc., * +* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * +***************************************************************************/ +#ifndef __TPATH_H__ +#define __TPATH_H__ + +#include "libchcore.h" + +class LIBCHCORE_API TPath +{ +public: + TPath(); + ~TPath(); + + long AddRef() { return ++m_lRefCount; } + long Release(); + bool IsShared() const { return m_lRefCount > 1; } + +protected: + static TPath* New(); + static void Delete(TPath* pPath); + +protected: + tstring_t m_strPath; + long m_lRefCount; + + friend class TSmartPath; +}; + +class LIBCHCORE_API TSmartPath +{ +public: + TSmartPath(); + TSmartPath(const tstring_t& strPath); + TSmartPath(const tchar_t* pszPath); + TSmartPath(const TSmartPath& spPath); + + ~TSmartPath(); + + void Clear() throw(); + + TSmartPath& operator=(const tstring_t& strPath); + TSmartPath& operator=(const TSmartPath& spPath); + TSmartPath& operator=(const tchar_t* pszPath); + + bool operator==(const TSmartPath& rPath) const; + bool operator<(const TSmartPath& rPath) const; + bool operator>(const TSmartPath& rPath) const; + + TSmartPath operator+(const TSmartPath& rPath) const; + TSmartPath& operator+=(const TSmartPath& rPath); + + operator tstring_t() const; + + bool Compare(const TSmartPath& rPath, bool bCaseSensitive) const; + bool IsChildOf(const TSmartPath& rPath, bool bCaseSensitive) const; + +protected: + TPath* m_pPath; +}; + +#endif Index: src/libchcore/libchcore.vc90.vcproj =================================================================== diff -u -r2457755b4084e3d1c80a8e7c77c9f0996312941b -r920ccbb7d5163da9980901b4c6fa9ac69b85ad6d --- src/libchcore/libchcore.vc90.vcproj (.../libchcore.vc90.vcproj) (revision 2457755b4084e3d1c80a8e7c77c9f0996312941b) +++ src/libchcore/libchcore.vc90.vcproj (.../libchcore.vc90.vcproj) (revision 920ccbb7d5163da9980901b4c6fa9ac69b85ad6d) @@ -437,6 +437,14 @@ RelativePath=".\stdafx.h" > + + + + #include +#include "../libicpf/gen_types.h"