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


C++ UStringVector::Add方法代码示例

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


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

示例1: LoadGlobalCodecs

HRESULT CContentsView::CalculateCrc2(const UString &methodName)
{
  CContentsView &srcPanel = *this;

  CRecordVector<UInt32> indices;
  srcPanel.GetOperatedIndicesSmart(indices);
  if (indices.IsEmpty())
    return S_OK;

  if (!srcPanel.Is_IO_FS_Folder())
  {
    CCopyToOptions options;
    options.streamMode = true;
    options.showErrorMessages = true;
    options.hashMethods.Add(methodName);

    UStringVector messages;
    return srcPanel.CopyTo(options, indices, &messages);
  }

  #ifdef EXTERNAL_CODECS

  LoadGlobalCodecs();
    
  #endif

  {
    CThreadCrc t;
    {
      UStringVector methods;
      methods.Add(methodName);
      RINOK(t.Hash.SetMethods(EXTERNAL_CODECS_VARS_G methods));
    }
    FOR_VECTOR (i, indices)
      t.Enumerator.FilePaths.Add(us2fs(srcPanel.GetItemRelPath(indices[i])));

    UString basePrefix = srcPanel.GetFsPath();
    UString basePrefix2 = basePrefix;
    if (basePrefix2.Back() == ':')
    {
      int pos = basePrefix2.ReverseFind_PathSepar();
      if (pos >= 0)
        basePrefix2.DeleteFrom(pos + 1);
    }

    t.Enumerator.BasePrefix = us2fs(basePrefix);
    t.Enumerator.BasePrefix_for_Open = us2fs(basePrefix2);

    t.Enumerator.EnterToDirs = !GetFlatMode();
    
    t.ProgressDialog.ShowCompressionInfo = false;
    
    UString title = LangString(IDS_CHECKSUM_CALCULATING);
    
    t.ProgressDialog.MainWindow = *GetTopLevelParent();
    t.ProgressDialog.MainTitle = L"7-Zip"; // LangString(IDS_APP_TITLE);
    t.ProgressDialog.MainAddTitle = title;
    t.ProgressDialog.MainAddTitle.Add_Space();
    
    RINOK(t.Create(title, *GetTopLevelParent()));
  }
  RefreshTitle();
  return S_OK;
}
开发者ID:wyrover,项目名称:7-Zip-Pro,代码行数:64,代码来源:PanelCrc.cpp

示例2: EnumerateDirItems

