Index: src/ch/DestPath.cpp =================================================================== diff -u -N -r5057e08b0cc064972abeb94a488e5f12d9db14a0 -r74b97b78cd03adf95a699f665a2d8e5fa19fcbcf --- src/ch/DestPath.cpp (.../DestPath.cpp) (revision 5057e08b0cc064972abeb94a488e5f12d9db14a0) +++ src/ch/DestPath.cpp (.../DestPath.cpp) (revision 74b97b78cd03adf95a699f665a2d8e5fa19fcbcf) @@ -23,6 +23,7 @@ #define new DEBUG_NEW #endif + void GetDriveData(LPCTSTR lpszPath, int* piDrvNum, UINT* puiDrvType) { TCHAR drv[_MAX_DRIVE+1]; @@ -35,41 +36,62 @@ _tcsupr(drv); // disk number - if (piDrvNum) + if(piDrvNum) *piDrvNum=drv[0]-_T('A'); // disk type - if (puiDrvType) + if(puiDrvType) { *puiDrvType=GetDriveType(drv); - if (*puiDrvType == DRIVE_NO_ROOT_DIR) + if(*puiDrvType == DRIVE_NO_ROOT_DIR) *puiDrvType=DRIVE_UNKNOWN; } } else { // there's no disk in a path - if (piDrvNum) + if(piDrvNum) *piDrvNum=-1; - if (puiDrvType) + if(puiDrvType) { // check for unc path - if (_tcsncmp(lpszPath, _T("\\\\"), 2) == 0) + if(_tcsncmp(lpszPath, _T("\\\\"), 2) == 0) *puiDrvType=DRIVE_REMOTE; else *puiDrvType=DRIVE_UNKNOWN; } } } +CDestPath::CDestPath() : + m_iDriveNumber(-2), + m_uiDriveType(static_cast(-1)) +{ +} + void CDestPath::SetPath(LPCTSTR lpszPath) { m_strPath=lpszPath; // make sure '\\' has been added - if (m_strPath.Right(1) != _T('\\')) + if(m_strPath.Right(1) != _T('\\')) m_strPath+=_T('\\'); - GetDriveData(m_strPath, &m_iDriveNumber, &m_uiDriveType); + m_iDriveNumber = -2; + m_uiDriveType = static_cast(-1); } + +int CDestPath::GetDriveNumber() const +{ + if(m_iDriveNumber == -2) + GetDriveData(m_strPath, &m_iDriveNumber, NULL); + return m_iDriveNumber; +} + +UINT CDestPath::GetDriveType() const +{ + if(m_uiDriveType == static_cast(-1)) + GetDriveData(m_strPath, NULL, &m_uiDriveType); + return m_uiDriveType; +} Index: src/ch/DestPath.h =================================================================== diff -u -N -r5057e08b0cc064972abeb94a488e5f12d9db14a0 -r74b97b78cd03adf95a699f665a2d8e5fa19fcbcf --- src/ch/DestPath.h (.../DestPath.h) (revision 5057e08b0cc064972abeb94a488e5f12d9db14a0) +++ src/ch/DestPath.h (.../DestPath.h) (revision 74b97b78cd03adf95a699f665a2d8e5fa19fcbcf) @@ -22,25 +22,24 @@ class CDestPath { public: - CDestPath() { m_iDriveNumber=-1; m_uiDriveType=static_cast(-1); }; + CDestPath(); + void SetPath(LPCTSTR lpszPath); const CString& GetPath() const { return m_strPath; }; - int GetDriveNumber() const { return m_iDriveNumber; }; - UINT GetDriveType() const { return m_uiDriveType; }; + int GetDriveNumber() const; + UINT GetDriveType() const; template void serialize(Archive& ar, unsigned int /*uiVersion*/) { ar & m_strPath; - ar & m_iDriveNumber; - ar & m_uiDriveType; } protected: CString m_strPath; // always with ending '\\' - int m_iDriveNumber; // initialized within setpath (std -1) - UINT m_uiDriveType; // disk type - -1 if none, the rest like in GetDriveType + mutable int m_iDriveNumber; // initialized within setpath (std -1) + mutable UINT m_uiDriveType; // disk type - -1 if none, the rest like in GetDriveType }; #endif \ No newline at end of file