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


C++ CInFileStream类代码示例

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


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

示例1: LZMADecodeFile

bool LZMADecodeFile ( const char *fromFile, const char *toFile, CProgressInfo7Zip *progress )
{
	CMyComPtr<ISequentialInStream> inStream;
	CInFileStream *inStreamSpec = new CInFileStream;
	inStream = inStreamSpec;

	if ( !inStreamSpec->Open ( GetSystemString(fromFile) ) )
		return false;

	CMyComPtr<ISequentialOutStream> outStream;
	COutFileStream *outStreamSpec = new COutFileStream;
	outStream = outStreamSpec;
	if ( !outStreamSpec->Create ( GetSystemString(toFile), true ) )
		return false;


	NCompress::NLZMA::CDecoder *decoderSpec = new NCompress::NLZMA::CDecoder;

	CMyComPtr<ICompressCoder> decoder = decoderSpec;

	const UInt32 kPropertiesSize = 5;
	Byte properties[kPropertiesSize];
	UInt32 processedSize;
	
	if ( ReadStream (inStream, properties, kPropertiesSize, &processedSize) != S_OK )
		return false;

	if ( processedSize != kPropertiesSize )
		return false;

	if ( decoderSpec->SetDecoderProperties2(properties, kPropertiesSize) != S_OK )
		return false;

	UInt64 fileSize = 0;
	for (int i = 0; i < 8; i++)
	{
	  Byte b;
	  if ( inStream->Read(&b, 1, &processedSize) != S_OK )
		  return false;

	  if ( processedSize != 1 )
		  return false;
	  fileSize |= ((UInt64)b) << (8 * i);
	}

	if ( progress )
	{
		progress->Init();
		progress->ApprovedStart = 1 << 21;
		progress->SetMax ( fileSize );
	}

	if ( decoder->Code(inStream, outStream, 0, &fileSize, progress) != S_OK )
		// decoder error
		return false;

	return true;
}
开发者ID:donbex,项目名称:spkutils,代码行数:58,代码来源:File.cpp

示例2: ReOpenArchive

HRESULT ReOpenArchive(IInArchive *archive, const UString &fileName, IArchiveOpenCallback *openArchiveCallback)
{
  CInFileStream *inStreamSpec = new CInFileStream;
  CMyComPtr<IInStream> inStream(inStreamSpec);
  inStreamSpec->Open(fileName);
  return archive->Open(inStream, &kMaxCheckStartPosition, openArchiveCallback);
}
开发者ID:yak1ex,项目名称:ax7z,代码行数:7,代码来源:OpenArchive.cpp

示例3: if

HRESULT CArc::OpenStreamOrFile(
    CCodecs *codecs,
    int formatIndex,
    bool stdInMode,
    IInStream *stream,
    IArchiveOpenCallback *callback)
{
  CMyComPtr<IInStream> fileStream;
  CMyComPtr<ISequentialInStream> seqStream;
  if (stdInMode)
    seqStream = new CStdInFileStream;
  else if (!stream)
  {
    CInFileStream *fileStreamSpec = new CInFileStream;
    fileStream = fileStreamSpec;
    if (!fileStreamSpec->Open(Path))
      return GetLastError();
    stream = fileStream;
  }

  /*
  if (callback)
  {
    UInt64 fileSize;
    RINOK(stream->Seek(0, STREAM_SEEK_END, &fileSize));
    RINOK(callback->SetTotal(NULL, &fileSize))
  }
  */

  return OpenStream(codecs, formatIndex, stream, seqStream, callback);
}
开发者ID:0963682490,项目名称:omaha,代码行数:31,代码来源:OpenArchive.cpp

示例4: RINOK

STDMETHODIMP P7ZipArchiveUpdateCallback::GetStream(UInt32 index, ISequentialInStream **inStream)
{
  RINOK(Finilize());

  const CDirItem &dirItem = (*DirItems)[index];
  GetStream2(dirItem.Name);
 
  if (dirItem.isDir())
    return S_OK;

  {
    CInFileStream *inStreamSpec = new CInFileStream;
    CMyComPtr<ISequentialInStream> inStreamLoc(inStreamSpec);
    UString path = DirPrefix + dirItem.FullPath;
    if (!inStreamSpec->Open(path))
    {
      DWORD sysError = ::GetLastError();
      FailedCodes.Add(sysError);
      FailedFiles.Add(path);
      // if (systemError == ERROR_SHARING_VIOLATION)
      {
        PrintNewLine();
        PrintError("WARNING: can't open file");
        // PrintString(NError::MyFormatMessageW(systemError));
        return S_FALSE;
      }
      // return sysError;
    }
    *inStream = inStreamLoc.Detach();
  }
  return S_OK;
}
开发者ID:gccli,项目名称:mylibrary,代码行数:32,代码来源:p7zip_callback.cpp

