2 // vss.cpp -- Interface to Volume Shadow Copies (VSS)
4 // Copyright transferred from MATRIX-Computer GmbH to
5 // Kern Sibbald by express permission.
7 // Copyright (C) 2004-2005 Kern Sibbald
9 // This program is free software; you can redistribute it and/or
10 // modify it under the terms of the GNU General Public License as
11 // published by the Free Software Foundation; either version 2 of
12 // the License, or (at your option) any later version.
14 // This program is distributed in the hope that it will be useful,
15 // but WITHOUT ANY WARRANTY; without even the implied warranty of
16 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 // General Public License for more details.
19 // You should have received a copy of the GNU General Public
20 // License along with this program; if not, write to the Free
21 // Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
22 // MA 02111-1307, USA.
24 // Author : Thorsten Engel
25 // Created On : Fri May 06 21:44:00 2006
31 #include <sys/types.h>
62 #include <atlcomcli.h>
66 // Used for safe string manipulation
71 #pragma comment(lib,"atlsd.lib")
76 VSSClient::VSSClient()
78 m_bCoInitializeCalled = false;
79 m_dwContext = 0; // VSS_CTX_BACKUP;
80 m_bDuringRestore = false;
81 m_bBackupIsInitialized = false;
83 memset (m_wszUniqueVolumeName,0,sizeof (m_wszUniqueVolumeName));
84 memset (m_szShadowCopyName,0,sizeof (m_szShadowCopyName));
88 VSSClient::~VSSClient()
90 // Release the IVssBackupComponents interface
91 // WARNING: this must be done BEFORE calling CoUninitialize()
93 m_pVssObject->Release();
97 // Call CoUninitialize if the CoInitialize was performed sucesfully
98 if (m_bCoInitializeCalled)
102 BOOL VSSClient::InitializeForBackup()
104 //return Initialize (VSS_CTX_BACKUP);
105 return Initialize (0);
111 BOOL VSSClient::GetShadowPath (const char* szFilePath, char* szShadowPath, int nBuflen)
113 if (!m_bBackupIsInitialized)
116 /* check for valid pathname */
119 bIsValidName = strlen (szFilePath) > 3;
121 bIsValidName &= isalpha (szFilePath[0]) &&
122 szFilePath[1]==':' &&
126 int nDriveIndex = toupper(szFilePath[0])-'A';
127 if (m_szShadowCopyName[nDriveIndex][0] != 0) {
128 strncpy (szShadowPath, m_szShadowCopyName[nDriveIndex], nBuflen);
129 nBuflen -= (int) strlen (m_szShadowCopyName[nDriveIndex]);
130 strncat (szShadowPath, szFilePath+2,nBuflen);
136 strncpy (szShadowPath, szFilePath, nBuflen);