当前位置: 首页>>代码示例>>C++>>正文


C++ XNode::GetChildAttr方法代码示例

本文整理汇总了C++中XNode::GetChildAttr方法的典型用法代码示例。如果您正苦于以下问题:C++ XNode::GetChildAttr方法的具体用法?C++ XNode::GetChildAttr怎么用?C++ XNode::GetChildAttr使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在XNode的用法示例。


在下文中一共展示了XNode::GetChildAttr方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1:

   void
   BackupExecuter::_RestoreDataDirectory(shared_ptr<Backup> pBackup, XNode *pBackupNode)
   {
      XNode *pBackupInfoNode = pBackupNode->GetChild(_T("BackupInformation"));
      
      // Create the path to the zip file.
      String sBackupFile = pBackup->GetBackupFile();
      String sPath = sBackupFile.Mid(0, sBackupFile.ReverseFind(_T("\\")));

      String sDirContainingDataFiles;
      String sDataFileFormat = pBackupInfoNode->GetChildAttr(_T("DataFiles"), _T("Format"))->value;
      
      String sExtractedFilesDirectory;
      if (sDataFileFormat.CompareNoCase(_T("7Z")) == 0)
      {
         // Create the path to the directory that will contain the extracted files. 
         //  This directory is temporary and will be removed when we're done.
         sExtractedFilesDirectory = Utilities::GetUniqueTempDirectory();

         // Extract the files to this directory.
         Compression oComp;
         oComp.Uncompress(sBackupFile, sExtractedFilesDirectory);

         // The data files in the zip file are stored in
         // a directory called DataBackup.
         sDirContainingDataFiles = sExtractedFilesDirectory + "\\DataBackup";
      }
      else
      {
         // Fetch the path to the data files.
         String sFolderName = pBackupInfoNode->GetChildAttr(_T("DataFiles"), _T("FolderName"))->value;
         sDirContainingDataFiles = sPath + "\\" + sFolderName;
      }

      // Delete all directories from the data directory
      // so that we're sure that we're doing a clean restore
      String sDataDirectory = IniFileSettings::Instance()->GetDataDirectory();
      
      std::set<String> vecExcludes;
      FileUtilities::DeleteFilesInDirectory(sDataDirectory);
      FileUtilities::DeleteDirectoriesInDirectory(sDataDirectory, vecExcludes);

      String errorMessage;
      FileUtilities::CopyDirectory(sDirContainingDataFiles, sDataDirectory, errorMessage);

      if (sDataFileFormat.CompareNoCase(_T("7z")) == 0)
      {
         // The temporary directory we created while
         // unzipping should be deleted now.
         FileUtilities::DeleteDirectory(sExtractedFilesDirectory);
      }
   }
开发者ID:Bill48105,项目名称:hmailserver,代码行数:52,代码来源:BackupExecuter.cpp

示例2:

   shared_ptr<Backup>
   BackupManager::LoadBackup(const String &sZipFile) const
   {
      LOG_DEBUG("BackupManager::LoadBackup");

      shared_ptr<Backup> pResult = shared_ptr<Backup>(new Backup);

      // First uncompress our specification file.
      String sTempDir = IniFileSettings::Instance()->GetTempDirectory();
      String sXMLFile = sTempDir + "\\hMailServerBackup.xml";
      FileUtilities::DeleteFile(sXMLFile);
      Compression oComp;
      oComp.Uncompress(sZipFile, sTempDir, "hMailServerBackup.xml");

      // Load the XML document
      String sXMLBuffer = FileUtilities::ReadCompleteTextFile(sXMLFile);
      XDoc oXMLDocument;
      oXMLDocument.Load(sXMLBuffer);

      XNode *pBackupNode = oXMLDocument.GetChild(_T("Backup"));
      if (!pBackupNode)
      {
         LOG_DEBUG("BackupManager::~LoadBackup - E1");
         return pResult;
      }

      int iMode = _ttoi(pBackupNode->GetChildAttr(_T("BackupInformation"), _T("Mode"))->value);

      pResult->SetBackupFile(sZipFile);
      pResult->SetContains(iMode);

      // Delete the XML file we temporarly created
      FileUtilities::DeleteFile(sXMLFile);

      LOG_DEBUG("BackupManager::~LoadBackup - E2");
      return pResult;
   }
开发者ID:Bill48105,项目名称:hmailserver,代码行数:37,代码来源:BackupManager.cpp


注:本文中的XNode::GetChildAttr方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。