示例5: open_instream

int open_instream(const string infile,
		CMyComPtr<ISequentialInStream> &inStream,
		UInt64 &fileSize)
{
	CInFileStream *inStreamSpec = new CInFileStream;
	inStream = inStreamSpec;
	if (!inStreamSpec->Open(infile.c_str()))
		throw Exception("Cannot open input file " + infile);

	inStreamSpec->File.GetLength(fileSize);

	return inStreamSpec->File.GetHandle();
}
开发者ID:119,项目名称:aircam-openwrt,代码行数:13,代码来源:lzmp.cpp

示例6: OpenArchive

HRESULT OpenArchive(
    CCodecs *codecs,
    const UString &filePath, 
    IInArchive **archiveResult, 
    int &formatIndex,
    UString &defaultItemName,
    IArchiveOpenCallback *openArchiveCallback)
{
  CInFileStream *inStreamSpec = new CInFileStream;
  CMyComPtr<IInStream> inStream(inStreamSpec);
  if (!inStreamSpec->Open(filePath))
    return GetLastError();
  return OpenArchive(codecs, inStream, ExtractFileNameFromPath(filePath),
    archiveResult, formatIndex,
    defaultItemName, openArchiveCallback);
}
开发者ID:yak1ex,项目名称:ax7z,代码行数:16,代码来源:OpenArchive.cpp

示例7: RINOK

STDMETHODIMP CArchiveUpdateCallback::GetStream(UInt32 index, ISequentialInStream **inStream)
{
  COM_TRY_BEGIN
  const CUpdatePair2 &up = (*UpdatePairs)[index];
  if (!up.NewData)
    return E_FAIL;
  
  RINOK(Callback->CheckBreak());
  RINOK(Callback->Finilize());

  if (up.IsAnti)
  {
    return Callback->GetStream((*ArcItems)[up.ArcIndex].Name, true);
  }
  const CDirItem &di = DirItems->Items[up.DirIndex];
//  RINOK(Callback->GetStream(DirItems->GetLogPath(up.DirIndex), false));	// 削除
 
  /* 追加ここから */
  UString strLogPath = DirItems->GetLogPath(up.DirIndex);
  RINOK(Callback->GetStream(strLogPath, false));
  g_StdOut.GetProgressDialog()->AddWorkFile(strLogPath, strLogPath, di.Attrib, false, di.MTime, di.Size, 0, 0, L"");
  /* 追加ここまで */

  if (di.IsDir())
    return S_OK;

  if (StdInMode)
  {
    CStdInFileStream *inStreamSpec = new CStdInFileStream;
    CMyComPtr<ISequentialInStream> inStreamLoc(inStreamSpec);
    *inStream = inStreamLoc.Detach();
  }
  else
  {
    CInFileStream *inStreamSpec = new CInFileStream;
    CMyComPtr<ISequentialInStream> inStreamLoc(inStreamSpec);
    const UString path = DirItems->GetPhyPath(up.DirIndex);
    if (!inStreamSpec->OpenShared(us2fs(path), ShareForWrite))
    {
      return Callback->OpenFileError(path, ::GetLastError());
    }
    *inStream = inStreamLoc.Detach();
  }
  return S_OK;
  COM_TRY_END
}
开发者ID:NepiSys,项目名称:Walls-WL-6.0-Alpha-Developer-Edition,代码行数:46,代码来源:UpdateCallback.cpp

示例8: Open2

