ihxfiletest.cpp
Upload User: zhongxx05
Upload Date: 2007-06-06
Package Size: 33641k
Code Size: 21k
Category:

Symbian

Development Platform:

C/C++

  1. /* ***** BEGIN LICENSE BLOCK ***** 
  2.  * Version: RCSL 1.0/RPSL 1.0 
  3.  *  
  4.  * Portions Copyright (c) 1995-2002 RealNetworks, Inc. All Rights Reserved. 
  5.  *      
  6.  * The contents of this file, and the files included with this file, are 
  7.  * subject to the current version of the RealNetworks Public Source License 
  8.  * Version 1.0 (the "RPSL") available at 
  9.  * http://www.helixcommunity.org/content/rpsl unless you have licensed 
  10.  * the file under the RealNetworks Community Source License Version 1.0 
  11.  * (the "RCSL") available at http://www.helixcommunity.org/content/rcsl, 
  12.  * in which case the RCSL will apply. You may also obtain the license terms 
  13.  * directly from RealNetworks.  You may not use this file except in 
  14.  * compliance with the RPSL or, if you have a valid RCSL with RealNetworks 
  15.  * applicable to this file, the RCSL.  Please see the applicable RPSL or 
  16.  * RCSL for the rights, obligations and limitations governing use of the 
  17.  * contents of the file.  
  18.  *  
  19.  * This file is part of the Helix DNA Technology. RealNetworks is the 
  20.  * developer of the Original Code and owns the copyrights in the portions 
  21.  * it created. 
  22.  *  
  23.  * This file, and the files included with this file, is distributed and made 
  24.  * available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 
  25.  * EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS ALL SUCH WARRANTIES, 
  26.  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS 
  27.  * FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 
  28.  * 
  29.  * Technology Compatibility Kit Test Suite(s) Location: 
  30.  *    http://www.helixcommunity.org/content/tck 
  31.  * 
  32.  * Contributor(s): 
  33.  *  
  34.  * ***** END LICENSE BLOCK ***** */ 
  35. #include "hx_ut_debug.h"
  36. #include "datffact.h"
  37. #include "hxbuffer.h"
  38. #include "hlxclib/sys/stat.h"
  39. #include "chxdataf.h"
  40. #include "cihx2chxdataf.h"
  41. #include "ut_param_util.h"
  42. #include "filetestutil.h"
  43. #include "ihxfiletest.h"
  44. HLXIHXFileTest::HLXIHXFileTest(const char* pModeString)
  45.     : m_pIHXDataFile(NULL)
  46.     , m_pCHXDataFile(NULL)
  47.     , m_pCHXDirectory(NULL)
  48.     , m_DataFileMode('i')
  49.     , m_bTestDir(false)
  50. {
  51.     if ((!pModeString) || (strncmp(pModeString, "ihx", 3) == 0))
  52.     {
  53. m_DataFileMode = 'i';
  54. // Use "ihx" file object test
  55. HXDataFileFactory* pDataFileFactory = new HXDataFileFactory;
  56. if (pDataFileFactory)
  57. {
  58.     IUnknown* pPersistentObj = NULL;
  59.     
  60.     pDataFileFactory->AddRef();
  61.     
  62.     pDataFileFactory->CreateFile(m_pIHXDataFile,
  63.  NULL,     // context
  64.  pPersistentObj,
  65.  TRUE,     // mem. mapped I/O
  66.  0,     // page size
  67.  FALSE,     // file locking
  68.  FALSE);    // prefer sync. object
  69.     
  70.     pDataFileFactory->Release();
  71.     
  72.     HX_RELEASE(pPersistentObj);
  73. }
  74. m_bTestDir = (strcmp(pModeString, "ihxdir") == 0);
  75.     }
  76.     else if (strncmp(pModeString, "chx", 3) == 0)
  77.     {
  78. m_DataFileMode = 'c';
  79. CIHX2CHXDataFile* pIHX2CHXDataFile = new CIHX2CHXDataFile();
  80. if (pIHX2CHXDataFile)
  81. {
  82.     pIHX2CHXDataFile->AddRef();
  83.     m_pIHXDataFile = pIHX2CHXDataFile;
  84.     m_pCHXDataFile = pIHX2CHXDataFile->GetCHXDataFile();
  85.     pIHX2CHXDataFile = NULL;
  86. }
  87. HX_RELEASE(pIHX2CHXDataFile);
  88. m_bTestDir = (strcmp(pModeString, "chxdir") == 0);
  89.     }
  90.     if (m_bTestDir)
  91.     {
  92. m_pCHXDirectory = new CHXDirectory();
  93.     }
  94. }
  95. HLXIHXFileTest::~HLXIHXFileTest()
  96. {
  97.     HX_RELEASE(m_pIHXDataFile);
  98.     HX_DELETE(m_pCHXDirectory);
  99. }
  100.     
  101. void HLXIHXFileTest::GetCommandInfo(UTVector<HLXUnitTestCmdInfo*>& cmds)
  102. {
  103.     cmds.Resize(28);
  104.     cmds[0] = new HLXUnitTestCmdInfoDisp<HLXIHXFileTest>(this, 
  105.     "Bind",
  106.     &HLXIHXFileTest::HandleBindCmd,
  107.     2);
  108.     cmds[1] = new HLXUnitTestCmdInfoDisp<HLXIHXFileTest>(this, 
  109.     "Create",
  110.     &HLXIHXFileTest::HandleCreateCmd,
  111.     3);
  112.     cmds[2] = new HLXUnitTestCmdInfoDisp<HLXIHXFileTest>(this, 
  113.     "Open",
  114.     &HLXIHXFileTest::HandleOpenCmd,
  115.     3);
  116.     cmds[3] = new HLXUnitTestCmdInfoDisp<HLXIHXFileTest>(this, 
  117.     "Close",
  118.     &HLXIHXFileTest::HandleCloseCmd,
  119.     2);
  120.     cmds[4] = new HLXUnitTestCmdInfoDisp<HLXIHXFileTest>(this, 
  121.     "Name",
  122.     &HLXIHXFileTest::HandleNameCmd,
  123.     2,
  124.     3);
  125.     cmds[5] = new HLXUnitTestCmdInfoDisp<HLXIHXFileTest>(this, 
  126.     "IsOpen",
  127.     &HLXIHXFileTest::HandleIsOpenCmd,
  128.     2);
  129.     cmds[6] = new HLXUnitTestCmdInfoDisp<HLXIHXFileTest>(this, 
  130.     "Write",
  131.     &HLXIHXFileTest::HandleWriteCmd,
  132.     3);
  133.     cmds[7] = new HLXUnitTestCmdInfoDisp<HLXIHXFileTest>(this, 
  134.     "Read",
  135.     &HLXIHXFileTest::HandleReadCmd,
  136.     3,
  137.     4);
  138.     cmds[8] = new HLXUnitTestCmdInfoDisp<HLXIHXFileTest>(this, 
  139.     "Flush",
  140.     &HLXIHXFileTest::HandleFlushCmd,
  141.     2);
  142.     cmds[9] = new HLXUnitTestCmdInfoDisp<HLXIHXFileTest>(this, 
  143.     "Seek",
  144.     &HLXIHXFileTest::HandleSeekCmd,
  145.     4);
  146.     cmds[10] = new HLXUnitTestCmdInfoDisp<HLXIHXFileTest>(this, 
  147.     "Tell",
  148.     &HLXIHXFileTest::HandleTellCmd,
  149.     1,
  150.     2);
  151.     cmds[11] = new HLXUnitTestCmdInfoDisp<HLXIHXFileTest>(this, 
  152.     "Stat",
  153.     &HLXIHXFileTest::HandleStatCmd,
  154.     2,
  155.     3);
  156.     cmds[12] = new HLXUnitTestCmdInfoDisp<HLXIHXFileTest>(this, 
  157.     "Delete",
  158.     &HLXIHXFileTest::HandleDeleteCmd,
  159.     2,
  160.     3);
  161.     cmds[13] = new HLXUnitTestCmdInfoDisp<HLXIHXFileTest>(this, 
  162.     "GetFd",
  163.     &HLXIHXFileTest::HandleGetFdCmd,
  164.     2);
  165.     cmds[14] = new HLXUnitTestCmdInfoDisp<HLXIHXFileTest>(this, 
  166.     "GetLastErrorCode",
  167.     &HLXIHXFileTest::HandleGetLastErrorCodeCmd,
  168.     2);
  169.     cmds[15] = new HLXUnitTestCmdInfoDisp<HLXIHXFileTest>(this, 
  170.     "GetLastErrorString",
  171.     &HLXIHXFileTest::HandleGetLastErrorStringCmd,
  172.     1);
  173.     cmds[16] = new HLXUnitTestCmdInfoDisp<HLXIHXFileTest>(this, 
  174.     "Rewind",
  175.     &HLXIHXFileTest::HandleRewindCmd,
  176.     2);
  177.     cmds[17] = new HLXUnitTestCmdInfoDisp<HLXIHXFileTest>(this, 
  178.     "GetTempName",
  179.     &HLXIHXFileTest::HandleGetTempNameCmd,
  180.     1);
  181.     cmds[18] = new HLXUnitTestCmdInfoDisp<HLXIHXFileTest>(this, 
  182.     "SetDirPath",
  183.     &HLXIHXFileTest::HandleSetDirPathCmd,
  184.     2);
  185.     cmds[19] = new HLXUnitTestCmdInfoDisp<HLXIHXFileTest>(this, 
  186.     "GetDirPath",
  187.     &HLXIHXFileTest::HandleGetDirPathCmd,
  188.     2,
  189.     3);
  190.     cmds[20] = new HLXUnitTestCmdInfoDisp<HLXIHXFileTest>(this, 
  191.     "CreateDir",
  192.     &HLXIHXFileTest::HandleCreateDirCmd,
  193.     2);
  194.     cmds[21] = new HLXUnitTestCmdInfoDisp<HLXIHXFileTest>(this, 
  195.     "IsDirValid",
  196.     &HLXIHXFileTest::HandleIsDirValidCmd,
  197.     2);
  198.     cmds[22] = new HLXUnitTestCmdInfoDisp<HLXIHXFileTest>(this, 
  199.     "DestroyDir",
  200.     &HLXIHXFileTest::HandleDestroyDirCmd,
  201.     2,
  202.     3);
  203.     cmds[23] = new HLXUnitTestCmdInfoDisp<HLXIHXFileTest>(this, 
  204.     "DeleteDirFile",
  205.     &HLXIHXFileTest::HandleDeleteDirFileCmd,
  206.     3);
  207.     cmds[24] = new HLXUnitTestCmdInfoDisp<HLXIHXFileTest>(this, 
  208.     "MakeCurrentDir",
  209.     &HLXIHXFileTest::HandleMakeCurrentDirCmd,
  210.     2);
  211.     cmds[25] = new HLXUnitTestCmdInfoDisp<HLXIHXFileTest>(this, 
  212.     "FindFirstInDir",
  213.     &HLXIHXFileTest::HandleFindFirstInDirCmd,
  214.     4,
  215.     5);
  216.     cmds[26] = new HLXUnitTestCmdInfoDisp<HLXIHXFileTest>(this, 
  217.     "FindNextInDir",
  218.     &HLXIHXFileTest::HandleFindNextInDirCmd,
  219.     3,
  220.     4);
  221.     cmds[27] = new HLXUnitTestCmdInfoDisp<HLXIHXFileTest>(this, 
  222.     "Rename",
  223.     &HLXIHXFileTest::HandleRenameCmd,
  224.     4);    
  225. }
  226. HLXCmdBasedTest* HLXIHXFileTest::Clone() const
  227. {
  228.     char pModeString[10]; /* Flawfinder: ignore */
  229.     if (m_DataFileMode == 'c')
  230.     {
  231. strcpy(pModeString, "chx"); /* Flawfinder: ignore */
  232.     }
  233.     else
  234.     {
  235. strcpy(pModeString, "ihx"); /* Flawfinder: ignore */
  236.     }
  237.     if (m_bTestDir)
  238.     {
  239. strcat(pModeString, "dir"); /* Flawfinder: ignore */
  240.     }
  241.     return new HLXIHXFileTest(pModeString);
  242. }
  243. /*****************************************************************************
  244.  *  DataFile Commands
  245.  */ 
  246. bool HLXIHXFileTest::HandleBindCmd(const UTVector<UTString>& info)
  247. {
  248.     bool bRetVal = false;
  249.     if (m_pIHXDataFile)
  250.     {
  251. m_pIHXDataFile->Bind((const char*) info[1]);
  252. bRetVal = true;
  253.     }
  254.     return bRetVal;
  255. }
  256. bool HLXIHXFileTest::HandleCreateCmd(const UTVector<UTString>& info)
  257. {
  258.     bool bRetVal = false;
  259.     if (m_pIHXDataFile)
  260.     {
  261. HX_RESULT retVal = m_pIHXDataFile->Create(
  262.     CFileTestUtil::ParseModeString(info[1]));
  263. bRetVal = (retVal == HXR_OK);
  264. bRetVal = (bRetVal == CFileTestUtil::ParseResultString(info[2]));
  265.     }
  266.     return bRetVal;
  267. }
  268. bool HLXIHXFileTest::HandleOpenCmd(const UTVector<UTString>& info)
  269. {
  270.     bool bRetVal = false;
  271.     if (m_pIHXDataFile)
  272.     {
  273. HX_RESULT retVal = m_pIHXDataFile->Open(
  274.     CFileTestUtil::ParseModeString(info[1]));
  275. bRetVal = (retVal == HXR_OK);
  276. bRetVal = (bRetVal == CFileTestUtil::ParseResultString(info[2]));
  277.     }
  278.     return bRetVal;
  279. }
  280. bool HLXIHXFileTest::HandleCloseCmd(const UTVector<UTString>& info)
  281. {
  282.     bool bRetVal = false;
  283.     if (m_pIHXDataFile)
  284.     {
  285. HX_RESULT retVal = m_pIHXDataFile->Close();
  286. bRetVal = (retVal == HXR_OK);
  287. bRetVal = (bRetVal == CFileTestUtil::ParseResultString(info[1]));
  288.     }
  289.     return bRetVal;
  290. }
  291. bool HLXIHXFileTest::HandleFlushCmd(const UTVector<UTString>& info)
  292. {
  293.     bool bRetVal = false;
  294.     if (m_pIHXDataFile)
  295.     {
  296. HX_RESULT retVal = m_pIHXDataFile->Flush();
  297. bRetVal = (retVal == HXR_OK);
  298. bRetVal = (bRetVal == CFileTestUtil::ParseResultString(info[1]));
  299.     }
  300.     return bRetVal;
  301. }
  302. bool HLXIHXFileTest::HandleNameCmd(const UTVector<UTString>& info)
  303. {
  304.     bool bRetVal = false;
  305.     if (m_pIHXDataFile)
  306.     {
  307. IHXBuffer* pHXBuffer = NULL;
  308. BOOL bResultVal;
  309. bResultVal = m_pIHXDataFile->Name(pHXBuffer);
  310. bRetVal = (bResultVal ? true : false);
  311. bRetVal = (bRetVal == (CFileTestUtil::ParseResultString(info[1]) ? true : false));
  312. if (bRetVal && bResultVal)
  313. {
  314.     bRetVal = false;
  315.     if (pHXBuffer)
  316.     {
  317. if (info.Nelements() > 2)
  318. {
  319.     bRetVal = CFileTestUtil::CheckString(info[2], pHXBuffer);
  320. }
  321. else
  322. {
  323.     bRetVal = true;
  324. }
  325.     }
  326. }
  327. HX_RELEASE(pHXBuffer);
  328.     }
  329.     return bRetVal;
  330. }
  331. bool HLXIHXFileTest::HandleGetTempNameCmd(const UTVector<UTString>& info)
  332. {
  333.     bool bRetVal = false;
  334.     if (m_pIHXDataFile)
  335.     {
  336. if (m_pCHXDataFile)
  337. {
  338.     char* pTempName = new char [_MAX_PATH + 1];
  339.     if (pTempName)
  340.     {
  341. pTempName[0] = '';
  342. bRetVal = (m_pCHXDataFile->
  343.    GetTemporaryFileName("test", pTempName, _MAX_PATH + 1) != 0);
  344. if (bRetVal)
  345. {
  346.     bRetVal = false;
  347.     if ((strlen(pTempName) > 0) && 
  348. (strlen(pTempName) <= _MAX_PATH))
  349.     {
  350. bRetVal = true;
  351.     }
  352. }
  353. delete [] pTempName;
  354.     }
  355. }
  356. else
  357. {
  358.     bRetVal = true;
  359. }
  360.     }
  361.     return bRetVal;
  362. }
  363. bool HLXIHXFileTest::HandleIsOpenCmd(const UTVector<UTString>& info)
  364. {
  365.     bool bRetVal = false;
  366.     if (m_pIHXDataFile)
  367.     {
  368. bRetVal = (m_pIHXDataFile->IsOpen() != FALSE);
  369. bRetVal = (bRetVal == CFileTestUtil::ParseBoolString(info[1]));
  370.     }
  371.     return bRetVal;
  372. }
  373. bool HLXIHXFileTest::HandleWriteCmd(const UTVector<UTString>& info)
  374. {
  375.     bool bRetVal = false;
  376.     if (m_pIHXDataFile)
  377.     {
  378. IHXBuffer* pHXBuffer = new CHXBuffer();
  379. if (pHXBuffer)
  380. {
  381.     pHXBuffer->AddRef();
  382.     if (pHXBuffer->Set((const UINT8*) ((const char*) info[1]), 
  383.        strlen(info[1])) == HXR_OK)
  384.     {
  385. ULONG32 ulRetSize;
  386. ULONG32 ulInSize;
  387. ulInSize = pHXBuffer->GetSize();
  388. ulRetSize = m_pIHXDataFile->Write(pHXBuffer);
  389. bRetVal = (ulRetSize == ulInSize);
  390. bRetVal = (bRetVal == CFileTestUtil::ParseResultString(info[2]));
  391.     }
  392.     pHXBuffer->Release();
  393. }
  394.     }
  395.     return bRetVal;
  396. }
  397. bool HLXIHXFileTest::HandleReadCmd(const UTVector<UTString>& info)
  398. {
  399.     bool bRetVal = false;
  400.     if (m_pIHXDataFile)
  401.     {
  402. unsigned int uiReadSize = 0;
  403. if (UTParamUtil::GetUInt(info[1], uiReadSize))
  404. {
  405.     IHXBuffer* pHXBuffer = NULL;
  406.     bool bReadOK;
  407.     ULONG32 ulRetSize = m_pIHXDataFile->Read(pHXBuffer, uiReadSize);
  408.     bReadOK = ((ulRetSize != 0) && (ulRetSize != -1));
  409.     bRetVal = (bReadOK == CFileTestUtil::ParseResultString(info[2]));
  410.     if (bRetVal && bReadOK)
  411.     {
  412. bRetVal = false;
  413. if (info.Nelements() > 3)
  414. {
  415.     bRetVal = CFileTestUtil::CheckBuffer(info[3], 
  416.  pHXBuffer);
  417. }
  418.     }
  419.     HX_RELEASE(pHXBuffer);
  420. }
  421.     }
  422.     return bRetVal;
  423. }
  424. bool HLXIHXFileTest::HandleSeekCmd(const UTVector<UTString>& info)
  425. {
  426.     bool bRetVal = false;
  427.     if (m_pIHXDataFile)
  428.     {
  429. unsigned int uiSeekOffset = 0;
  430. if (UTParamUtil::GetUInt(info[1], uiSeekOffset))
  431. {
  432.     HX_RESULT retVal = m_pIHXDataFile->Seek(
  433. uiSeekOffset, 
  434. CFileTestUtil::ParseSeekModeString(info[2]));
  435.     bRetVal = (retVal == HXR_OK);
  436.     bRetVal = (bRetVal == CFileTestUtil::ParseResultString(info[3]));
  437. }
  438.     }
  439.     return bRetVal;
  440. }
  441. bool HLXIHXFileTest::HandleRewindCmd(const UTVector<UTString>& info)
  442. {
  443.     bool bRetVal = false;
  444.     if (m_pIHXDataFile)
  445.     {
  446. HX_RESULT retVal = HXR_FAIL;
  447. if (m_pCHXDataFile)
  448. {
  449.     retVal = m_pCHXDataFile->Rewind();
  450. }
  451. else
  452.     retVal = m_pIHXDataFile->Seek(0, SEEK_SET);
  453. }
  454. bRetVal = (retVal == HXR_OK);
  455. bRetVal = (bRetVal == CFileTestUtil::ParseResultString(info[1]));
  456.     }
  457.     return bRetVal;
  458. }
  459. bool HLXIHXFileTest::HandleTellCmd(const UTVector<UTString>& info)
  460. {
  461.     bool bRetVal = false;
  462.     if (m_pIHXDataFile)
  463.     {
  464. unsigned int uiFileOffset = 0;
  465. ULONG32 ulRetFileOffset = m_pIHXDataFile->Tell();
  466. bRetVal = true;
  467. if ((info.Nelements() > 1) &&
  468.     UTParamUtil::GetUInt(info[1], uiFileOffset))
  469. {
  470.     bRetVal = (ulRetFileOffset == uiFileOffset);
  471. }
  472.     }
  473.     return bRetVal;
  474. }
  475. bool HLXIHXFileTest::HandleStatCmd(const UTVector<UTString>& info)
  476. {
  477.     bool bRetVal = false;
  478.     if (m_pIHXDataFile)
  479.     {
  480. struct stat statBuffer;
  481. HX_RESULT retVal = m_pIHXDataFile->Stat(&statBuffer);
  482. bRetVal = (retVal == HXR_OK);
  483. bRetVal = (bRetVal == CFileTestUtil::ParseResultString(info[1]));
  484. if (bRetVal && (retVal == HXR_OK) && (info.Nelements() > 2))
  485. {
  486.     unsigned int uiFileSize = 0;
  487.     bRetVal = false;
  488.     if (UTParamUtil::GetUInt(info[2], uiFileSize))
  489.     {
  490. bRetVal = (statBuffer.st_size == uiFileSize);
  491.     }
  492. }
  493.     }
  494.     return bRetVal;
  495. }
  496. bool HLXIHXFileTest::HandleDeleteCmd(const UTVector<UTString>& info)
  497. {
  498.     bool bRetVal = false;
  499.     if (m_pIHXDataFile)
  500.     {
  501. if (info.Nelements() == 2)
  502. {
  503.     HX_RESULT retVal = m_pIHXDataFile->Delete();
  504.     bRetVal = (retVal == HXR_OK);
  505.     bRetVal = (bRetVal == CFileTestUtil::ParseResultString(info[1]));
  506. }
  507. else if (info.Nelements() == 3)
  508. {
  509.     HX_RESULT retVal = HXR_FAIL;
  510.     if (m_pCHXDataFile)
  511.     {
  512. retVal = m_pCHXDataFile->Delete((const char*) info[1]);
  513.     }
  514.     else
  515.     {
  516. m_pIHXDataFile->Bind((const char*) info[1]);
  517. retVal = m_pIHXDataFile->Delete();
  518.     }
  519.     bRetVal = (retVal == HXR_OK);
  520.     bRetVal = (bRetVal == CFileTestUtil::ParseResultString(info[2]));
  521. }
  522.     }
  523.     return bRetVal;
  524. }
  525. bool HLXIHXFileTest::HandleGetFdCmd(const UTVector<UTString>& info)
  526. {
  527.     bool bRetVal = false;
  528.     if (m_pIHXDataFile)
  529.     {
  530. INT16 iFd = m_pIHXDataFile->GetFd();
  531. bRetVal = true;
  532.     }
  533.     return bRetVal;
  534. }
  535. bool HLXIHXFileTest::HandleGetLastErrorCodeCmd(const UTVector<UTString>& info)
  536. {
  537.     bool bRetVal = false;
  538.     if (m_pIHXDataFile)
  539.     {
  540. HX_RESULT retVal = m_pIHXDataFile->GetLastError();
  541. bRetVal = (retVal == HXR_OK);
  542. bRetVal = (bRetVal == CFileTestUtil::ParseResultString(info[1]));
  543.     }
  544.     return bRetVal;
  545. }
  546. bool HLXIHXFileTest::HandleGetLastErrorStringCmd(const UTVector<UTString>& info)
  547. {
  548.     bool bRetVal = false;
  549.     if (m_pIHXDataFile)
  550.     {
  551. IHXBuffer* pHXBuffer = NULL;
  552. m_pIHXDataFile->GetLastError(pHXBuffer);
  553. HX_RELEASE(pHXBuffer);
  554. bRetVal = true;
  555.     }
  556.     return bRetVal;
  557. }
  558. /*****************************************************************************
  559.  *    Directory Commands
  560.  */ 
  561. bool HLXIHXFileTest::HandleSetDirPathCmd(const UTVector<UTString>& info)
  562. {
  563.     bool bRetVal = true;
  564.     if (m_bTestDir)
  565.     {
  566. bRetVal = false;
  567. if (m_pCHXDirectory)
  568. {
  569.     m_pCHXDirectory->SetPath((const char*) info[1]);
  570.     bRetVal = true;
  571. }
  572.     }
  573.     return bRetVal;
  574. }
  575. bool HLXIHXFileTest::HandleGetDirPathCmd(const UTVector<UTString>& info)
  576. {
  577.     bool bRetVal = true;
  578.     if (m_bTestDir)
  579.     {
  580. bRetVal = false;
  581. if (m_pCHXDirectory)
  582. {
  583.     const char* pPath;
  584.     
  585.     pPath = m_pCHXDirectory->GetPath();
  586.     bRetVal = (pPath ? true : false);
  587.     bRetVal = (bRetVal == (CFileTestUtil::ParseResultString(info[1]) ? true : false));
  588.     if (bRetVal && pPath)
  589.     {
  590. bRetVal = false;
  591. if (info.Nelements() > 2)
  592. {
  593.     bRetVal = (strcmp(info[2], pPath) == 0);
  594. }
  595. else
  596. {
  597.     bRetVal = true;
  598. }
  599.     }
  600. }
  601.     }
  602.     return bRetVal;
  603. }
  604. bool HLXIHXFileTest::HandleCreateDirCmd(const UTVector<UTString>& info)
  605. {
  606.     bool bRetVal = true;
  607.     if (m_bTestDir)
  608.     {
  609. bRetVal = false;
  610. if (m_pCHXDirectory)
  611. {
  612.     bRetVal = (m_pCHXDirectory->Create() != FALSE);
  613.     bRetVal = (bRetVal == CFileTestUtil::ParseResultString(info[1]));
  614. }
  615.     }
  616.     return bRetVal;
  617. }
  618. bool HLXIHXFileTest::HandleIsDirValidCmd(const UTVector<UTString>& info)
  619. {
  620.     bool bRetVal = false;
  621.     if (m_bTestDir)
  622.     {
  623. bRetVal = false;
  624. if (m_pCHXDirectory)
  625. {
  626.     bRetVal = (m_pCHXDirectory->IsValid() != FALSE);
  627.     bRetVal = (bRetVal == CFileTestUtil::ParseBoolString(info[1]));
  628. }
  629.     }
  630.     return bRetVal;
  631. }
  632. bool HLXIHXFileTest::HandleDestroyDirCmd(const UTVector<UTString>& info)
  633. {
  634.     bool bRetVal = false;
  635.     if (m_bTestDir)
  636.     {
  637. bRetVal = false;
  638. if (m_pCHXDirectory)
  639. {
  640.     bool bDestroyContents = CFileTestUtil::ParseBoolString(info[1]);
  641.     bRetVal = (m_pCHXDirectory->Destroy(bDestroyContents ? TRUE : FALSE) != FALSE);
  642.     if (info.Nelements() > 2)
  643.     {
  644. bRetVal = (bRetVal == CFileTestUtil::ParseResultString(info[2]));
  645.     }
  646.     else
  647.     {
  648. bRetVal = true;
  649.     }
  650. }
  651.     }
  652.     return bRetVal;
  653. }
  654. bool HLXIHXFileTest::HandleDeleteDirFileCmd(const UTVector<UTString>& info)
  655. {
  656.     bool bRetVal = false;
  657.     if (m_bTestDir)
  658.     {
  659. bRetVal = false;
  660. if (m_pCHXDirectory)
  661. {
  662.     bRetVal = (m_pCHXDirectory->DeleteFile((const char*) info[1]) != FALSE);
  663.     bRetVal = (bRetVal == CFileTestUtil::ParseResultString(info[2]));
  664. }
  665.     }
  666.     return bRetVal;
  667. }
  668. bool HLXIHXFileTest::HandleMakeCurrentDirCmd(const UTVector<UTString>& info)
  669. {
  670.     bool bRetVal = true;
  671.     if (m_bTestDir)
  672.     {
  673. bRetVal = false;
  674. if (m_pCHXDirectory)
  675. {
  676.     bRetVal = (m_pCHXDirectory->MakeCurrentDir() != FALSE);
  677.     bRetVal = (bRetVal == CFileTestUtil::ParseResultString(info[1]));
  678. }
  679.     }
  680.     return bRetVal;
  681. }
  682. bool HLXIHXFileTest::HandleFindFirstInDirCmd(const UTVector<UTString>& info)
  683. {
  684.     bool bRetVal = true;
  685.     if (m_bTestDir)
  686.     {
  687. bRetVal = false;
  688. if (m_pCHXDirectory)
  689. {
  690.     unsigned int uiFileNameSize = 0;
  691.     char* pOutFileName = NULL;
  692.     if (UTParamUtil::GetUInt(info[2], uiFileNameSize))
  693.     {
  694. pOutFileName = new char [uiFileNameSize];
  695. if (pOutFileName)
  696. {
  697.     XHXDirectory::FSOBJ retObj;
  698.     retObj = m_pCHXDirectory->FindFirst((const char*) info[1], // pattern
  699. pOutFileName,
  700. uiFileNameSize);
  701.     bRetVal = (retObj == CFileTestUtil::ParseFSOBJString(
  702.     (const char*) info[3], 
  703.     (retObj != XHXDirectory::FSOBJ_NOTVALID) ? retObj : XHXDirectory::FSOBJ_FILE));
  704.     if (bRetVal && (retObj != XHXDirectory::FSOBJ_NOTVALID))
  705.     {
  706. if (info.Nelements() > 4)
  707. {
  708.     bRetVal = (strcmp(pOutFileName, (const char*) info[4]) == 0);
  709. }
  710.     }
  711.     delete pOutFileName;
  712. }
  713.     }
  714. }
  715.     }
  716.     return bRetVal;
  717. }
  718. bool HLXIHXFileTest::HandleFindNextInDirCmd(const UTVector<UTString>& info)
  719. {
  720.     bool bRetVal = true;
  721.     if (m_bTestDir)
  722.     {
  723. bRetVal = false;
  724. if (m_pCHXDirectory)
  725. {
  726.     unsigned int uiFileNameSize = 0;
  727.     char* pOutFileName = NULL;
  728.     if (UTParamUtil::GetUInt(info[1], uiFileNameSize))
  729.     {
  730. pOutFileName = new char [uiFileNameSize];
  731. if (pOutFileName)
  732. {
  733.     XHXDirectory::FSOBJ retObj;
  734.     retObj = m_pCHXDirectory->FindNext(pOutFileName, // path
  735.        uiFileNameSize);
  736.     bRetVal = (retObj == CFileTestUtil::ParseFSOBJString((const char*) info[2], retObj));
  737.     if (bRetVal && (retObj != XHXDirectory::FSOBJ_NOTVALID))
  738.     {
  739. if (info.Nelements() > 3)
  740. {
  741.     bRetVal = (strcmp(pOutFileName, (const char*) info[3]) == 0);
  742. }
  743.     }
  744.     delete pOutFileName;
  745. }
  746.     }
  747. }
  748.     }
  749.     return bRetVal;
  750. }
  751. bool HLXIHXFileTest::HandleRenameCmd(const UTVector<UTString>& info)
  752. {
  753.     bool bRetVal = false;
  754.     if (m_bTestDir)
  755.     {
  756. bRetVal = false;
  757. if (m_pCHXDirectory)
  758. {
  759.     bRetVal = (m_pCHXDirectory->Rename((const char*) info[1],
  760.        (const char*) info[2]) == HXR_OK);
  761.     bRetVal = (bRetVal == CFileTestUtil::ParseResultString(info[3]));
  762. }
  763.     }
  764.     return bRetVal;
  765. }