Example #1
0
File: Main.cpp Project: bks/qz7
int Main2(
  #ifndef _WIN32
  int numArguments, const char *arguments[]
  #endif
)
{
  #ifdef _WIN32
  SetFileApisToOEM();
  #endif
  
  g_StdOut << kCopyrightString;

  UStringVector commandStrings;
  #ifdef _WIN32
  NCommandLineParser::SplitCommandLine(GetCommandLineW(), commandStrings);
  #else
  GetArguments(numArguments, arguments, commandStrings);
  #endif

  UString archiveName = commandStrings.Front();

  commandStrings.Delete(0);

  NCommandLineParser::CParser parser(kNumSwitches);
  try
  {
    parser.ParseStrings(kSwitchForms, commandStrings);
  }
  catch(...)
  {
    PrintHelpAndExit();
  }

  if(parser[NKey::kHelp1].ThereIs || parser[NKey::kHelp2].ThereIs)
  {
    PrintHelp();
    return 0;
  }
  const UStringVector &nonSwitchStrings = parser.NonSwitchStrings;

  int numNonSwitchStrings = nonSwitchStrings.Size();

  CArchiveCommand command;
  if (numNonSwitchStrings == 0)
    command.CommandType = NCommandType::kFullExtract;
  else
  {
    if (numNonSwitchStrings > 1)
      PrintHelpAndExit();
    if (!ParseArchiveCommand(nonSwitchStrings[kCommandIndex], command))
      PrintHelpAndExit();
  }


  NRecursedType::EEnum recursedType;
  recursedType = command.DefaultRecursedType();

  NWildcard::CCensor wildcardCensor;
  
  bool thereAreSwitchIncludeWildCards;
  thereAreSwitchIncludeWildCards = false;
  AddToCensorFromNonSwitchesStrings(wildcardCensor, nonSwitchStrings, recursedType,
      thereAreSwitchIncludeWildCards);

  bool yesToAll = parser[NKey::kYes].ThereIs;

  #ifdef _WIN32
  if (archiveName.Right(kDefaultExtLength).CompareNoCase(kDefaultExt) != 0)
    archiveName += kDefaultExt;
  #endif

  // NExtractMode::EEnum extractMode;
  // bool isExtractGroupCommand = command.IsFromExtractGroup(extractMode);

  bool passwordEnabled = parser[NKey::kPassword].ThereIs;

  UString password;
  if(passwordEnabled)
    password = parser[NKey::kPassword].PostStrings[0];

  NFind::CFileInfoW archiveFileInfo;
  if (!NFind::FindFile(archiveName, archiveFileInfo))
    throw kCantFindSFX;
  if (archiveFileInfo.IsDir())
    throw kCantFindSFX;
  
  UString outputDir;
  if(parser[NKey::kOutputDir].ThereIs)
  {
    outputDir = parser[NKey::kOutputDir].PostStrings[0];
    NName::NormalizeDirPathPrefix(outputDir);
  }

  {
    UStringVector v1, v2;
    v1.Add(archiveName);
    v2.Add(archiveName);
    const NWildcard::CCensorNode &wildcardCensorHead =
      wildcardCensor.Pairs.Front().Head;

    CCodecs *codecs = new CCodecs;
    CMyComPtr<
      #ifdef EXTERNAL_CODECS
      ICompressCodecsInfo
      #else
      IUnknown
      #endif
      > compressCodecsInfo = codecs;
    HRESULT result = codecs->Load();
    if (result != S_OK)
      throw CSystemException(result);

    if(command.CommandType != NCommandType::kList)
    {
      CExtractCallbackConsole *ecs = new CExtractCallbackConsole;
      CMyComPtr<IFolderArchiveExtractCallback> extractCallback = ecs;
      ecs->OutStream = g_StdStream;
      ecs->PasswordIsDefined = passwordEnabled;
      ecs->Password = password;
      ecs->Init();

      COpenCallbackConsole openCallback;
      openCallback.OutStream = g_StdStream;
      openCallback.PasswordIsDefined = passwordEnabled;
      openCallback.Password = password;

      CExtractOptions eo;
      eo.StdOutMode = false;
      eo.PathMode = NExtract::NPathMode::kFullPathnames;
      eo.TestMode = command.CommandType == NCommandType::kTest;
      eo.OverwriteMode = yesToAll ?
          NExtract::NOverwriteMode::kWithoutPrompt :
          NExtract::NOverwriteMode::kAskBefore;
      eo.OutputDir = outputDir;
      eo.YesToAll = yesToAll;

      UString errorMessage;
      CDecompressStat stat;
      HRESULT result = DecompressArchives(
          codecs, CIntVector(),
          v1, v2,
          wildcardCensorHead,
          eo, &openCallback, ecs, errorMessage, stat);
      if (!errorMessage.IsEmpty())
      {
        (*g_StdStream) << endl << "Error: " << errorMessage;;
        if (result == S_OK)
          result = E_FAIL;
      }

      if (ecs->NumArchiveErrors != 0 || ecs->NumFileErrors != 0)
      {
        if (ecs->NumArchiveErrors != 0)
          (*g_StdStream) << endl << "Archive Errors: " << ecs->NumArchiveErrors << endl;
        if (ecs->NumFileErrors != 0)
          (*g_StdStream) << endl << "Sub items Errors: " << ecs->NumFileErrors << endl;
        return NExitCode::kFatalError;
      }
      if (result != S_OK)
        throw CSystemException(result);
    }
    else
    {
      UInt64 numErrors = 0;
      HRESULT result = ListArchives(
          codecs, CIntVector(),
          v1, v2,
          wildcardCensorHead,
          true, false,
          passwordEnabled,
          password, numErrors);
      if (numErrors > 0)
      {
        g_StdOut << endl << "Errors: " << numErrors;
        return NExitCode::kFatalError;
      }
      if (result != S_OK)
        throw CSystemException(result);
    }
  }
  return 0;
}
Example #2
0
int Main2(
#ifndef _WIN32
    int numArgs, char *args[]
#endif
)
{
#if defined(_WIN32) && !defined(UNDER_CE)
    SetFileApisToOEM();
#endif

    g_StdOut << kCopyrightString;

    UStringVector commandStrings;
#ifdef _WIN32
    NCommandLineParser::SplitCommandLine(GetCommandLineW(), commandStrings);
#else
    // GetArguments(numArgs, args, commandStrings);
    mySplitCommandLine(numArgs,args,commandStrings);
#endif

#ifdef _WIN32

    FString arcPath;
    {
        FString path;
        NDLL::MyGetModuleFileName(path);
        if (!MyGetFullPathName(path, arcPath))
        {
            g_StdOut << "GetFullPathName Error";
            return NExitCode::kFatalError;
        }
    }

#else
    // After mySplitCommandLine
    showP7zipInfo(&g_StdOut);

    UString arcPath = commandStrings.Front();

#endif

    commandStrings.Delete(0);

    NCommandLineParser::CParser parser(kNumSwitches);
    try
    {
        parser.ParseStrings(kSwitchForms, commandStrings);
    }
    catch(...)
    {
        PrintHelpAndExit();
    }

    if (parser[NKey::kHelp1].ThereIs || parser[NKey::kHelp2].ThereIs)
    {
        PrintHelp();
        return 0;
    }
    const UStringVector &nonSwitchStrings = parser.NonSwitchStrings;

    int numNonSwitchStrings = nonSwitchStrings.Size();

    CArchiveCommand command;
    if (numNonSwitchStrings == 0)
        command.CommandType = NCommandType::kFullExtract;
    else
    {
        if (numNonSwitchStrings > 1)
            PrintHelpAndExit();
        if (!ParseArchiveCommand(nonSwitchStrings[kCommandIndex], command))
            PrintHelpAndExit();
    }


    NRecursedType::EEnum recursedType;
    recursedType = command.DefaultRecursedType();

    NWildcard::CCensor wildcardCensor;

    bool thereAreSwitchIncludeWildcards;
    thereAreSwitchIncludeWildcards = false;

    AddToCensorFromNonSwitchesStrings(wildcardCensor, nonSwitchStrings, recursedType,
                                      thereAreSwitchIncludeWildcards);

    bool yesToAll = parser[NKey::kYes].ThereIs;

    // NExtractMode::EEnum extractMode;
    // bool isExtractGroupCommand = command.IsFromExtractGroup(extractMode);

    bool passwordEnabled = parser[NKey::kPassword].ThereIs;

    UString password;
    if (passwordEnabled)
        password = parser[NKey::kPassword].PostStrings[0];

    if (!NFind::DoesFileExist(arcPath))
        throw kCantFindSFX;

    FString outputDir;
    if (parser[NKey::kOutputDir].ThereIs)
    {
        outputDir = us2fs(parser[NKey::kOutputDir].PostStrings[0]);
        NName::NormalizeDirPathPrefix(outputDir);
    }


    wildcardCensor.AddPathsToCensor(NWildcard::k_RelatPath);

    {
        UStringVector v1, v2;
        v1.Add(fs2us(arcPath));
        v2.Add(fs2us(arcPath));
        const NWildcard::CCensorNode &wildcardCensorHead =
            wildcardCensor.Pairs.Front().Head;

        CCodecs *codecs = new CCodecs;
        CMyComPtr<
#ifdef EXTERNAL_CODECS
        ICompressCodecsInfo
#else
        IUnknown
#endif
        > compressCodecsInfo = codecs;
        {
            HRESULT result = codecs->Load();
            if (result != S_OK)
                throw CSystemException(result);
        }

        if (command.CommandType != NCommandType::kList)
        {
            CExtractCallbackConsole *ecs = new CExtractCallbackConsole;
            CMyComPtr<IFolderArchiveExtractCallback> extractCallback = ecs;
            ecs->Init(g_StdStream, &g_StdErr, g_StdStream);

#ifndef _NO_CRYPTO
            ecs->PasswordIsDefined = passwordEnabled;
            ecs->Password = password;
#endif

            /*
            COpenCallbackConsole openCallback;
            openCallback.Init(g_StdStream, g_StdStream);

            #ifndef _NO_CRYPTO
            openCallback.PasswordIsDefined = passwordEnabled;
            openCallback.Password = password;
            #endif
            */

            CExtractOptions eo;
            eo.StdOutMode = false;
            eo.YesToAll = yesToAll;
            eo.TestMode = command.CommandType == NCommandType::kTest;
            eo.PathMode = NExtract::NPathMode::kFullPaths;
            eo.OverwriteMode = yesToAll ?
                               NExtract::NOverwriteMode::kOverwrite :
                               NExtract::NOverwriteMode::kAsk;
            eo.OutputDir = outputDir;

            UString errorMessage;
            CDecompressStat stat;
            HRESULT result = Extract(
                                 codecs, CObjectVector<COpenType>(), CIntVector(),
                                 v1, v2,
                                 wildcardCensorHead,
                                 eo, ecs, ecs,
                                 // NULL, // hash
                                 errorMessage, stat);
            if (!errorMessage.IsEmpty())
            {
                (*g_StdStream) << endl << "Error: " << errorMessage;;
                if (result == S_OK)
                    result = E_FAIL;
            }

            if (ecs->NumArcsWithError != 0 || ecs->NumFileErrors != 0)
            {
                if (ecs->NumArcsWithError != 0)
                    (*g_StdStream) << endl << "Archive Errors" << endl;
                if (ecs->NumFileErrors != 0)
                    (*g_StdStream) << endl << "Sub items Errors: " << ecs->NumFileErrors << endl;
                return NExitCode::kFatalError;
            }
            if (result != S_OK)
                throw CSystemException(result);
        }
        else
        {
            throw CSystemException(E_NOTIMPL);

            /*
            UInt64 numErrors = 0;
            UInt64 numWarnings = 0;
            HRESULT result = ListArchives(
                codecs, CObjectVector<COpenType>(), CIntVector(),
                false, // stdInMode
                v1, v2,
                true, // processAltStreams
                false, // showAltStreams
                wildcardCensorHead,
                true, // enableHeaders
                false, // techMode
                #ifndef _NO_CRYPTO
                passwordEnabled, password,
                #endif
                numErrors, numWarnings);
            if (numErrors > 0)
            {
              g_StdOut << endl << "Errors: " << numErrors;
              return NExitCode::kFatalError;
            }
            if (result != S_OK)
              throw CSystemException(result);
            */
        }
    }
    return 0;
}
Example #3
0
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;
}
int Main2(
  #ifndef _WIN32
  int numArguments, const char *arguments[]
  #endif
)
{
  #ifdef _WIN32
  SetFileApisToOEM();
  #endif
  
  UStringVector commandStrings;
  #ifdef _WIN32
  NCommandLineParser::SplitCommandLine(GetCommandLineW(), commandStrings);
  #else
  extern void mySplitCommandLine(int numArguments,const char *arguments[],UStringVector &parts);
  mySplitCommandLine(numArguments,arguments,commandStrings);
  #endif

  // After mySplitCommandLine
  g_StdOut << kCopyrightString << " (locale=" << my_getlocale() <<",Utf16=";
  if (global_use_utf16_conversion) g_StdOut << "on";
  else                             g_StdOut << "off";
  g_StdOut << ",HugeFiles=";
  if (sizeof(off_t) >= 8) g_StdOut << "on,";
  else                    g_StdOut << "off,";
  int nbcpu = NWindows::NSystem::GetNumberOfProcessors();
  if (nbcpu > 1) g_StdOut << nbcpu << " CPUs)\n";
  else           g_StdOut << nbcpu << " CPU)\n";
 
  UString arcPath = commandStrings.Front();

  commandStrings.Delete(0);

  NCommandLineParser::CParser parser(kNumSwitches);
  try
  {
    parser.ParseStrings(kSwitchForms, commandStrings);
  }
  catch(...)
  {
    PrintHelpAndExit();
  }

  if(parser[NKey::kHelp1].ThereIs || parser[NKey::kHelp2].ThereIs)
  {
    PrintHelp();
    return 0;
  }
  const UStringVector &nonSwitchStrings = parser.NonSwitchStrings;

  int numNonSwitchStrings = nonSwitchStrings.Size();

  CArchiveCommand command;
  if (numNonSwitchStrings == 0)
    command.CommandType = NCommandType::kFullExtract;
  else
  {
    if (numNonSwitchStrings > 1)
      PrintHelpAndExit();
    if (!ParseArchiveCommand(nonSwitchStrings[kCommandIndex], command))
      PrintHelpAndExit();
  }


  NRecursedType::EEnum recursedType;
  recursedType = command.DefaultRecursedType();

  NWildcard::CCensor wildcardCensor;
  
  bool thereAreSwitchIncludeWildCards;
  thereAreSwitchIncludeWildCards = false;
  AddToCensorFromNonSwitchesStrings(wildcardCensor, nonSwitchStrings, recursedType,
      thereAreSwitchIncludeWildCards);

  bool yesToAll = parser[NKey::kYes].ThereIs;

  // NExtractMode::EEnum extractMode;
  // bool isExtractGroupCommand = command.IsFromExtractGroup(extractMode);

  bool passwordEnabled = parser[NKey::kPassword].ThereIs;

  UString password;
  if(passwordEnabled)
    password = parser[NKey::kPassword].PostStrings[0];

  if (!NFind::DoesFileExist(arcPath))
    throw kCantFindSFX;
  
  UString outputDir;
  if (parser[NKey::kOutputDir].ThereIs)
  {
    outputDir = parser[NKey::kOutputDir].PostStrings[0];
    NName::NormalizeDirPathPrefix(outputDir);
  }

  {
    UStringVector v1, v2;
    v1.Add(arcPath);
    v2.Add(arcPath);
    const NWildcard::CCensorNode &wildcardCensorHead =
      wildcardCensor.Pairs.Front().Head;

    CCodecs *codecs = new CCodecs;
    CMyComPtr<
      #ifdef EXTERNAL_CODECS
      ICompressCodecsInfo
      #else
      IUnknown
      #endif
      > compressCodecsInfo = codecs;
    HRESULT result = codecs->Load();
    if (result != S_OK)
      throw CSystemException(result);

    if(command.CommandType != NCommandType::kList)
    {
      CExtractCallbackConsole *ecs = new CExtractCallbackConsole;
      CMyComPtr<IFolderArchiveExtractCallback> extractCallback = ecs;
      ecs->OutStream = g_StdStream;

      #ifndef _NO_CRYPTO
      ecs->PasswordIsDefined = passwordEnabled;
      ecs->Password = password;
      #endif

      ecs->Init();

      COpenCallbackConsole openCallback;
      openCallback.OutStream = g_StdStream;

      #ifndef _NO_CRYPTO
      openCallback.PasswordIsDefined = passwordEnabled;
      openCallback.Password = password;
      #endif

      CExtractOptions eo;
      eo.StdOutMode = false;
      eo.PathMode = NExtract::NPathMode::kFullPathnames;
      eo.TestMode = command.CommandType == NCommandType::kTest;
      eo.OverwriteMode = yesToAll ?
          NExtract::NOverwriteMode::kWithoutPrompt :
          NExtract::NOverwriteMode::kAskBefore;
      eo.OutputDir = outputDir;
      eo.YesToAll = yesToAll;

      UString errorMessage;
      CDecompressStat stat;
      HRESULT result = DecompressArchives(
          codecs, CIntVector(),
          v1, v2,
          wildcardCensorHead,
          eo, &openCallback, ecs, errorMessage, stat);
      if (!errorMessage.IsEmpty())
      {
        (*g_StdStream) << endl << "Error: " << errorMessage;;
        if (result == S_OK)
          result = E_FAIL;
      }

      if (ecs->NumArchiveErrors != 0 || ecs->NumFileErrors != 0)
      {
        if (ecs->NumArchiveErrors != 0)
          (*g_StdStream) << endl << "Archive Errors: " << ecs->NumArchiveErrors << endl;
        if (ecs->NumFileErrors != 0)
          (*g_StdStream) << endl << "Sub items Errors: " << ecs->NumFileErrors << endl;
        return NExitCode::kFatalError;
      }
      if (result != S_OK)
        throw CSystemException(result);
    }
    else
    {
      UInt64 numErrors = 0;
      HRESULT result = ListArchives(
          codecs, CIntVector(),
          false,
          v1, v2,
          wildcardCensorHead,
          true, false,
          #ifndef _NO_CRYPTO
          passwordEnabled, password,
          #endif
          numErrors);
      if (numErrors > 0)
      {
        g_StdOut << endl << "Errors: " << numErrors;
        return NExitCode::kFatalError;
      }
      if (result != S_OK)
        throw CSystemException(result);
    }
  }
  return 0;
}
Example #5
0
// 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,
			options.ArchivePathsFullSorted,
			options.WildcardCensor.Pairs.Front().Head,
			eo, &openCallback, ecs, errorMessage, stat, zdb_);

		if( result == S_OK )
			return true;
	}

	return false;
}
Example #6
0
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)
		eo.Properties = options.ExtractProperties;
#endif

		//ZDBS::_currentArchive = file_name_;

		UString errorMessage;
		CDecompressStat stat;
		HRESULT result = DecompressArchives(
			codecs_,
			formatIndices,
			options.ArchivePathsSorted,
			options.ArchivePathsFullSorted,
			options.WildcardCensor.Pairs.Front().Head,
			eo, &openCallback, ecs, errorMessage, stat, zdb_);
	}

	return CIOStream::Read( size );
}