HRESULT CArchiveLink::ReOpen(CCodecs *codecs, const UString &filePath,
    IArchiveOpenCallback *callback)
{
  if (Arcs.Size() > 1)
    return E_NOTIMPL;

  if (Arcs.Size() == 0)
    return Open2(codecs, CIntVector(), false, NULL, filePath, 0);

  CMyComPtr<IArchiveOpenCallback> openCallbackNew;
  SetCallback(filePath, NULL, callback, openCallbackNew);

  CInFileStream *fileStreamSpec = new CInFileStream;
  CMyComPtr<IInStream> stream(fileStreamSpec);
  if (!fileStreamSpec->Open(filePath))
    return GetLastError();
  HRESULT res = GetArchive()->Open(stream, &kMaxCheckStartPosition, callback);
  IsOpen = (res == S_OK);
  return res;
}
开发者ID:0963682490,项目名称:omaha,代码行数:20,代码来源:OpenArchive.cpp

示例9: aec

bool vms7zipArchive::Extract(LPCSTR pszArchive, LPCSTR pszOutFolder)
{
	CInFileStream *fileSpec = new CInFileStream;
	CMyComPtr <IInStream> spFile = fileSpec;

	m_errExtract = AEE_GENERIC_ERROR;

	if (false == fileSpec->Open(pszArchive))
		return false;

	CMyComPtr <IInArchive> spArc;

	vms7zipFormatDLL dll;
	if (false == Find7zipDLL (dll, pszArchive, true, spFile, spArc) &&
			false == Find7zipDLL (dll, pszArchive, false, spFile, spArc))
		return false;

	m_errExtract = AEE_NO_ERROR;

	char sz [MY_MAX_PATH];
	fsGetFileName (pszArchive, sz);

	vms7zipArchiveExtractCallback aec (spArc, pszOutFolder, m_pAC, sz);
	HRESULT hr;
	if (FAILED (hr=spArc->Extract (NULL, (UInt32)-1, 0, &aec))) {
		spArc = NULL;
		m_errExtract = aec.is_AbortedByUser () ? AEE_ABORTED_BY_USER : AEE_GENERIC_ERROR;
		return false;
	}

	spArc = NULL;

	if (*aec.get_FurtherExtractFile () != 0) {
		
		bool b = Extract (aec.get_FurtherExtractFile (), pszOutFolder);
		DeleteFile (aec.get_FurtherExtractFile ());
		return b;
	}

	return true;
}
开发者ID:pedia,项目名称:raidget,代码行数:41,代码来源:vms7ziparchive.cpp

示例10: RINOK

STDMETHODIMP CArchiveUpdateCallback::GetStream(UInt32 index, ISequentialInStream **inStream)
{
  COM_TRY_BEGIN
  const CUpdatePair2 &updatePair = (*UpdatePairs)[index];
  if(!updatePair.NewData)
	return E_FAIL;
  
  RINOK(Callback->CheckBreak());
  RINOK(Callback->Finilize());

  if(updatePair.IsAnti)
  {
	return Callback->GetStream((*ArchiveItems)[updatePair.ArchiveItemIndex].Name, true);
  }
  const CDirItem &dirItem = (*DirItems)[updatePair.DirItemIndex];
  RINOK(Callback->GetStream(dirItem.Name, false));
 
  if(dirItem.IsDirectory())
	return S_OK;

  if (StdInMode)
  {
	CStdInFileStream *inStreamSpec = new CStdInFileStream;
	CMyComPtr<ISequentialInStream> inStreamLoc(inStreamSpec);
	*inStream = inStreamLoc.Detach();
  }
  else
  {
	CInFileStream *inStreamSpec = new CInFileStream;
	CMyComPtr<ISequentialInStream> inStreamLoc(inStreamSpec);
	UString path = DirPrefix + dirItem.FullPath;
	if(!inStreamSpec->OpenShared(path, ShareForWrite))
	{
	  return Callback->OpenFileError(path, ::GetLastError());
	}
	*inStream = inStreamLoc.Detach();
  }
  return S_OK;
  COM_TRY_END
}
开发者ID:AMDmi3,项目名称:symwars3,代码行数:40,代码来源:UpdateCallback.cpp

示例11: GetStream

STDMETHODIMP COpenArchiveCallback::GetStream(const wchar_t *name, IInStream **inStream)
{
  COM_TRY_BEGIN
  *inStream = NULL;
  if (_subArchiveMode)
    return S_FALSE;

  FString fullPath;
  if (!NFile::NName::GetFullPath(_folderPrefix, us2fs(name), fullPath))
    return S_FALSE;
  if (!_fileInfo.Find(fullPath))
    return S_FALSE;
  if (_fileInfo.IsDir())
    return S_FALSE;
  CInFileStream *inFile = new CInFileStream;
  CMyComPtr<IInStream> inStreamTemp = inFile;
  if (!inFile->Open(fullPath))
    return ::GetLastError();
  *inStream = inStreamTemp.Detach();
  return S_OK;
  COM_TRY_END
}
开发者ID:OwenTan,项目名称:AndroidP7zip,代码行数:22,代码来源:OpenCallback.cpp

示例12: GetStream

STDMETHODIMP COpenArchiveCallback::GetStream(const wchar_t *name,
    IInStream **inStream)
{
  *inStream = NULL;
  if (_subArchiveMode)
    return S_FALSE;

  NWindows::NFile::NFind::CFileInfoW fileInfo;

  UString fullPath = _folderPrefix + name;
  if (!NWindows::NFile::NFind::FindFile(fullPath, fileInfo))
    return S_FALSE;
  _fileInfo = fileInfo;
  if (_fileInfo.IsDir())
    return S_FALSE;
  CInFileStream *inFile = new CInFileStream;
  CMyComPtr<IInStream> inStreamTemp = inFile;
  if (!inFile->Open(fullPath))
    return ::GetLastError();
  *inStream = inStreamTemp.Detach();
  return S_OK;
}
开发者ID:Bernieboy,项目名称:nds4ios,代码行数:22,代码来源:OpenCallback.cpp

示例13: if

HRESULT CArc::OpenStreamOrFile(
    CCodecs *codecs,
    int formatIndex,
    bool stdInMode,
    IInStream *stream,
    IArchiveOpenCallback *callback)
{
  CMyComPtr<IInStream> fileStream;
  CMyComPtr<ISequentialInStream> seqStream;
  if (stdInMode)
    seqStream = new CStdInFileStream;
  else if (!stream)
  {
    CInFileStream *fileStreamSpec = new CInFileStream(true);
    fileStream = fileStreamSpec;
    if (!fileStreamSpec->Open(Path))
      return GetLastError();
    stream = fileStream;
  }

  return OpenStream(codecs, formatIndex, stream, seqStream, callback);
}
开发者ID:anyakichi,项目名称:CleanArchiver,代码行数:22,代码来源:OpenArchive.cpp

示例14: main2