static HRESULT EnumerateDirItems(const NWildcard::CCensorNode &curNode,
    int phyParent, int logParent, const FString &phyPrefix,
    const UStringVector &addArchivePrefix,  // prefix from curNode
    CDirItems &dirItems,
    bool enterToSubFolders,
    IEnumDirItemCallback *callback,
    FStringVector &errorPaths,
    CRecordVector<DWORD> &errorCodes)
{
  if (!enterToSubFolders)
    if (curNode.NeedCheckSubDirs())
      enterToSubFolders = true;
  if (callback)
    RINOK(callback->ScanProgress(dirItems.GetNumFolders(), dirItems.Items.Size(), fs2us(phyPrefix)));

  // try direct_names case at first
  if (addArchivePrefix.IsEmpty() && !enterToSubFolders)
  {
    // check that all names are direct
    int i;
    for (i = 0; i < curNode.IncludeItems.Size(); i++)
    {
      const NWildcard::CItem &item = curNode.IncludeItems[i];
      if (item.Recursive || item.PathParts.Size() != 1)
        break;
      const UString &name = item.PathParts.Front();
      if (name.IsEmpty() || DoesNameContainWildCard(name))
        break;
    }
    if (i == curNode.IncludeItems.Size())
    {
      // all names are direct (no wildcards)
      // so we don't need file_system's dir enumerator
      CRecordVector<bool> needEnterVector;
      for (i = 0; i < curNode.IncludeItems.Size(); i++)
      {
        const NWildcard::CItem &item = curNode.IncludeItems[i];
        const UString &name = item.PathParts.Front();
        const FString fullPath = phyPrefix + us2fs(name);
        NFind::CFileInfo fi;
        if (!fi.Find(fullPath))
        {
          errorCodes.Add(::GetLastError());
          errorPaths.Add(fullPath);
          continue;
        }
        bool isDir = fi.IsDir();
        if (isDir && !item.ForDir || !isDir && !item.ForFile)
        {
          errorCodes.Add((DWORD)E_FAIL);
          errorPaths.Add(fullPath);
          continue;
        }
        {
          UStringVector pathParts;
          pathParts.Add(fs2us(fi.Name));
          if (curNode.CheckPathToRoot(false, pathParts, !isDir))
            continue;
        }
        AddDirFileInfo(phyParent, logParent, fi, dirItems.Items);
        if (!isDir)
          continue;
        
        UStringVector addArchivePrefixNew;
        const NWildcard::CCensorNode *nextNode = 0;
        int index = curNode.FindSubNode(name);
        if (index >= 0)
        {
          for (int t = needEnterVector.Size(); t <= index; t++)
            needEnterVector.Add(true);
          needEnterVector[index] = false;
          nextNode = &curNode.SubNodes[index];
        }
        else
        {
          nextNode = &curNode;
          addArchivePrefixNew.Add(name); // don't change it to fi.Name. It's for shortnames support
        }

        RINOK(EnumerateDirItems_Spec(*nextNode, phyParent, logParent, fi.Name, phyPrefix,
            addArchivePrefixNew, dirItems, true, callback, errorPaths, errorCodes));
      }
      for (i = 0; i < curNode.SubNodes.Size(); i++)
      {
        if (i < needEnterVector.Size())
          if (!needEnterVector[i])
            continue;
        const NWildcard::CCensorNode &nextNode = curNode.SubNodes[i];
        const FString fullPath = phyPrefix + us2fs(nextNode.Name);
        NFind::CFileInfo fi;
        if (!fi.Find(fullPath))
        {
          if (!nextNode.AreThereIncludeItems())
            continue;
          errorCodes.Add(::GetLastError());
          errorPaths.Add(fullPath);
          continue;
        }
        if (!fi.IsDir())
        {
//.........这里部分代码省略.........
开发者ID:Dabil,项目名称:puNES,代码行数:101,代码来源:EnumDirItems.cpp

示例3: WriteArgumentsToStringList

static void WriteArgumentsToStringList(int numArgs, const char *args[], UStringVector &strings)
{
  for (int i = 1; i < numArgs; i++)
    strings.Add(MultiByteToUnicodeString(args[i]));
}
开发者ID:BenjaminSiskoo,项目名称:mame,代码行数:5,代码来源:LzmaAlone.cpp

示例4: mySplitCommandLine

void mySplitCommandLine(int numArguments, char *arguments[],UStringVector &parts) {

  { // define P7ZIP_HOME_DIR
    static char p7zip_home_dir[MAX_PATH];
    AString dir,name;
    my_windows_split_path(arguments[0],dir,name);
    snprintf(p7zip_home_dir,sizeof(p7zip_home_dir),"P7ZIP_HOME_DIR=%s/",(const char *)dir);
    p7zip_home_dir[sizeof(p7zip_home_dir)-1] = 0;
    putenv(p7zip_home_dir);
  }

#ifdef ENV_HAVE_LOCALE
  // set the program's current locale from the user's environment variables
  setlocale(LC_ALL,"");

  // auto-detect which conversion p7zip should use
  char *locale = setlocale(LC_CTYPE,0);
  if (locale) {
    size_t len = strlen(locale);
    char *locale_upper = (char *)malloc(len+1);
    if (locale_upper) {
      strcpy(locale_upper,locale);

      for(size_t i=0;i<len;i++)
        locale_upper[i] = toupper(locale_upper[i] & 255);

      if (    (strcmp(locale_upper,"") != 0)
              && (strcmp(locale_upper,"C") != 0)
              && (strcmp(locale_upper,"POSIX") != 0) ) {
        global_use_utf16_conversion = 1;
      }
      free(locale_upper);
    }
  }
#elif defined(LOCALE_IS_UTF8)
  global_use_utf16_conversion = 1; // assume LC_CTYPE="utf8"
#else
  global_use_utf16_conversion = 0; // assume LC_CTYPE="C"
#endif

  parts.Clear();
  for(int ind=0;ind < numArguments; ind++) {
    if ((ind <= 2) && (strcmp(arguments[ind],"-no-utf16") == 0)) {
      global_use_utf16_conversion = 0;
    } else if ((ind <= 2) && (strcmp(arguments[ind],"-utf16") == 0)) {
      global_use_utf16_conversion = 1;
    } else {
      UString tmp = MultiByteToUnicodeString(arguments[ind]);
      // tmp.Trim(); " " is a valid filename ...
      if (!tmp.IsEmpty()) {
        parts.Add(tmp);
      }
      // try to hide the password
      {
        char * arg = arguments[ind];
    size_t len = strlen(arg);
        if ( (len > 2) && (arg[0] == '-') && ( (arg[1]=='p') || (arg[1]=='P') ) )
        {
          memset(arg+2,'*',len-2);
        }
      }
    }
  }
}
开发者ID:ArchangelSDY,项目名称:Qt7z,代码行数:64,代码来源:mySplitCommandLine.cpp

示例5: Correct_FsPath

void Correct_FsPath(bool absIsAllowed, UStringVector &parts, bool isDir)
{
  unsigned i = 0;

  if (absIsAllowed)
  {
    #if defined(_WIN32) && !defined(UNDER_CE)
    bool isDrive = false;
    #endif
    if (parts[0].IsEmpty())
    {
      i = 1;
      #if defined(_WIN32) && !defined(UNDER_CE)
      if (parts.Size() > 1 && parts[1].IsEmpty())
      {
        i = 2;
        if (parts.Size() > 2 && parts[2] == L"?")
        {
          i = 3;
          if (parts.Size() > 3  && NWindows::NFile::NName::IsDrivePath2(parts[3]))
          {
            isDrive = true;
            i = 4;
          }
        }
      }
      #endif
    }
    #if defined(_WIN32) && !defined(UNDER_CE)
    else if (NWindows::NFile::NName::IsDrivePath2(parts[0]))
    {
      isDrive = true;
      i = 1;
    }

    if (isDrive)
    {
      // we convert "c:name" to "c:\name", if absIsAllowed path.
      UString &ds = parts[i - 1];
      if (ds.Len() > 2)
      {
        parts.Insert(i, ds.Ptr(2));
        ds.DeleteFrom(2);
      }
    }
    #endif
  }

  for (; i < parts.Size();)
  {
    UString &s = parts[i];

    Correct_PathPart(s);

    if (s.IsEmpty())
    {
      if (isDir || i != parts.Size() - 1)
      {
        parts.Delete(i);
        continue;
      }
      s = k_EmptyReplaceName;
    }
    else
    {
      #ifdef _WIN32
      CorrectUnsupportedName(s);
      #endif
    }
    
    i++;
  }

  if (!isDir)
  {
    if (parts.IsEmpty())
      parts.Add((UString)k_EmptyReplaceName);
    else
    {
      UString &s = parts.Back();
      if (s.IsEmpty())
        s = k_EmptyReplaceName;
    }
  }
}
开发者ID:ArchangelSDY,项目名称:Qt7z,代码行数:85,代码来源:ExtractingFilePath.cpp

示例6: CalculateCrc

void CApp::CalculateCrc(const UString &methodName)
{
  int srcPanelIndex = GetFocusedPanelIndex();
  CPanel &srcPanel = Panels[srcPanelIndex];

  CRecordVector<UInt32> indices;
  srcPanel.GetOperatedIndicesSmart(indices);
  if (indices.IsEmpty())
    return;

  if (!srcPanel.IsFsOrDrivesFolder())
  {
    CCopyToOptions options;
    options.streamMode = true;
    options.showErrorMessages = true;
    options.hashMethods.Add(methodName);

    UStringVector messages;
    HRESULT res = srcPanel.CopyTo(options, indices, &messages);
    if (res != S_OK)
    {
      if (res != E_ABORT)
        srcPanel.MessageBoxError(res);
    }
    return;
  }

  CCodecs *codecs = new CCodecs;
  #ifdef EXTERNAL_CODECS
  CExternalCodecs __externalCodecs;
  __externalCodecs.GetCodecs = codecs;
  __externalCodecs.GetHashers = codecs;
  #else
  CMyComPtr<IUnknown> compressCodecsInfo = codecs;
  #endif
  ThrowException_if_Error(codecs->Load());

  #ifdef EXTERNAL_CODECS
  ThrowException_if_Error(__externalCodecs.LoadCodecs());
  #endif

  {
    CThreadCrc t;
    {
      UStringVector methods;
      methods.Add(methodName);
      t.Hash.SetMethods(EXTERNAL_CODECS_VARS methods);
    }
    FOR_VECTOR (i, indices)
      t.Enumerator.FilePaths.Add(us2fs(srcPanel.GetItemRelPath(indices[i])));
    t.Enumerator.BasePrefix = us2fs(srcPanel.GetFsPath());
    t.Enumerator.EnterToDirs = !GetFlatMode();
    
    t.ProgressDialog.ShowCompressionInfo = false;
    
    UString title = LangString(IDS_CHECKSUM_CALCULATING);
    
    t.ProgressDialog.MainWindow = _window;
    t.ProgressDialog.MainTitle = L"7-Zip"; // LangString(IDS_APP_TITLE);
    t.ProgressDialog.MainAddTitle = title + UString(L' ');
    
    if (t.Create(title, _window) != S_OK)
      return;
  }
  RefreshTitleAlways();
}
开发者ID:OwenTan,项目名称:AndroidP7zip,代码行数:66,代码来源:PanelCrc.cpp

示例7: EnumerateDirItems

static HRESULT EnumerateDirItems(
	const NWildcard::CCensorNode &curNode, 
	const UString &diskPrefix,        // full disk path prefix 
	const UString &archivePrefix,     // prefix from root
	const UStringVector &addArchivePrefix,  // prefix from curNode
	CObjectVector<CDirItem> &dirItems, 
	bool enterToSubFolders,
	IEnumDirItemCallback *callback,
	UStringVector &errorPaths,
	CRecordVector<DWORD> &errorCodes)
{
  if (!enterToSubFolders)
	if (curNode.NeedCheckSubDirs())
	  enterToSubFolders = true;
  if (callback)
	RINOK(callback->CheckBreak());

  // try direct_names case at first
  if (addArchivePrefix.IsEmpty() && !enterToSubFolders)
  {
	// check that all names are direct
	int i;
	for (i = 0; i < curNode.IncludeItems.Size(); i++)
	{
	  const NWildcard::CItem &item = curNode.IncludeItems[i];
	  if (item.Recursive || item.PathParts.Size() != 1)
		break;
	  const UString &name = item.PathParts.Front();
	  if (name.IsEmpty() || DoesNameContainWildCard(name))
		break;
	}
	if (i == curNode.IncludeItems.Size())
	{
	  // all names are direct (no wildcards)
	  // so we don't need file_system's dir enumerator
	  CRecordVector<bool> needEnterVector;
	  for (i = 0; i < curNode.IncludeItems.Size(); i++)
	  {
		const NWildcard::CItem &item = curNode.IncludeItems[i];
		const UString &name = item.PathParts.Front();
		const UString fullPath = diskPrefix + name;
		NFind::CFileInfoW fileInfo;
		if (!NFind::FindFile(fullPath, fileInfo))
		{
		  errorCodes.Add(::GetLastError());
		  errorPaths.Add(fullPath);
		  continue;
		}
		bool isDir = fileInfo.IsDirectory();
		if (isDir && !item.ForDir || !isDir && !item.ForFile)
		{
		  errorCodes.Add((DWORD)E_FAIL);
		  errorPaths.Add(fullPath);
		  continue;
		}
		const UString realName = fileInfo.Name;
		const UString realDiskPath = diskPrefix + realName;
		{
		  UStringVector pathParts;
		  pathParts.Add(fileInfo.Name);
		  if (curNode.CheckPathToRoot(false, pathParts, !isDir))
			continue;
		}
		AddDirFileInfo(archivePrefix, realDiskPath, fileInfo, dirItems);
		if (!isDir)
		  continue;
		
		UStringVector addArchivePrefixNew;
		const NWildcard::CCensorNode *nextNode = 0;
		int index = curNode.FindSubNode(name);
		if (index >= 0)
		{
		  for (int t = needEnterVector.Size(); t <= index; t++)
			needEnterVector.Add(true);
		  needEnterVector[index] = false;
		  nextNode = &curNode.SubNodes[index];
		}
		else
		{
		  nextNode = &curNode;
		  addArchivePrefixNew.Add(name); // don't change it to realName. It's for shortnames support
		}
		RINOK(EnumerateDirItems(*nextNode,   
			realDiskPath + wchar_t(kDirDelimiter), 
			archivePrefix + realName + wchar_t(kDirDelimiter), 
			addArchivePrefixNew, dirItems, true, callback, errorPaths, errorCodes));
	  }
	  for (i = 0; i < curNode.SubNodes.Size(); i++)
	  {
		if (i < needEnterVector.Size())
		  if (!needEnterVector[i])
			continue;
		const NWildcard::CCensorNode &nextNode = curNode.SubNodes[i];
		const UString fullPath = diskPrefix + nextNode.Name;
		NFind::CFileInfoW fileInfo;
		if (!NFind::FindFile(fullPath, fileInfo))
		{
		  if (!nextNode.AreThereIncludeItems())
			continue;
		  errorCodes.Add(::GetLastError());
//.........这里部分代码省略.........
开发者ID:AMDmi3,项目名称:symwars3,代码行数:101,代码来源:EnumDirItems.cpp

示例8: EnumerateForItem

static HRESULT EnumerateForItem(
    NFind::CFileInfo &fi,
    const NWildcard::CCensorNode &curNode,
    int phyParent, int logParent, const FString &phyPrefix,
    const UStringVector &addArchivePrefix,  // prefix from curNode
    CDirItems &dirItems,
    bool enterToSubFolders)
{
  const UString name = fs2us(fi.Name);
  bool enterToSubFolders2 = enterToSubFolders;
  UStringVector addArchivePrefixNew = addArchivePrefix;
  addArchivePrefixNew.Add(name);
  {
    UStringVector addArchivePrefixNewTemp(addArchivePrefixNew);
    if (curNode.CheckPathToRoot(false, addArchivePrefixNewTemp, !fi.IsDir()))
      return S_OK;
  }
  int dirItemIndex = -1;
  
  if (curNode.CheckPathToRoot(true, addArchivePrefixNew, !fi.IsDir()))
  {
    int secureIndex = -1;
    #ifdef _USE_SECURITY_CODE
    if (dirItems.ReadSecure)
    {
      RINOK(dirItems.AddSecurityItem(phyPrefix + fi.Name, secureIndex));
    }
    #endif
    
    dirItemIndex = dirItems.Items.Size();
    dirItems.AddDirFileInfo(phyParent, logParent, secureIndex, fi);
    if (fi.IsDir())
      enterToSubFolders2 = true;
  }

  #ifndef UNDER_CE
  if (dirItems.ScanAltStreams)
  {
    RINOK(EnumerateAltStreams(fi, curNode, phyParent, logParent,
        phyPrefix + fi.Name,
        addArchivePrefixNew, dirItems));
  }

  if (dirItemIndex >= 0)
  {
    CDirItem &dirItem = dirItems.Items[dirItemIndex];
    RINOK(dirItems.SetLinkInfo(dirItem, fi, phyPrefix));
    if (dirItem.ReparseData.Size() != 0)
      return S_OK;
  }
  #endif
  
  if (!fi.IsDir())
    return S_OK;
  
  const NWildcard::CCensorNode *nextNode = 0;
  if (addArchivePrefix.IsEmpty())
  {
    int index = curNode.FindSubNode(name);
    if (index >= 0)
      nextNode = &curNode.SubNodes[index];
  }
  if (!enterToSubFolders2 && nextNode == 0)
    return S_OK;
  
  addArchivePrefixNew = addArchivePrefix;
  if (nextNode == 0)
  {
    nextNode = &curNode;
    addArchivePrefixNew.Add(name);
  }
  
  return EnumerateDirItems_Spec(
      *nextNode, phyParent, logParent, fi.Name, phyPrefix,
      addArchivePrefixNew,
      dirItems,
      enterToSubFolders2);
}
开发者ID:ming-hai,项目名称:soui,代码行数:78,代码来源:EnumDirItems.cpp

示例9: getInfo

void zmodifyer::getInfo( std::vector< std::pair< std::wstring, ZFile* > > & fileList, wchar_t const * path, wchar_t const * password )
{
	if( zdb_->db_.IsEmpty() )
	{
		// 커맨드 스트링
		UStringVector commandStrings;

		commandStrings.Add(L"L");

		UString pw( L"-P" );

		commandStrings.Add( (pw + ( password ? password : L"") ) );

		commandStrings.Add( file_name_ );

		CArchiveCommandLineOptions options;

		OptionSetting( commandStrings, options );

		// 압축파일 형식 인덱스 추출.
		CIntVector formatIndices;

		if (!codecs_->FindFormatForArchiveType(options.ArcType, formatIndices))
		{
			throw kUnsupportedArcTypeMessage;
		}

		UInt64 numErrors = 0;

		HRESULT result = ListArchives(
			codecs_,
			formatIndices,
			options.StdInMode,
			options.ArchivePathsSorted,
			options.ArchivePathsFullSorted,
			options.WildcardCensor.Pairs.Front().Head,
			options.EnableHeaders,
			options.TechMode,
#ifndef _NO_CRYPTO
			options.PasswordEnabled,
			options.Password,
#endif
			numErrors, zdb_);
	}

	ZFile * zfile = 0;

	std::wstring filePath = path ? path : L"";

	if( filePath.empty() )
	{
		zfile = &zdb_->folder_;
	}
	else
	{
		zfile = zdb_->folder_.find( filePath );
	}

	if( zfile )
	{
		zfile->getList( fileList, filePath );
	}
}
开发者ID:daoluong,项目名称:zpack-library,代码行数:63,代码来源:zmodifyer.cpp

示例10: if

void CArchiveCommandLineParser::Parse2(CArchiveCommandLineOptions &options)
{
  const UStringVector &nonSwitchStrings = parser.NonSwitchStrings;
  int numNonSwitchStrings = nonSwitchStrings.Size();
  if(numNonSwitchStrings < kMinNonSwitchWords)  
    ThrowUserErrorException();

  if (!ParseArchiveCommand(nonSwitchStrings[kCommandIndex], options.Command))
    ThrowUserErrorException();

  options.TechMode = parser[NKey::kTechMode].ThereIs;

  if (parser[NKey::kCaseSensitive].ThereIs)
    g_CaseSensitive = (parser[NKey::kCaseSensitive].PostCharIndex < 0);

  NRecursedType::EEnum recursedType;
  if (parser[NKey::kRecursed].ThereIs)
    recursedType = GetRecursedTypeFromIndex(parser[NKey::kRecursed].PostCharIndex);
  else
    recursedType = NRecursedType::kNonRecursed;

  UINT codePage = CP_UTF8;
  if (parser[NKey::kCharSet].ThereIs)
  {
    UString name = parser[NKey::kCharSet].PostStrings.Front();
    name.MakeUpper();
    int i;
    for (i = 0; i < kNumCodePages; i++)
    {
      const CCodePagePair &pair = g_CodePagePairs[i];
      if (name.Compare(pair.Name) == 0)
      {
        codePage = pair.CodePage;
        break;
      }
    }
    if (i >= kNumCodePages)
      ThrowUserErrorException();
  }

  bool thereAreSwitchIncludes = false;
  if (parser[NKey::kInclude].ThereIs)
  {
    thereAreSwitchIncludes = true;
    AddSwitchWildCardsToCensor(options.WildcardCensor, 
        parser[NKey::kInclude].PostStrings, true, recursedType, codePage);
  }
  if (parser[NKey::kExclude].ThereIs)
    AddSwitchWildCardsToCensor(options.WildcardCensor, 
        parser[NKey::kExclude].PostStrings, false, recursedType, codePage);
 
  int curCommandIndex = kCommandIndex + 1;
  bool thereIsArchiveName = !parser[NKey::kNoArName].ThereIs && 
      options.Command.CommandType != NCommandType::kBenchmark && 
      options.Command.CommandType != NCommandType::kInfo;
  if (thereIsArchiveName)
  {
    if(curCommandIndex >= numNonSwitchStrings)  
      ThrowUserErrorException();
    options.ArchiveName = nonSwitchStrings[curCommandIndex++];
  }

  AddToCensorFromNonSwitchesStrings(
      curCommandIndex, options.WildcardCensor, 
      nonSwitchStrings, recursedType, thereAreSwitchIncludes, codePage);

  options.YesToAll = parser[NKey::kYes].ThereIs;

  bool isExtractGroupCommand = options.Command.IsFromExtractGroup();

  options.PasswordEnabled = parser[NKey::kPassword].ThereIs;

  if(options.PasswordEnabled)
    options.Password = parser[NKey::kPassword].PostStrings[0];

  options.StdInMode = parser[NKey::kStdIn].ThereIs;
  options.ShowDialog = parser[NKey::kShowDialog].ThereIs;

  if(isExtractGroupCommand || options.Command.CommandType == NCommandType::kList)
  {
    if (options.StdInMode)
      ThrowException("Reading archives from stdin is not implemented");
    if (!options.WildcardCensor.AllAreRelative())
      ThrowException("Cannot use absolute pathnames for this command");

    NWildcard::CCensor archiveWildcardCensor;

    if (parser[NKey::kArInclude].ThereIs)
    {
      AddSwitchWildCardsToCensor(archiveWildcardCensor, 
        parser[NKey::kArInclude].PostStrings, true, NRecursedType::kNonRecursed, codePage);
    }
    if (parser[NKey::kArExclude].ThereIs)
      AddSwitchWildCardsToCensor(archiveWildcardCensor, 
      parser[NKey::kArExclude].PostStrings, false, NRecursedType::kNonRecursed, codePage);

    if (thereIsArchiveName)
      AddCommandLineWildCardToCensr(archiveWildcardCensor, options.ArchiveName, true, NRecursedType::kNonRecursed);

    #ifdef _WIN32
//.........这里部分代码省略.........
开发者ID:4ft35t,项目名称:firmware-mod-kit,代码行数:101,代码来源:ArchiveCommandLine.cpp

示例11: update

bool zmodifyer::update( UStringVector & file_names, UStringVector & commandStrings, wchar_t const * password )
{
	if( file_names.IsEmpty() )
		return false;

	// 프로그래스 뷰 사용안함
	commandStrings.Add( L"-BD" );
	// 솔리드 압축 사용 안함
	commandStrings.Add( L"-MS=OFF" );
	// 압축 방식 lzma2
	commandStrings.Add( L"-M0=LZMA2" );
	// multi thread
	commandStrings.Add( L"-MMT=+" );

	if( password && wcslen(password) )
	{
		UString pw( L"-P" );
		commandStrings.Add( (pw + ( password ? password : L"") ) );
	}

	commandStrings.Add( file_name_ );

	for( int i=0; i<file_names.Size(); ++i )
		commandStrings.Add( file_names[i] );

	// 파싱된 커맨드라인 정보로 options 셋팅 ------------
	CArchiveCommandLineOptions options;
	OptionSetting( commandStrings, options );
	options.OverwriteMode = NExtract::NOverwriteMode::kWithoutPrompt; // 덮어쓰기 할때 묻지마라.
	options.YesToAll = true;
	//------------

	// 압축파일 형식 인덱스 추출.
	CIntVector formatIndices;
	if (!codecs_->FindFormatForArchiveType(options.ArcType, formatIndices))
	{
		throw kUnsupportedArcTypeMessage;
	}

	CUpdateOptions &uo = options.UpdateOptions;
	if (uo.SfxMode && uo.SfxModule.IsEmpty())
		uo.SfxModule = kDefaultSfxModule;

	COpenCallbackConsole openCallback;
	openCallback.OutStream = &outStream_;

#ifndef _NO_CRYPTO
	bool passwordIsDefined =
		options.PasswordEnabled && !options.Password.IsEmpty();
	openCallback.PasswordIsDefined = passwordIsDefined;
	openCallback.Password = options.Password;
#endif

	CUpdateCallbackConsole callback;
	callback.EnablePercents = options.EnablePercents;

#ifndef _NO_CRYPTO
	callback.PasswordIsDefined = passwordIsDefined;
	callback.AskPassword = options.PasswordEnabled && options.Password.IsEmpty();
	callback.Password = options.Password;
#endif

	callback.StdOutMode = uo.StdOutMode;
	callback.Init(&outStream_);

	CUpdateErrorInfo errorInfo;

	if (!uo.Init(codecs_, formatIndices, options.ArchiveName))
		throw kUnsupportedArcTypeMessage;

	HRESULT result = UpdateArchive(codecs_,
		options.WildcardCensor, uo,
		errorInfo, &openCallback, &callback, zdb_);

	clearDB();

	return result == S_OK;
}
开发者ID:daoluong,项目名称:zpack-library,代码行数:78,代码来源:zmodifyer.cpp

示例12: extract

// file_name.empty() 이면 모든 파일 압축해제
bool zmodifyer::extract(UStringVector & file_names, wchar_t const * password, wchar_t const * outDir, bool allPath)
{
	// 커맨드 스트링
	UStringVector commandStrings;

	if( allPath )
		commandStrings.Add( L"X" );
	else
		commandStrings.Add( L"E" );

	UString pw( L"-P" );

	commandStrings.Add( (pw + ( password ? password : L"") ) );

	if( outDir )
	{
		UString od( L"-O" );
		commandStrings.Add( (od + outDir) );
	}
	commandStrings.Add( file_name_ );

	if( file_names.IsEmpty() )
	{
		commandStrings.Add( L"*" );
	}
	else
	{
		for( int i=0; i<file_names.Size(); ++i )
			commandStrings.Add( file_names[i] );
	}

	// 파싱된 커맨드라인 정보로 options 셋팅 ------------
	CArchiveCommandLineOptions options;
	OptionSetting( commandStrings, options );
	options.OverwriteMode = NExtract::NOverwriteMode::kWithoutPrompt; // 덮어쓰기 할때 묻지마라.
	options.YesToAll = true;
	//------------

	// 압축파일 형식 인덱스 추출.
	CIntVector formatIndices;
	if (!codecs_->FindFormatForArchiveType(options.ArcType, formatIndices))
	{
		//throw kUnsupportedArcTypeMessage;
		return false;
	}

	bool isExtractGroupCommand = options.Command.IsFromExtractGroup();

	if (codecs_->Formats.Size() == 0 &&
		(isExtractGroupCommand ||
		options.Command.CommandType == NCommandType::kList ||
		options.Command.IsFromUpdateGroup()))
		return false;
		//throw kNoFormats;

	// 압축 해제
	if (isExtractGroupCommand)
	{
		CExtractCallbackConsole *ecs = new CExtractCallbackConsole;
		CMyComPtr<IFolderArchiveExtractCallback> extractCallback = ecs;

		ecs->OutStream = &outStream_;

#ifndef _NO_CRYPTO
		ecs->PasswordIsDefined = options.PasswordEnabled;
		ecs->Password = options.Password;
#endif

		ecs->Init();

		COpenCallbackConsole openCallback;
		openCallback.OutStream = &outStream_;

#ifndef _NO_CRYPTO
		openCallback.PasswordIsDefined = options.PasswordEnabled;
		openCallback.Password = options.Password;
#endif

		CExtractOptions eo;
		eo.StdInMode = options.StdInMode;
		eo.StdOutMode = options.StdOutMode;
		eo.PathMode = options.Command.GetPathMode();
		eo.TestMode = options.Command.IsTestMode();
		eo.OverwriteMode = options.OverwriteMode;
		eo.OutputDir = options.OutputDir;
		eo.YesToAll = options.YesToAll;
		eo.CalcCrc = options.CalcCrc;

#if !defined(_7ZIP_ST) && !defined(_SFX)
		eo.Properties = options.ExtractProperties;
#endif
		//ZDBS::_currentArchive = file_name_;

		UString errorMessage;
		CDecompressStat stat;
		HRESULT result = DecompressArchives(
			codecs_,
			formatIndices,
			options.ArchivePathsSorted,
//.........这里部分代码省略.........
开发者ID:daoluong,项目名称:zpack-library,代码行数:101,代码来源:zmodifyer.cpp

示例13: pw

unsigned char * zmodifyer::get( UString & file_name, size_t & size, wchar_t const * password /* = 0 */ )
{
	if( file_name.Length() == 0 )
		return 0;

	// 커맨드 스트링
	UStringVector commandStrings;

	commandStrings.Add( L"G" );

	UString pw( L"-P" );

	commandStrings.Add( (pw + ( password ? password : L"") ) );
	
	// multi thread
	commandStrings.Add( L"-MMT=+" );

	commandStrings.Add( L"-BD" );

	commandStrings.Add( file_name_ );

	commandStrings.Add( file_name );

	// 파싱된 커맨드라인 정보로 options 셋팅 ------------
	CArchiveCommandLineOptions options;
	
	//options.HelpMode = true;
	
	// 없는 파일이면 작업 중지
	if( !zdb_->db_.IsEmpty() )
	{
		typedef std::list< std::wstring > FileList;
		FileList files;

		std::wstring tmp = file_name;

		boost::split( files, tmp, boost::is_any_of(L":") );

		for( FileList::iterator iter = files.begin(); iter != files.end(); ++iter )
		{
			if( !zdb_->folder_.find( *iter ) )
				return 0;
		}
	}

	OptionSetting( commandStrings, options );
	options.OverwriteMode = NExtract::NOverwriteMode::kWithoutPrompt; // 덮어쓰기 할때 묻지마라.
	options.YesToAll = true;
	//------------

	// 압축파일 형식 인덱스 추출.
	CIntVector formatIndices;
	if (!codecs_->FindFormatForArchiveType(options.ArcType, formatIndices))
	{
		throw kUnsupportedArcTypeMessage;
	}

	bool isExtractGroupCommand = options.Command.IsFromExtractGroup();

	if (codecs_->Formats.Size() == 0 &&
		(isExtractGroupCommand ||
		options.Command.CommandType == NCommandType::kList ||
		options.Command.IsFromUpdateGroup()))
		throw kNoFormats;

	// 압축 해제
	if (isExtractGroupCommand)
	{
		CExtractCallbackConsole *ecs = new CExtractCallbackConsole;
		CMyComPtr<IFolderArchiveExtractCallback> extractCallback = ecs;

		ecs->OutStream = &outStream_;

#ifndef _NO_CRYPTO
		ecs->PasswordIsDefined = options.PasswordEnabled;
		ecs->Password = options.Password;
#endif

		ecs->Init();

		COpenCallbackConsole openCallback;
		openCallback.OutStream = &outStream_;

#ifndef _NO_CRYPTO
		openCallback.PasswordIsDefined = options.PasswordEnabled;
		openCallback.Password = options.Password;
#endif

		CExtractOptions eo;
		eo.StdInMode = options.StdInMode;
		eo.StdOutMode = options.StdOutMode;
		eo.PathMode = options.Command.GetPathMode();
		//eo.TestMode = options.Command.IsTestMode();
		eo.TestMode = true; // 테스트 모드로 압축해제(파일 저장 안함)
		eo.OverwriteMode = options.OverwriteMode;
		eo.OutputDir = options.OutputDir;
		eo.YesToAll = options.YesToAll;
		eo.CalcCrc = options.CalcCrc;

#if !defined(_7ZIP_ST) && !defined(_SFX)
//.........这里部分代码省略.........
开发者ID:daoluong,项目名称:zpack-library,代码行数:101,代码来源:zmodifyer.cpp

示例14: DoExtractArchive

int DoExtractArchive(UString archive, UString targetDir, bool overwrite, bool extractPaths, ExtractProgressHandler epc)
{
	CCodecs *codecs = new CCodecs;
	CMyComPtr<IUnknown> compressCodecsInfo = codecs;
	HRESULT result = codecs->Load();

	if (result != S_OK)
		throw CSystemException(result);

	if (codecs->Formats.Size() == 0) throw -1;

	CIntVector formatIndices;

	if (!codecs->FindFormatForArchiveType(L"7z", formatIndices))
	{
		throw -1;
	}

	BOOL bApisAreAnsi = AreFileApisANSI();

#ifdef _WIN32
	if (bApisAreAnsi)
		SwitchFileAPIEncoding(bApisAreAnsi);
#endif

	CExtractCallbackConsole *ecs = new CExtractCallbackConsole();
	CMyComPtr<IFolderArchiveExtractCallback> extractCallback = ecs;
	ecs->ProgressHandler = epc;
	wcsncpy(ecs->destDir, targetDir, MAX_PATH);
	ecs->Init();

	COpenCallbackConsole openCallback;

	CExtractOptions eo;
	eo.StdOutMode = false;
	eo.PathMode = extractPaths?NExtract::NPathMode::kCurPaths:NExtract::NPathMode::kNoPaths;
	eo.TestMode = false;
	eo.OverwriteMode = overwrite?NExtract::NOverwriteMode::kOverwrite:NExtract::NOverwriteMode::kSkip;
	eo.OutputDir = targetDir;
	eo.YesToAll = true;
#ifdef COMPRESS_MT
	CObjectVector<CProperty> prp;
	eo.Properties = prp;
#endif
	UString errorMessage;
	CDecompressStat stat;
	NWildcard::CCensor wildcardCensor;
	wildcardCensor.AddItem(NWildcard::ECensorPathMode::k_FullPath, true, L"*", true, true);
	UStringVector ArchivePathsSorted;
	UStringVector ArchivePathsFullSorted;
	ArchivePathsSorted.Add(archive);
	UString fullPath;
	NFile::NDir::MyGetFullPathName(archive, fullPath);
	ArchivePathsFullSorted.Add(fullPath);

	UStringVector v1, v2;
	v1.Add(fs2us(archive));
	v2.Add(fs2us(archive));
	const NWildcard::CCensorNode &wildcardCensorHead =
		wildcardCensor.Pairs.Front().Head;
	
	result = Extract(
		codecs, CObjectVector<COpenType>(), CIntVector(),
		v1, v2,
		wildcardCensorHead,
		eo, ecs, ecs,
		NULL, // hash
		errorMessage, stat);

#ifdef _WIN32
	if (bApisAreAnsi)
		SwitchFileAPIEncoding(!bApisAreAnsi);
#endif


	if (!errorMessage.IsEmpty())
	{
		if (result == S_OK)
		result = E_FAIL;
	}

	if (ecs->NumArchiveErrors != 0 || ecs->NumFileErrors != 0)
	{
		if (result != S_OK)
			throw CSystemException(result);

		return NExitCode::kFatalError;
	}

	if (result != S_OK)
		throw CSystemException(result);

  return 0;
}
开发者ID:liao0818,项目名称:nsis7z,代码行数:94,代码来源:Main.cpp

示例15: OnCopy

void CApp::OnCopy(bool move, bool copyToSame, int srcPanelIndex)
{
  int destPanelIndex = (NumPanels <= 1) ? srcPanelIndex : (1 - srcPanelIndex);
  CPanel &srcPanel = Panels[srcPanelIndex];
  CPanel &destPanel = Panels[destPanelIndex];

  CPanel::CDisableTimerProcessing disableTimerProcessing1(destPanel);
  CPanel::CDisableTimerProcessing disableTimerProcessing2(srcPanel);

  if (!srcPanel.DoesItSupportOperations())
  {
    srcPanel.MessageBoxErrorLang(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208);
    return;
  }

  CRecordVector<UInt32> indices;
  UString destPath;
  bool useDestPanel = false;

  {
    if (copyToSame)
    {
      int focusedItem = srcPanel._listView.GetFocusedItem();
      if (focusedItem < 0)
        return;
      int realIndex = srcPanel.GetRealItemIndex(focusedItem);
      if (realIndex == kParentIndex)
        return;
      indices.Add(realIndex);
      destPath = srcPanel.GetItemName(realIndex);
    }
    else
    {
      srcPanel.GetOperatedIndicesSmart(indices);
      if (indices.Size() == 0)
        return;
      destPath = destPanel._currentFolderPrefix;
      if (NumPanels == 1)
        ReducePathToRealFileSystemPath(destPath);
    }

    CCopyDialog copyDialog;
    UStringVector copyFolders;
    ReadCopyHistory(copyFolders);

    copyDialog.Strings = copyFolders;
    copyDialog.Value = destPath;
    
    copyDialog.Title = move ?
        LangString(IDS_MOVE, 0x03020202):
        LangString(IDS_COPY, 0x03020201);
    copyDialog.Static = move ?
        LangString(IDS_MOVE_TO, 0x03020204):
        LangString(IDS_COPY_TO, 0x03020203);

    copyDialog.Info = srcPanel.GetItemsInfoString(indices);

    if (copyDialog.Create(srcPanel.GetParent()) == IDCANCEL)
      return;

    destPath = copyDialog.Value;

    if (destPath.IsEmpty())
    {
      srcPanel.MessageBoxErrorLang(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208);
      return;
    }

    if (!IsPathAbsolute(destPath))
    {
      if (!srcPanel.IsFSFolder())
      {
        srcPanel.MessageBoxErrorLang(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208);
        return;
      }
      destPath = srcPanel._currentFolderPrefix + destPath;
    }

    #ifndef UNDER_CE
    if (destPath.Length() > 0 && destPath[0] == '\\')
      if (destPath.Length() == 1 || destPath[1] != '\\')
      {
        srcPanel.MessageBoxErrorLang(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208);
        return;
      }
    #endif

    if (indices.Size() > 1 ||
        (!destPath.IsEmpty() && destPath.Back() == WCHAR_PATH_SEPARATOR) ||
        NFind::DoesDirExist(us2fs(destPath)) ||
        srcPanel.IsArcFolder())
    {
      NDirectory::CreateComplexDirectory(us2fs(destPath));
      NName::NormalizeDirPathPrefix(destPath);
      if (!CheckFolderPath(destPath))
      {
        if (NumPanels < 2 || destPath != destPanel._currentFolderPrefix || !destPanel.DoesItSupportOperations())
        {
          srcPanel.MessageBoxErrorLang(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208);
          return;
//.........这里部分代码省略.........
开发者ID:Dabil,项目名称:puNES,代码行数:101,代码来源:App.cpp


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