VSSClass.cpp 36 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439
  1. /*
  2. ** Command & Conquer Renegade(tm)
  3. ** Copyright 2025 Electronic Arts Inc.
  4. **
  5. ** This program is free software: you can redistribute it and/or modify
  6. ** it under the terms of the GNU General Public License as published by
  7. ** the Free Software Foundation, either version 3 of the License, or
  8. ** (at your option) any later version.
  9. **
  10. ** This program is distributed in the hope that it will be useful,
  11. ** but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. ** GNU General Public License for more details.
  14. **
  15. ** You should have received a copy of the GNU General Public License
  16. ** along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. /***********************************************************************************************
  19. *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S ***
  20. ***********************************************************************************************
  21. * *
  22. * Project Name : LevelEdit *
  23. * *
  24. * $Archive:: /Commando/Code/Tools/LevelEdit/VSSClass.cpp $*
  25. * *
  26. * Author:: Patrick Smith *
  27. * *
  28. * $Modtime:: 1/29/02 3:16p $*
  29. * *
  30. * $Revision:: 13 $*
  31. * *
  32. *---------------------------------------------------------------------------------------------*
  33. * Functions: *
  34. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  35. #include "stdafx.h"
  36. #include "vssclass.h"
  37. #include "utils.h"
  38. #include "filemgr.h"
  39. #include "oleauto.h"
  40. #include "afxdisp.h"
  41. #include "rawfile.h"
  42. typedef struct tagVSS_ERROR
  43. {
  44. HRESULT hresult;
  45. LPCTSTR description;
  46. } VSS_ERROR;
  47. VSS_ERROR _ErrorArray[] =
  48. {
  49. { -2147164975, "You cannot change the Admin name or access privileges" },
  50. { -2147166139, "Invalid DOS path: < >" },
  51. { -2147166373, "File < > is currently checked out by < >" },
  52. { -2147166374, "You currently have file < > checked out" },
  53. { -2147166386, "Cannot delete the root project" },
  54. { -2147166391, "You do not have access rights to < >" },
  55. { -2147166398, "Cannot move the root project" },
  56. { -2147166404, "File < > is not checked out" },
  57. { -2147166405, "File < > is not shared by any other projects" },
  58. { -2147166411, "Cannot Rename the root project" },
  59. { -2147166417, "A project cannot be shared under a descendant." },
  60. { -2147166418, "File < > is already shared by this project" },
  61. { -2147166424, "The SourceSafe database has been locked by the Administrator." },
  62. { -2147166519, "Invalid password" },
  63. { -2147166521, "Cannot delete the Admin user" },
  64. { -2147166522, "Permission denied " },
  65. { -2147166525, "User ""< >"" already exists" },
  66. { -2147166526, "User ""< >"" not found " },
  67. { -2147166572, "An item with the name < > already exists" },
  68. { -2147166574, "You can not move a project under itself" },
  69. { -2147166583, "Version not found" },
  70. { -2147167977, "The SourceSafe database path < > does not exist. Please select another database." },
  71. { -2147210887, "This command only works on projects." },
  72. { -2147210888, "This command only works on files." },
  73. { -2147352566, "Invalid access code (bad parameter)*" }
  74. };
  75. ///////////////////////////////////////////////////////////////////
  76. //
  77. // Sys_String_To_ANSI
  78. //
  79. LPTSTR
  80. Sys_String_To_ANSI (BSTR bstr)
  81. {
  82. int len = ::SysStringLen (bstr);
  83. TCHAR *ansi_string = new TCHAR[len + 1];
  84. ASSERT(ansi_string != NULL);
  85. // Convert the BSTR to ANSI using the ANSI code page
  86. ::WideCharToMultiByte (CP_ACP,
  87. 0,
  88. bstr,
  89. len,
  90. ansi_string,
  91. len + 1,
  92. NULL,
  93. NULL);
  94. // Ensure the new string is NULL terminated
  95. ansi_string[len] = 0;
  96. // Return a pointer to the ANSI string
  97. return ansi_string;
  98. }
  99. ///////////////////////////////////////////////////////////////////
  100. //
  101. // Alloc_Sys_String
  102. //
  103. BSTR
  104. Alloc_Sys_String (LPCTSTR string)
  105. {
  106. BSTR sys_string = NULL;
  107. if (string != NULL) {
  108. // Copy the ascii format string to a wide-character string
  109. WCHAR *pwide_string = new WCHAR [::lstrlen (string) + 1];
  110. WCHAR *ptemp_string = pwide_string;
  111. while (*string) {
  112. *ptemp_string++ = (WCHAR)*string++;
  113. }
  114. *ptemp_string = WCHAR('\0');
  115. // Allocate a system-string (COM-safe) from the wide-character string.
  116. sys_string = ::SysAllocString (pwide_string);
  117. // Free the wide-character string we allocated earlier
  118. delete [] pwide_string;
  119. pwide_string = NULL;
  120. }
  121. // Return the system string
  122. return sys_string;
  123. }
  124. ///////////////////////////////////////////////////////////////////
  125. //
  126. // IDispatch_Get_Property
  127. //
  128. bool
  129. IDispatch_Get_Property
  130. (
  131. LPDISPATCH pdispatch,
  132. DISPID dispid,
  133. VARIANT *presult
  134. )
  135. {
  136. // Assume failure
  137. bool retval = false;
  138. // Params OK?
  139. ASSERT (pdispatch != NULL);
  140. if (pdispatch != NULL) {
  141. // Get this property w/o passing any args
  142. DISPPARAMS no_args = {NULL, NULL, 0, 0};
  143. retval = SUCCEEDED (pdispatch->Invoke (dispid,
  144. IID_NULL,
  145. NULL,
  146. DISPATCH_PROPERTYGET,
  147. &no_args,
  148. presult,
  149. NULL,
  150. NULL));
  151. }
  152. // Return the true/false result code
  153. return retval;
  154. }
  155. ///////////////////////////////////////////////////////////////////
  156. //
  157. // IDispatch_Get_Property
  158. //
  159. bool
  160. IDispatch_Get_Property
  161. (
  162. LPDISPATCH pdispatch,
  163. DISPID dispid,
  164. VARIANT &var_arg,
  165. VARIANT *presult
  166. )
  167. {
  168. // Assume failure
  169. bool retval = false;
  170. // Params OK?
  171. ASSERT (pdispatch != NULL);
  172. if (pdispatch != NULL) {
  173. // Fill in the dispatch-params structure with our single param
  174. DISPPARAMS args = {NULL, NULL, 0, 0};
  175. args.rgvarg = &var_arg;
  176. args.cArgs = 1;
  177. // Get this property an pass in the single arguement
  178. EXCEPINFO excep_info = { 0 };
  179. retval = SUCCEEDED (pdispatch->Invoke (dispid,
  180. IID_NULL,
  181. NULL,
  182. DISPATCH_PROPERTYGET,
  183. &args,
  184. presult,
  185. &excep_info,
  186. NULL));
  187. }
  188. // Return the true/false result code
  189. return retval;
  190. }
  191. ///////////////////////////////////////////////////////////////////
  192. //
  193. // Get_VSS_Interface
  194. //
  195. void
  196. VSSClass::Get_VSS_Interface (void)
  197. {
  198. if (m_pIVSSDatabase == NULL) {
  199. // Attempt to create an instance of the VSS Database interface
  200. LPUNKNOWN punknown = NULL;
  201. HRESULT hresult = ::CoCreateInstance (CLSID_VSSDatabase,
  202. NULL,
  203. CLSCTX_INPROC_SERVER,
  204. IID_IVSSDatabase,
  205. (LPVOID *)&punknown);
  206. if (SUCCEEDED (hresult)) {
  207. // Get a pointer to the 'newest' interface we know about
  208. punknown->QueryInterface (IID_IVSSDatabase, (LPVOID *)&m_pIVSSDatabase);
  209. // Release our hold on the original IUnknown interface
  210. COM_RELEASE (punknown);
  211. }
  212. }
  213. return ;
  214. }
  215. ///////////////////////////////////////////////////////////////////
  216. //
  217. // Open_Database
  218. //
  219. bool
  220. VSSClass::Open_Database
  221. (
  222. LPCTSTR ini_filename,
  223. LPCTSTR username,
  224. LPCTSTR password
  225. )
  226. {
  227. // Make sure we have an interface to work with
  228. Get_VSS_Interface ();
  229. // Assume failure
  230. bool retval = false;
  231. m_bReadOnly = TRUE;
  232. ASSERT (m_pIVSSDatabase != NULL);
  233. if (m_pIVSSDatabase != NULL) {
  234. // Convert the string params to COM-safe system strings
  235. BSTR bstr_filename = ::Alloc_Sys_String (ini_filename);
  236. BSTR bstr_username = ::Alloc_Sys_String (username != NULL ? username : "");
  237. BSTR bstr_password = ::Alloc_Sys_String (password != NULL ? password : "");
  238. // Ask VSS to open this database
  239. retval = SUCCEEDED (m_pIVSSDatabase->Open (bstr_filename, bstr_username, bstr_password));
  240. if (retval) {
  241. //
  242. // Determine if the user is read-only
  243. //
  244. IVSSUser *user = NULL;
  245. if (SUCCEEDED (m_pIVSSDatabase->get_User (bstr_username, &user))) {
  246. VARIANT_BOOL readonly = 0;
  247. user->get_ReadOnly (&readonly);
  248. m_bReadOnly = (readonly != 0);
  249. COM_RELEASE (user);
  250. }
  251. //
  252. // Set the working directory
  253. //
  254. /*IVSSItem *root_item = Get_VSS_Item ("$/");
  255. if (root_item != NULL) {
  256. LPCTSTR local_path = ::Get_File_Mgr ()->Get_Base_Path ();
  257. BSTR bstr_local_path = ::Alloc_Sys_String (local_path);
  258. HRESULT result = root_item->put_LocalSpec (bstr_local_path);
  259. ASSERT (SUCCEEDED (result));
  260. ::SysFreeString (bstr_local_path);
  261. COM_RELEASE (root_item);
  262. }*/
  263. }
  264. // Free the system strings we allocated earlier
  265. ::SysFreeString (bstr_filename);
  266. ::SysFreeString (bstr_username);
  267. ::SysFreeString (bstr_password);
  268. }
  269. // Free our inteface pointer if the function wasn't successfull
  270. if (retval == false) {
  271. COM_RELEASE (m_pIVSSDatabase);
  272. }
  273. // Return the true/false result code
  274. return retval;
  275. }
  276. ///////////////////////////////////////////////////////////////////
  277. //
  278. // Get_VSS_Item_From_Local_Path
  279. //
  280. IVSSItem *
  281. VSSClass::Get_VSS_Item_From_Local_Path (LPCTSTR local_filename)
  282. {
  283. // Assume failure
  284. IVSSItem *pitem = NULL;
  285. ASSERT (m_pIVSSDatabase != NULL);
  286. ASSERT (local_filename != NULL);
  287. // State OK?
  288. if ((m_pIVSSDatabase != NULL) &&
  289. (local_filename != NULL)) {
  290. // Lookup the relative path
  291. TCHAR vss_path[MAX_PATH];
  292. CString rel_path = ::Get_File_Mgr ()->Make_Relative_Path (local_filename);
  293. ::wsprintf (vss_path, "$/%s", (LPCTSTR)rel_path);
  294. // Now, lookup the VSS item
  295. pitem = Get_VSS_Item (vss_path);
  296. }
  297. // Return a pointer to the IVSSItem interface
  298. return pitem;
  299. }
  300. ///////////////////////////////////////////////////////////////////
  301. //
  302. // Get_VSS_Item
  303. //
  304. IVSSItem *
  305. VSSClass::Get_VSS_Item (LPCTSTR vss_path)
  306. {
  307. // Assume failure
  308. IVSSItem *pitem = NULL;
  309. ASSERT (m_pIVSSDatabase != NULL);
  310. ASSERT (vss_path != NULL);
  311. // State OK?
  312. if ((m_pIVSSDatabase != NULL) &&
  313. (vss_path != NULL)) {
  314. // Convert the ascii string to a COM-safe BSTR
  315. BSTR bstr_vss_path = ::Alloc_Sys_String (vss_path);
  316. /*VARIANT var_arg;
  317. var_arg.vt = VT_BSTR;
  318. var_arg.bstrVal = bstr_vss_path;
  319. VARIANT result = { 0 };
  320. // Use the IDispatch interface to get the VSSItem property
  321. bool success = ::IDispatch_Get_Property (m_pIVSSDatabase,
  322. 0x00000006,
  323. var_arg,
  324. &result); */
  325. HRESULT result = m_pIVSSDatabase->get_VSSItem (bstr_vss_path, 0, &pitem);
  326. if (FAILED (result)) {
  327. pitem = NULL;
  328. }
  329. // Was the property-get successful?
  330. /*if (success) {
  331. // The IVSSItem pointer should be passed back in the result
  332. pitem = (IVSSItem *)result.ppdispVal;
  333. }*/
  334. // Free the system string we allocated earlier
  335. ::SysFreeString (bstr_vss_path);
  336. }
  337. // Return a pointer to the IVSSItem interface
  338. return pitem;
  339. }
  340. ///////////////////////////////////////////////////////////////////
  341. //
  342. // Does_File_Exist
  343. //
  344. bool
  345. VSSClass::Does_File_Exist (LPCTSTR local_filename)
  346. {
  347. // Assume failure
  348. bool retval = false;
  349. // Get a pointer to this 'item' inside the VSS database.
  350. IVSSItem *pitem = Get_VSS_Item_From_Local_Path (local_filename);
  351. // If we successfully got the VSS item, then it exists in the DB
  352. if (pitem != NULL) {
  353. retval = true;
  354. // Release our hold on the item
  355. COM_RELEASE (pitem);
  356. }
  357. // Return the true/false result code
  358. return retval;
  359. }
  360. ///////////////////////////////////////////////////////////////////
  361. //
  362. // Get_Type
  363. //
  364. VSSItemType
  365. VSSClass::Get_Type (LPCTSTR local_filename)
  366. {
  367. VSSItemType type = VSSITEM_FILE;
  368. // Get a pointer to this 'item' inside the VSS database.
  369. IVSSItem *pitem = Get_VSS_Item_From_Local_Path (local_filename);
  370. ASSERT (pitem != NULL);
  371. if (pitem != NULL) {
  372. int temp = 0;
  373. pitem->get_Type (&temp);
  374. type = (VSSItemType)temp;
  375. // Release our hold on the item
  376. COM_RELEASE (pitem);
  377. }
  378. // Return the type (either project or file)
  379. return type;
  380. }
  381. ///////////////////////////////////////////////////////////////////
  382. //
  383. // Get
  384. //
  385. bool
  386. VSSClass::Get (LPCTSTR local_filename)
  387. {
  388. // Assume failure
  389. bool retval = false;
  390. //
  391. // If this 'file' is a directory, then get files recursively, otherwise
  392. // simply 'get' the desired file.
  393. //
  394. if (Get_Type (local_filename) == VSSITEM_PROJECT) {
  395. retval = Get_Subproject (local_filename);
  396. } else {
  397. // Get a pointer to this 'item' inside the VSS database.
  398. IVSSItem *pitem = Get_VSS_Item_From_Local_Path (local_filename);
  399. ASSERT (pitem != NULL);
  400. if (pitem != NULL) {
  401. // Do the actual file 'get' from VSS.
  402. retval = Get (local_filename, pitem);
  403. COM_RELEASE (pitem);
  404. }
  405. }
  406. // Return the true/false result code
  407. return retval;
  408. }
  409. ///////////////////////////////////////////////////////////////////
  410. //
  411. // Get
  412. //
  413. bool
  414. VSSClass::Get
  415. (
  416. LPCTSTR local_filename,
  417. IVSSItem *pitem
  418. )
  419. {
  420. // Assume failure
  421. bool retval = false;
  422. // Params OK?
  423. ASSERT (pitem != NULL);
  424. if (pitem != NULL) {
  425. if (Get_File_Status (local_filename, NULL, 0, pitem) != VSSFILE_CHECKEDOUT_ME) {
  426. // Convert the ascii string to a COM-safe BSTR
  427. BSTR bstr_filename = ::Alloc_Sys_String (local_filename);
  428. //
  429. // Get the file
  430. //
  431. VARIANT_BOOL is_different = 0;
  432. HRESULT hresult = pitem->get_IsDifferent (bstr_filename, &is_different);
  433. if (!SUCCEEDED (hresult) || (is_different != 0)) {
  434. retval = SUCCEEDED (pitem->Get (&bstr_filename, VSSFLAG_TIMEMOD | VSSFLAG_REPREPLACE));
  435. }
  436. // Free the system string we allocated earlier
  437. ::SysFreeString (bstr_filename);
  438. } else {
  439. retval = true;
  440. }
  441. //
  442. // Only do the 'get' if the vss-version and local versions are different.
  443. //
  444. /*VARIANT_BOOL is_different = 0;
  445. HRESULT hresult = pitem->get_IsDifferent (bstr_filename, &is_different);
  446. if (!SUCCEEDED (hresult) || (is_different != 0)) {
  447. // Get the last mod time of the version in VSS
  448. SYSTEMTIME vss_file_time = { 0 };
  449. if (Get_File_Date (pitem, vss_file_time)) {
  450. // Get the last mod time of the local version
  451. FILETIME local_file_time = { 0 };
  452. Get_File_Time (local_filename, NULL, NULL, &local_file_time);
  453. //
  454. // Should this file be overwritten?
  455. //
  456. CTime vss_time (vss_file_time);
  457. CTime local_time (local_file_time);
  458. if (vss_time > local_time) {
  459. retval = SUCCEEDED (pitem->Get (&bstr_filename, VSSFLAG_TIMEMOD | VSSFLAG_REPREPLACE));
  460. }
  461. }
  462. }*/
  463. }
  464. // Return the true/false result code
  465. return retval;
  466. }
  467. ///////////////////////////////////////////////////////////////////
  468. //
  469. // Get_Subproject
  470. //
  471. bool
  472. VSSClass::Get_Subproject (LPCTSTR local_filename)
  473. {
  474. // Assume failure
  475. bool retval = false;
  476. // Get a pointer to this 'item' inside the VSS database.
  477. IVSSItem *pitem = Get_VSS_Item_From_Local_Path (local_filename);
  478. // Did we succesfully get the VSS item?
  479. ASSERT (pitem != NULL);
  480. if (pitem != NULL) {
  481. Get_Recursive (local_filename, pitem);
  482. retval = true;
  483. // Convert the ascii string to a COM-safe BSTR
  484. //BSTR bstr_filename = ::Alloc_Sys_String (::Get_File_Mgr ()->Make_Full_Path (local_filename));
  485. // Ask the VSS interface to recursively 'get' this file for us
  486. //retval = SUCCEEDED (pitem->Get (&bstr_filename, VSSFLAG_TIMEMOD | VSSFLAG_RECURSYES));
  487. // Free the system string we allocated earlier
  488. //::SysFreeString (bstr_filename);
  489. // Release our hold on the item
  490. COM_RELEASE (pitem);
  491. }
  492. // Return the true/false result code
  493. return retval;
  494. }
  495. ///////////////////////////////////////////////////////////////////
  496. //
  497. // Check_Out
  498. //
  499. bool
  500. VSSClass::Check_Out (LPCTSTR local_filename, bool get_locally)
  501. {
  502. // Assume failure
  503. bool retval = false;
  504. // Get a pointer to this 'item' inside the VSS database.
  505. IVSSItem *pitem = Get_VSS_Item_From_Local_Path (local_filename);
  506. // Did we succesfully get the VSS item?
  507. ASSERT (pitem != NULL);
  508. if (pitem != NULL) {
  509. // Convert the ascii string to a COM-safe BSTR
  510. BSTR bstr_filename = ::Alloc_Sys_String (local_filename);
  511. // Ask the VSS interface to 'checkout' this file for us
  512. retval = SUCCEEDED (pitem->Checkout (NULL, bstr_filename, (get_locally ? VSSFLAG_TIMEMOD : VSSFLAG_GETNO) | VSSFLAG_CHKEXCLUSIVENO));
  513. // Free the system string we allocated earlier
  514. ::SysFreeString (bstr_filename);
  515. // Release our hold on the item
  516. COM_RELEASE (pitem);
  517. }
  518. // Return the true/false result code
  519. return retval;
  520. }
  521. ///////////////////////////////////////////////////////////////////
  522. //
  523. // Check_In
  524. //
  525. bool
  526. VSSClass::Check_In
  527. (
  528. LPCTSTR local_filename,
  529. LPCTSTR comment
  530. )
  531. {
  532. // Assume failure
  533. bool retval = false;
  534. // Get a pointer to this 'item' inside the VSS database.
  535. IVSSItem *pitem = Get_VSS_Item_From_Local_Path (local_filename);
  536. // Did we succesfully get the VSS item?
  537. ASSERT (pitem != NULL);
  538. if (pitem != NULL) {
  539. // Convert the ascii string to a COM-safe BSTR
  540. BSTR bstr_filename = ::Alloc_Sys_String (local_filename);
  541. BSTR bstr_comment = (comment != NULL) ? ::Alloc_Sys_String (comment) : NULL;
  542. // Ask the VSS interface to 'Checkin' this file for us
  543. retval = SUCCEEDED (pitem->Checkin (bstr_comment, bstr_filename, VSSFLAG_CMPCHKSUM | VSSFLAG_RECURSNO | VSSFLAG_UPDUPDATE));
  544. // Free the system strings we allocated earlier
  545. ::SysFreeString (bstr_filename);
  546. if (bstr_comment) {
  547. ::SysFreeString (bstr_filename);
  548. }
  549. // Release our hold on the item
  550. COM_RELEASE (pitem);
  551. }
  552. // Return the true/false result code
  553. return retval;
  554. }
  555. ///////////////////////////////////////////////////////////////////
  556. //
  557. // Add_File
  558. //
  559. bool
  560. VSSClass::Add_File
  561. (
  562. LPCTSTR local_filename,
  563. LPCTSTR comment
  564. )
  565. {
  566. // Assume failure
  567. bool retval = false;
  568. if (Build_Tree (local_filename)) {
  569. TCHAR parent_dir[MAX_PATH];
  570. ::lstrcpy (parent_dir, ::Strip_Filename_From_Path (local_filename));
  571. // Get a pointer to this item's parent inside the VSS database.
  572. IVSSItem *pitem = Get_VSS_Item_From_Local_Path (parent_dir);
  573. // Did we succesfully get the VSS item?
  574. ASSERT (pitem != NULL);
  575. if (pitem != NULL) {
  576. // Convert the ascii string to a COM-safe BSTR
  577. BSTR bstr_filename = ::Alloc_Sys_String (local_filename);
  578. BSTR bstr_comment = (comment != NULL) ? ::Alloc_Sys_String (comment) : NULL;
  579. // Ask the VSS interface to add this file for us
  580. IVSSItem *pnew_item = NULL;
  581. retval = SUCCEEDED (pitem->Add (bstr_filename, bstr_comment, 0, &pnew_item));
  582. // Free the system strings we allocated earlier
  583. ::SysFreeString (bstr_filename);
  584. if (bstr_comment) {
  585. ::SysFreeString (bstr_filename);
  586. }
  587. // Release our hold on these items
  588. COM_RELEASE (pitem);
  589. COM_RELEASE (pnew_item);
  590. }
  591. }
  592. // Return the true/false result code
  593. return retval;
  594. }
  595. ///////////////////////////////////////////////////////////////////
  596. //
  597. // Build_Tree
  598. //
  599. bool
  600. VSSClass::Build_Tree (LPCTSTR local_filename)
  601. {
  602. // Assume failure
  603. bool retval = true;
  604. // Create a relative path to use
  605. CString rel_path = ::Get_File_Mgr ()->Make_Relative_Path (local_filename);
  606. // Generate a list of folders from the path
  607. CString *pfolder_list = NULL;
  608. int count = ::Build_List_From_String (::Strip_Filename_From_Path (rel_path), "\\", &pfolder_list);
  609. // Loop through all the folders in the path and make sure they
  610. // exist in VSS
  611. CString vss_path = "$";
  612. CString parent = "$";
  613. for (int ifolder = 0; (ifolder < count) && retval; ifolder ++) {
  614. // See if this path exists in the VSS database
  615. vss_path += CString ("\\") + pfolder_list[ifolder];
  616. IVSSItem *pitem = Get_VSS_Item (vss_path);
  617. if (pitem == NULL) {
  618. // Get a pointer to the parent so we can create a new folder
  619. pitem = Get_VSS_Item (parent + CString ("\\"));
  620. if (pitem != NULL) {
  621. // Convert the ascii string to a COM-safe BSTR
  622. BSTR bstr_foldername = ::Alloc_Sys_String (pfolder_list[ifolder]);
  623. // Ask the VSS interface to add this folder for us
  624. IVSSItem *pfolder = NULL;
  625. retval &= (bool)SUCCEEDED (pitem->NewSubproject (bstr_foldername, NULL, &pfolder));
  626. // Free any memory we allocated
  627. ::SysFreeString (bstr_foldername);
  628. COM_RELEASE (pfolder);
  629. }
  630. }
  631. COM_RELEASE (pitem);
  632. parent += CString ("\\") + pfolder_list[ifolder];
  633. }
  634. // Free the list
  635. SAFE_DELETE_ARRAY (pfolder_list);
  636. // Return the true/false result code
  637. return retval;
  638. }
  639. ///////////////////////////////////////////////////////////////////
  640. //
  641. // Undo_Check_Out
  642. //
  643. bool
  644. VSSClass::Undo_Check_Out (LPCTSTR local_filename)
  645. {
  646. // Assume failure
  647. bool retval = false;
  648. // Get a pointer to this 'item' inside the VSS database.
  649. IVSSItem *pitem = Get_VSS_Item_From_Local_Path (local_filename);
  650. // Did we succesfully get the VSS item?
  651. ASSERT (pitem != NULL);
  652. if (pitem != NULL) {
  653. // Convert the ascii string to a COM-safe BSTR
  654. BSTR bstr_filename = ::Alloc_Sys_String (local_filename);
  655. // Ask the VSS interface to undo our 'checkout' on this file for us
  656. retval = SUCCEEDED (pitem->UndoCheckout (bstr_filename, 0));
  657. // Free the system string we allocated earlier
  658. ::SysFreeString (bstr_filename);
  659. // Release our hold on the item
  660. COM_RELEASE (pitem);
  661. }
  662. // Return the true/false result code
  663. return retval;
  664. }
  665. ///////////////////////////////////////////////////////////////////
  666. //
  667. // Destroy
  668. //
  669. bool
  670. VSSClass::Destroy (LPCTSTR local_filename)
  671. {
  672. // Assume failure
  673. bool retval = false;
  674. // Get a pointer to this 'item' inside the VSS database.
  675. IVSSItem *pitem = Get_VSS_Item_From_Local_Path (local_filename);
  676. // Did we succesfully get the VSS item?
  677. ASSERT (pitem != NULL);
  678. if (pitem != NULL) {
  679. // Ask the VSS interface to completely destroy this file for us
  680. retval = SUCCEEDED (pitem->Destroy ());
  681. // Release our hold on the item
  682. COM_RELEASE (pitem);
  683. }
  684. // Return the true/false result code
  685. return retval;
  686. }
  687. ///////////////////////////////////////////////////////////////////
  688. //
  689. // Get_File_Version
  690. //
  691. long
  692. VSSClass::Get_File_Version (LPCTSTR local_filename)
  693. {
  694. long version = 0L;
  695. // Get a pointer to this 'item' inside the VSS database.
  696. IVSSItem *pitem = Get_VSS_Item_From_Local_Path (local_filename);
  697. // Did we succesfully get the VSS item?
  698. ASSERT (pitem != NULL);
  699. if (pitem != NULL) {
  700. // Get the version number for this item
  701. VARIANT result = { 0 };
  702. ::IDispatch_Get_Property (pitem, 0x00000008, &result);
  703. // Pass the result back to the caller
  704. version = result.lVal;
  705. // Release our hold on the item
  706. COM_RELEASE (pitem);
  707. }
  708. // Return the version ID
  709. return version;
  710. }
  711. ///////////////////////////////////////////////////////////////////
  712. //
  713. // Is_File_Different
  714. //
  715. bool
  716. VSSClass::Is_File_Different (LPCTSTR local_filename)
  717. {
  718. bool different = false;
  719. // Get a pointer to this 'item' inside the VSS database.
  720. IVSSItem *pitem = Get_VSS_Item_From_Local_Path (local_filename);
  721. // Did we succesfully get the VSS item?
  722. ASSERT (pitem != NULL);
  723. if (pitem != NULL) {
  724. // Convert the ansi string to a system string
  725. BSTR bstr_filename = ::Alloc_Sys_String (local_filename);
  726. VARIANT var_arg = { 0 };
  727. var_arg.vt = VT_BSTR;
  728. var_arg.bstrVal = bstr_filename;
  729. // Ask VSS if the local and checked-in copy are different
  730. VARIANT result = { 0 };
  731. ::IDispatch_Get_Property (pitem, 0x00000010, var_arg, &result);
  732. // Convert the COM-bool to a C++ bool
  733. different = (result.boolVal == 0 ? false : true);
  734. // Free the system strings we allocated earlier
  735. ::SysFreeString (bstr_filename);
  736. // Release our hold on the item
  737. COM_RELEASE (pitem);
  738. }
  739. // Return the true/false result code
  740. return different;
  741. }
  742. ///////////////////////////////////////////////////////////////////
  743. //
  744. // Get_File_Date
  745. //
  746. bool
  747. VSSClass::Get_File_Date
  748. (
  749. //LPCTSTR local_filename,
  750. IVSSItem *pitem,
  751. SYSTEMTIME &system_time
  752. )
  753. {
  754. // Params OK?
  755. ASSERT (pitem != NULL);
  756. if (pitem != NULL) {
  757. // Determine which version number we want the date for.
  758. long current_ver_num = 0;
  759. pitem->get_VersionNumber (&current_ver_num);
  760. //
  761. // Get the 'versions' list for this item
  762. //
  763. IVSSVersions *pversions = NULL;
  764. HRESULT hresult = pitem->get_Versions (VSSFLAG_HISTIGNOREFILES, &pversions);
  765. if (SUCCEEDED (hresult) && (pversions != NULL)) {
  766. //
  767. // Get the version enumerator for this item
  768. //
  769. IUnknown *penum_variant = NULL;
  770. HRESULT hresult = pversions->_NewEnum (&penum_variant);
  771. if (SUCCEEDED (hresult)) {
  772. //
  773. // Convert the IUnknown version enumerator to a standard
  774. // VARIANT enumerator.
  775. //
  776. IEnumVARIANT *pversion_enum = NULL;
  777. hresult = penum_variant->QueryInterface (IID_IEnumVARIANT, (LPVOID *)&pversion_enum);
  778. if (SUCCEEDED (hresult) && (pversion_enum != NULL)) {
  779. //
  780. // Loop through all the versions until we've found the right one.
  781. //
  782. bool found = false;
  783. VARIANT version_info = { 0 };
  784. while ((pversion_enum->Next (1, &version_info, NULL) == S_OK) && !found) {
  785. IVSSVersionOld *pversion = (IVSSVersionOld *)version_info.pdispVal;
  786. if (pversion != NULL) {
  787. // Get this version's number
  788. long ver_num = 0L;
  789. pversion->get_VersionNumber (&ver_num);
  790. // Is this the version we were looking for?
  791. if (ver_num == current_ver_num) {
  792. // Get the date from the version
  793. DATE file_date = { 0 };
  794. pversion->get_Date (&file_date);
  795. // Convert the OLE date to a SYSTEMTIME structure
  796. COleDateTime date_obj (file_date);
  797. date_obj.GetAsSystemTime (system_time);
  798. // Success!
  799. found = true;
  800. }
  801. COM_RELEASE (pversion);
  802. }
  803. }
  804. COM_RELEASE (pversion_enum);
  805. }
  806. // Get the date of this file
  807. /*if (::IDispatch_Get_Property (pcheckout, 0x00000004, &result)) {
  808. COleDateTime date_obj (result.dateVal);
  809. SYSTEMTIME system_time;
  810. date_obj.GetAsSystemTime (system_time);
  811. LPTSTR username = ::Sys_String_To_ANSI (result.bstrVal);
  812. // Copy the username back to the buffer the caller supplied
  813. ::lstrcpyn (checked_out_username, username, buffer_size);
  814. checked_out_username[buffer_size-1] = 0;
  815. // Free the temporary buffer we used to hold the username
  816. delete [] username;
  817. username = NULL;
  818. }*/
  819. COM_RELEASE (penum_variant);
  820. }
  821. // Release our hold on the interface
  822. COM_RELEASE (pversions);
  823. }
  824. }
  825. // Return the current file status
  826. return true;
  827. }
  828. ///////////////////////////////////////////////////////////////////
  829. //
  830. // Get_File_Status
  831. //
  832. VSSFileStatus
  833. VSSClass::Get_File_Status
  834. (
  835. LPCTSTR local_filename,
  836. LPTSTR checked_out_username,
  837. DWORD buffer_size,
  838. IVSSItem * item_to_use
  839. )
  840. {
  841. // Assume not checked out
  842. VSSFileStatus status = VSSFILE_NOTCHECKEDOUT;
  843. // Get a pointer to this 'item' inside the VSS database.
  844. IVSSItem *pitem = item_to_use;
  845. if (pitem == NULL) {
  846. pitem = Get_VSS_Item_From_Local_Path (local_filename);
  847. }
  848. // Did we succesfully get the VSS item?
  849. ASSERT (pitem != NULL);
  850. if (pitem != NULL) {
  851. // Get the current check-out status for this item
  852. VARIANT result = { 0 };
  853. ::IDispatch_Get_Property (pitem, 0x0000000e, &result);
  854. // Pass the result back to the caller
  855. status = (VSSFileStatus)result.lVal;
  856. // Should we lookup the name of user who has this file checked out?
  857. if ((status != VSSFILE_NOTCHECKEDOUT) &&
  858. (checked_out_username != NULL)) {
  859. // Get a pointer to the 'checkouts' interface for this item
  860. bool success = ::IDispatch_Get_Property (pitem, 0x0000000f, &result);
  861. IVSSCheckouts *pcheckouts = (IVSSCheckouts *)result.ppdispVal;
  862. if (success && (pcheckouts != NULL)) {
  863. // Get the count of 'checkouts' on this file (should be 1 for our purposes)
  864. if (::IDispatch_Get_Property (pcheckouts, 0x00000001, &result)) {
  865. int count = result.lVal;
  866. if (count > 0) {
  867. VARIANT var_test = { 0 };
  868. var_test.vt = VT_I4;
  869. var_test.lVal = 1;
  870. VARIANT var_arg = { 0 };
  871. var_arg.vt = VT_VARIANT | VT_BYREF;
  872. var_arg.pvarVal = &var_test;
  873. // Attempt to lookup an interface that represents the first 'checkout'.
  874. // Remember, VSS supports multiple checkouts per file.
  875. if (::IDispatch_Get_Property (pcheckouts, 00000000, var_arg, &result)) {
  876. IVSSCheckout *pcheckout = (IVSSCheckout *)result.ppdispVal;
  877. // Get the username of this 'checkout'
  878. if (::IDispatch_Get_Property (pcheckout, 0x00000001, &result)) {
  879. LPTSTR username = ::Sys_String_To_ANSI (result.bstrVal);
  880. // Copy the username back to the buffer the caller supplied
  881. ::lstrcpyn (checked_out_username, username, buffer_size);
  882. checked_out_username[buffer_size-1] = 0;
  883. // Free the temporary buffer we used to hold the username
  884. delete [] username;
  885. username = NULL;
  886. }
  887. // Release our hold on the checkout interface
  888. COM_RELEASE (pcheckout);
  889. }
  890. }
  891. }
  892. // Release our hold on the interface
  893. COM_RELEASE (pcheckouts);
  894. }
  895. }
  896. // Release our hold on the item
  897. if (item_to_use == NULL) {
  898. COM_RELEASE (pitem);
  899. }
  900. }
  901. // Return the current file status
  902. return status;
  903. }
  904. ///////////////////////////////////////////////////////////////////
  905. //
  906. // Get_Error_Description
  907. //
  908. LPCTSTR
  909. VSSClass::Get_Error_Description (HRESULT hresult)
  910. {
  911. LPCTSTR description = NULL;
  912. // Loop through all the VSS specific errors that we know about
  913. int error_count = sizeof (_ErrorArray) / sizeof (VSS_ERROR);
  914. for (int error = 0;
  915. (error < error_count) && (description == NULL);
  916. error ++) {
  917. // Is this the error we are looking for?
  918. if (_ErrorArray[error].hresult == hresult) {
  919. description = _ErrorArray[error].description;
  920. }
  921. }
  922. // Return a string containing the error description.
  923. return description;
  924. }
  925. ///////////////////////////////////////////////////////////////////
  926. //
  927. // Retry_Check_Out
  928. //
  929. bool
  930. VSSClass::Retry_Check_Out
  931. (
  932. LPCTSTR local_filename,
  933. int iattempts,
  934. int idelay
  935. )
  936. {
  937. // Assume failure
  938. bool retval = false;
  939. // Try for up to 'iattempts' times to check-out the file
  940. for (int iattempt = 0; (iattempt < iattempts) && !retval; iattempt ++) {
  941. // Attempt to checkout the file, if unsucccessful, then wait for a second
  942. retval = Check_Out (local_filename);
  943. if (retval == false) {
  944. ::Sleep (idelay);
  945. }
  946. }
  947. // Return the true/false result code
  948. return retval;
  949. }
  950. ///////////////////////////////////////////////////////////////////
  951. //
  952. // Retry_Check_In
  953. //
  954. bool
  955. VSSClass::Retry_Check_In
  956. (
  957. LPCTSTR local_filename,
  958. int iattempts,
  959. int idelay
  960. )
  961. {
  962. // Assume failure
  963. bool retval = false;
  964. // Try for up to 'iattempts' times to check-in the file
  965. for (int iattempt = 0; (iattempt < iattempts) && !retval; iattempt ++) {
  966. // Attempt to checkin the file, if unsucccessful, then wait for a second
  967. retval = Check_In (local_filename);
  968. if (retval == false) {
  969. ::Sleep (idelay);
  970. }
  971. }
  972. // Return the true/false result code
  973. return retval;
  974. }
  975. ///////////////////////////////////////////////////////////////////
  976. //
  977. // Get_Recursive
  978. //
  979. void
  980. VSSClass::Get_Recursive
  981. (
  982. LPCTSTR local_path,
  983. IVSSItem *pparent
  984. )
  985. {
  986. // Get a pointer to the 'IVSSItems' interface for this item
  987. VARIANT result = { 0 };
  988. //bool success = ::IDispatch_Get_Property (pparent, 0x00000009, &result);
  989. IVSSItems *pitems = NULL;
  990. pparent->get_Items (0, &pitems);
  991. //IVSSItems *pitems = (IVSSItems *)result.ppdispVal;
  992. if (pitems != NULL) {
  993. // Get the sub-item count
  994. if (::IDispatch_Get_Property (pitems, 0x00000001, &result)) {
  995. int count = result.lVal;
  996. for (int index = 0; index < count; index ++) {
  997. VARIANT var_index = { 0 };
  998. var_index.vt = VT_I4;
  999. var_index.lVal = index + 1;
  1000. VARIANT var_arg = { 0 };
  1001. var_arg.vt = VT_VARIANT | VT_BYREF;
  1002. var_arg.pvarVal = &var_index;
  1003. // Get the subitem at this index
  1004. if (::IDispatch_Get_Property (pitems, 0x00000000, var_arg, &result)) {
  1005. IVSSItem *psub_item = (IVSSItem *)result.ppdispVal;
  1006. if (psub_item != NULL) {
  1007. // Get the sub-item's name
  1008. TCHAR sub_item_name[MAX_PATH] = { 0 };
  1009. if (::IDispatch_Get_Property (psub_item, 0x00000006, &result)) {
  1010. char *ansi_name = ::Sys_String_To_ANSI (result.bstrVal);
  1011. ::lstrcpy (sub_item_name, ansi_name);
  1012. SAFE_DELETE (ansi_name);
  1013. }
  1014. // Build a filename from the path and the subitem name
  1015. TCHAR sub_item_path[MAX_PATH];
  1016. ::lstrcpy (sub_item_path, local_path);
  1017. if (sub_item_path[::lstrlen (sub_item_path)-1] != '\\') {
  1018. ::lstrcat (sub_item_path, "\\");
  1019. }
  1020. ::lstrcat (sub_item_path, sub_item_name);
  1021. // Get the sub-item's type
  1022. VSSItemType sub_item_type = VSSITEM_PROJECT;
  1023. if (::IDispatch_Get_Property (psub_item, 0x00000004, &result)) {
  1024. sub_item_type = (VSSItemType)result.lVal;
  1025. }
  1026. // Recursively 'get' items for this subitem
  1027. if (sub_item_type == VSSITEM_PROJECT) {
  1028. Get_Recursive (sub_item_path, psub_item);
  1029. } else {
  1030. Get (sub_item_path, psub_item);
  1031. }
  1032. // Release our hold on this subitem's interface
  1033. COM_RELEASE (psub_item);
  1034. }
  1035. }
  1036. }
  1037. }
  1038. // Release our hold on the interface
  1039. COM_RELEASE (pitems);
  1040. }
  1041. return ;
  1042. }
  1043. ///////////////////////////////////////////////////////////////////
  1044. //
  1045. // Check_Out_Ex
  1046. //
  1047. ///////////////////////////////////////////////////////////////////
  1048. bool
  1049. VSSClass::Check_Out_Ex (LPCTSTR local_filename, HWND parent_wnd)
  1050. {
  1051. bool retval = false;
  1052. //
  1053. // Determine the checkout status of the file
  1054. //
  1055. CString user_name;
  1056. VSSFileStatus status = Get_File_Status (local_filename, user_name.GetBufferSetLength (64), 64);
  1057. if (status == VSSFILE_NOTCHECKEDOUT) {
  1058. //
  1059. // Check out the file
  1060. //
  1061. retval = Retry_Check_Out (local_filename, 10, 250);
  1062. if (retval == false) {
  1063. CString message;
  1064. message.Format ("Unable to check out %s.", local_filename);
  1065. ::MessageBox (parent_wnd, message, "VSS Error", MB_ICONERROR | MB_OK);
  1066. }
  1067. } else if (status == VSSFILE_CHECKEDOUT) {
  1068. //
  1069. // Let the user know who has the file checked out.
  1070. //
  1071. CString message;
  1072. message.Format ("User %s already has this file checked out.", user_name);
  1073. ::MessageBox (parent_wnd, message, "Checkout Error", MB_ICONEXCLAMATION | MB_OK);
  1074. } else if (status == VSSFILE_CHECKEDOUT_ME) {
  1075. retval = true;
  1076. }
  1077. return retval;
  1078. }
  1079. ///////////////////////////////////////////////////////////////////
  1080. //
  1081. // Check_In_Ex
  1082. //
  1083. ///////////////////////////////////////////////////////////////////
  1084. bool
  1085. VSSClass::Check_In_Ex (LPCTSTR local_filename, HWND parent_wnd)
  1086. {
  1087. bool retval = false;
  1088. //
  1089. // Make sure the file is checked out to the current user
  1090. //
  1091. if (Get_File_Status (local_filename) == VSSFILE_CHECKEDOUT_ME) {
  1092. //
  1093. // Check in the file
  1094. //
  1095. retval = Retry_Check_In (local_filename, 10, 250);
  1096. if (retval == false) {
  1097. CString message;
  1098. message.Format ("Unable to check in file: %s.", local_filename);
  1099. ::MessageBox (parent_wnd, message, "VSS Error", MB_ICONERROR | MB_OK);
  1100. }
  1101. } else if (Does_File_Exist (local_filename) == false) {
  1102. //
  1103. // If the file did not exist, then add it to the database.
  1104. //
  1105. retval = Add_File (local_filename);
  1106. }
  1107. return retval;
  1108. }
  1109. ///////////////////////////////////////////////////////////////////
  1110. //
  1111. // Get_File_Status
  1112. //
  1113. ///////////////////////////////////////////////////////////////////
  1114. AssetDatabaseClass::FILE_STATUS
  1115. VSSClass::Get_File_Status (LPCTSTR local_filename, StringClass *checked_out_user_name)
  1116. {
  1117. AssetDatabaseClass::FILE_STATUS retval = AssetDatabaseClass::UNKNOWN;
  1118. LPTSTR username = NULL;
  1119. DWORD buffer_size = 0;
  1120. if (checked_out_user_name != NULL) {
  1121. username = checked_out_user_name->Get_Buffer (64);
  1122. buffer_size = 64;
  1123. }
  1124. //
  1125. // Lookup the vss status of this file
  1126. //
  1127. VSSFileStatus vss_status = Get_File_Status (local_filename, username, buffer_size);
  1128. //
  1129. // Map the return value to a generic
  1130. //
  1131. if (vss_status == VSSFILE_CHECKEDOUT_ME) {
  1132. retval = AssetDatabaseClass::CHECKED_OUT_TO_ME;
  1133. } else if (vss_status == VSSFILE_NOTCHECKEDOUT) {
  1134. retval = AssetDatabaseClass::NOT_CHECKED_OUT;
  1135. } else if (vss_status == VSSFILE_CHECKEDOUT) {
  1136. retval = AssetDatabaseClass::CHECKED_OUT;
  1137. }
  1138. return retval;
  1139. }
  1140. ///////////////////////////////////////////////////////////////////
  1141. //
  1142. // Get_File
  1143. //
  1144. ///////////////////////////////////////////////////////////////////
  1145. FileClass *
  1146. VSSClass::Get_File (LPCTSTR local_filename)
  1147. {
  1148. //
  1149. // Do this to get around an oddity of the class when you pass in
  1150. // the filename to the constructor
  1151. //
  1152. RawFileClass *file_obj = new RawFileClass;
  1153. file_obj->Set_Name (local_filename);
  1154. return file_obj;
  1155. }