//.........这里部分代码省略.........
	else
	  if (!GetNumber(s, numThreads))
		IncorrectCommand();
  }
  #endif

  if (command.CompareNoCase(L"b") == 0)
  {
	const UInt32 kNumDefaultItereations = 1;
	UInt32 numIterations = kNumDefaultItereations;
	{
	  if (paramIndex < nonSwitchStrings.Size())
		if (!GetNumber(nonSwitchStrings[paramIndex++], numIterations))
		  numIterations = kNumDefaultItereations;
	}
	return LzmaBenchCon(stderr, numIterations, numThreads, dictionary);
  }

  if (numThreads == (UInt32)-1)
	numThreads = 1;

  bool encodeMode = false;
  if (command.CompareNoCase(L"e") == 0)
	encodeMode = true;
  else if (command.CompareNoCase(L"d") == 0)
	encodeMode = false;
  else
	IncorrectCommand();

  bool stdInMode = parser[NKey::kStdIn].ThereIs;
  bool stdOutMode = parser[NKey::kStdOut].ThereIs;

  CMyComPtr<ISequentialInStream> inStream;
  CInFileStream *inStreamSpec = 0;
  if (stdInMode)
  {
	inStream = new CStdInFileStream;
	MY_SET_BINARY_MODE(stdin);
  }
  else
  {
	if (paramIndex >= nonSwitchStrings.Size())
	  IncorrectCommand();
	const UString &inputName = nonSwitchStrings[paramIndex++]; 
	inStreamSpec = new CInFileStream;
	inStream = inStreamSpec;
	if (!inStreamSpec->Open(GetSystemString(inputName)))
	{
	  fprintf(stderr, "\nError: can not open input file %s\n", 
		  (const char *)GetOemString(inputName));
	  return 1;
	}
  }

  CMyComPtr<ISequentialOutStream> outStream;
  COutFileStream *outStreamSpec = NULL;
  if (stdOutMode)
  {
	outStream = new CStdOutFileStream;
	MY_SET_BINARY_MODE(stdout);
  }
  else
  {
	if (paramIndex >= nonSwitchStrings.Size())
	  IncorrectCommand();
	const UString &outputName = nonSwitchStrings[paramIndex++]; 
开发者ID:AMDmi3,项目名称:symwars3,代码行数:67,代码来源:LzmaAlone.cpp

示例15: RINOK


//.........这里部分代码省略.........
  }


  CObjectVector<CArcItem> arcItems;
  if (GetArchive())
  {
    RINOK(ReadItems());
    EnumerateArchiveItems(this, _proxyArchive->RootFolder,  L"", arcItems);
  }

  CRecordVector<CUpdatePair2> updatePairs2;

  {
    CRecordVector<CUpdatePair> updatePairs;
    GetUpdatePairInfoList(dirItems, arcItems, fileTimeType, updatePairs);
    CAgUpCallbackImp upCallback(&arcItems, updateCallback100);
    UpdateProduce(updatePairs, actionSet, updatePairs2, &upCallback);
  }

  UInt32 numFiles = 0;
  for (i = 0; i < updatePairs2.Size(); i++)
    if (updatePairs2[i].NewData)
      numFiles++;
  
  if (updateCallback100)
  {
    RINOK(updateCallback100->SetNumFiles(numFiles));
  }
  
  CUpdateCallbackAgent updateCallbackAgent;
  updateCallbackAgent.SetCallback(updateCallback100);
  CArchiveUpdateCallback *updateCallbackSpec = new CArchiveUpdateCallback;
  CMyComPtr<IArchiveUpdateCallback> updateCallback(updateCallbackSpec );

  updateCallbackSpec->DirItems = &dirItems;
  updateCallbackSpec->ArcItems = &arcItems;
  updateCallbackSpec->UpdatePairs = &updatePairs2;
  updateCallbackSpec->Archive = GetArchive();
  updateCallbackSpec->Callback = &updateCallbackAgent;

  COutFileStream *outStreamSpec = new COutFileStream;
  CMyComPtr<IOutStream> outStream(outStreamSpec);
  UString archiveName = newArchiveName;
  {
    UString resultPath;
    int pos;
    if(!NFile::NDirectory::MyGetFullPathName(archiveName, resultPath, pos))
      return E_FAIL;
    NFile::NDirectory::CreateComplexDirectory(resultPath.Left(pos));
  }
  if (!outStreamSpec->Create(archiveName, true))
  {
    // ShowLastErrorMessage();
    return E_FAIL;
  }
  
  CMyComPtr<ISetProperties> setProperties;
  if (outArchive->QueryInterface(IID_ISetProperties, (void **)&setProperties) == S_OK)
  {
    if (m_PropNames.Size() == 0)
    {
      RINOK(setProperties->SetProperties(0, 0, 0));
    }
    else
    {
      CRecordVector<const wchar_t *> names;
      for(i = 0; i < m_PropNames.Size(); i++)
        names.Add((const wchar_t *)m_PropNames[i]);

      NWindows::NCOM::CPropVariant *propValues = new NWindows::NCOM::CPropVariant[m_PropValues.Size()];
      try
      {
        for (int i = 0; i < m_PropValues.Size(); i++)
          propValues[i] = m_PropValues[i];
        RINOK(setProperties->SetProperties(&names.Front(), propValues, names.Size()));
      }
      catch(...)
      {
        delete []propValues;
        return E_FAIL;
      }
      delete []propValues;
    }
  }
  m_PropNames.Clear();
  m_PropValues.Clear();

  if (sfxModule != NULL)
  {
    CInFileStream *sfxStreamSpec = new CInFileStream;
    CMyComPtr<IInStream> sfxStream(sfxStreamSpec);
    if (!sfxStreamSpec->Open(sfxModule))
      return E_FAIL;
      // throw "Can't open sfx module";
    RINOK(CopyBlock(sfxStream, outStream));
  }

  RINOK(outArchive->UpdateItems(outStream, updatePairs2.Size(),updateCallback));
  return outStreamSpec->Close();
}
开发者ID:BIAINC,项目名称:7Zip,代码行数:101,代码来源:AgentOut.cpp


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