⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 lzoutwindow.cpp

📁 7-Zip 3.11的源码
💻 CPP
字号:
// LZOutWindow.cpp

#include "StdAfx.h"

#include "LZOutWindow.h"

void CLZOutWindow::Create(UINT32 windowSize)
{
  _pos = 0;
  _streamPos = 0;
  UINT32 newBlockSize = windowSize;
  const UINT32 kMinBlockSize = 1;
  if (newBlockSize < kMinBlockSize)
    newBlockSize = kMinBlockSize;
  if (_buffer != 0 && _windowSize == newBlockSize)
    return;
  delete []_buffer;
  _buffer = 0;
  _windowSize = newBlockSize;
  _buffer = new BYTE[_windowSize];
}

CLZOutWindow::~CLZOutWindow()
{
  // ReleaseStream();
  delete []_buffer;
}

/*
void CLZOutWindow::SetWindowSize(UINT32 windowSize)
{
  _windowSize = windowSize;
}
*/

void CLZOutWindow::Init(ISequentialOutStream *stream, bool solid)
{
  // ReleaseStream();
  _stream = stream;
  // _stream->AddRef();

  if(!solid)
  {
    _streamPos = 0;
    _pos = 0;
  }
}

/*
void CLZOutWindow::ReleaseStream()
{
  if(_stream != 0)
  {
    // Flush(); // Test it
    _stream->Release();
    _stream = 0;
  }
}
*/

void CLZOutWindow::FlushWithCheck()
{
  HRESULT result = Flush();
  if (result != S_OK)
    throw CLZOutWindowException(result);
}

HRESULT CLZOutWindow::Flush()
{
  UINT32 size = _pos - _streamPos;
  if(size == 0)
    return S_OK;
  UINT32 processedSize;
  HRESULT result = _stream->Write(_buffer + _streamPos, size, &processedSize);
  if (result != S_OK)
    return result;
  if (size != processedSize)
    return E_FAIL;
  if (_pos >= _windowSize)
    _pos = 0;
  _streamPos = _pos;
  return S_OK;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -