<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <HTML ><HEAD ><TITLE >Bzip2</TITLE ><META NAME="GENERATOR" CONTENT="Modular DocBook HTML Stylesheet Version 1.79"><LINK REL="HOME" TITLE="Manual do PHP" HREF="index.html"><LINK REL="UP" TITLE="Referência das Funções" HREF="funcref.html"><LINK REL="PREVIOUS" TITLE="bcompiler_write_included_filename" HREF="function.bcompiler-write-included-filename.html"><LINK REL="NEXT" TITLE="bzclose" HREF="function.bzclose.html"><META HTTP-EQUIV="Content-type" CONTENT="text/html; charset=UTF-8"></HEAD ><BODY CLASS="reference" BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#0000FF" VLINK="#840084" ALINK="#0000FF" ><DIV CLASS="NAVHEADER" ><TABLE SUMMARY="Header navigation table" WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" ><TR ><TH COLSPAN="3" ALIGN="center" >Manual do PHP</TH ></TR ><TR ><TD WIDTH="10%" ALIGN="left" VALIGN="bottom" ><A HREF="function.bcompiler-write-included-filename.html" ACCESSKEY="P" >Anterior</A ></TD ><TD WIDTH="80%" ALIGN="center" VALIGN="bottom" ></TD ><TD WIDTH="10%" ALIGN="right" VALIGN="bottom" ><A HREF="function.bzclose.html" ACCESSKEY="N" >Próxima</A ></TD ></TR ></TABLE ><HR ALIGN="LEFT" WIDTH="100%"></DIV ><DIV CLASS="reference" ><A NAME="ref.bzip2" ></A ><DIV CLASS="TITLEPAGE" ><H1 CLASS="title" >IX. Bzip2</H1 ><DIV CLASS="PARTINTRO" ><A NAME="AEN14233" ></A ><DIV CLASS="section" ><H1 CLASS="section" ><A NAME="bzip2.intro" >Introdução</A ></H1 ><P > As funções para bzip2 são usadas para ler e escrever, de forma transparente, arquivos compactados do tipo bzip2 (.bz2). </P ></DIV ><DIV CLASS="section" ><H1 CLASS="section" ><A NAME="bzip2.requirements" >Dependências</A ></H1 ><P > Este módulo utiliza as funções da biblioteca <A HREF="http://www.bzip.org/" TARGET="_top" >bzip2</A > desenvolvida por Julian Seward </P ></DIV ><DIV CLASS="section" ><H1 CLASS="section" ><A NAME="bzip2.installation" >Instalação</A ></H1 ><P > O suporte às funções para Bzip2 no PHP não é habilitado por padrão. Você precisa usar a opção de configuração <A HREF="missing-stuff.html#install.configure.with-bz2" >--with-bz2</A > quando for compilar o PHP para habilitar o suporte a bzip2. Este módulo requer bzip2/libbzip2, versão >= 1.0.x. </P ></DIV ><DIV CLASS="section" ><H1 CLASS="section" ><A NAME="bzip2.configuration" >Configurações em execução</A ></H1 ><P >Esta extensão não define nenhum parâmetro de configuração no <TT CLASS="filename" >php.ini</TT >.</P ></DIV ><DIV CLASS="section" ><H1 CLASS="section" ><A NAME="bzip2.resources" >Tipos Resource</A ></H1 ><P > Esta extensão define um tipo de recurso (resource): um ponteiro para arquivo que identifica o arquivo bzip2 que está sendo usado. </P ></DIV ><DIV CLASS="section" ><H1 CLASS="section" ><A NAME="bzip2.constants" >Constantes pré-definidas</A ></H1 ><P >Esta extensão não possui nenhuma constante.</P ></DIV ><DIV CLASS="section" ><H1 CLASS="section" ><A NAME="bzip2.examples" >Exemplos</A ></H1 ><P > Este exemplo abre um arquivo temporário e escreve uma string de test nele, e então mostra o conteúdo do arquivo. </P ><TABLE WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" CLASS="EXAMPLE" ><TR ><TD ><DIV CLASS="example" ><A NAME="AEN14258" ></A ><P ><B >Exemplo 1. Um exemplo simples de bzip2</B ></P ><TABLE BORDER="0" BGCOLOR="#E0E0E0" CELLPADDING="5" ><TR ><TD ><code><font color="#000000"> <font color="#0000BB"><?php<br /><br />$arquivo </font><font color="#007700">= </font><font color="#DD0000">"/tmp/testfile.bz2"</font><font color="#007700">;<br /></font><font color="#0000BB">$str </font><font color="#007700">= </font><font color="#DD0000">"This is a test string.\n"</font><font color="#007700">;<br /><br /></font><font color="#FF8000">// abre o arquivo para escrita<br /></font><font color="#0000BB">$bz </font><font color="#007700">= </font><font color="#0000BB">bzopen</font><font color="#007700">(</font><font color="#0000BB">$arquivo</font><font color="#007700">, </font><font color="#DD0000">"w"</font><font color="#007700">);<br /><br /></font><font color="#FF8000">// escreve a string no arquivo<br /></font><font color="#0000BB">bzwrite</font><font color="#007700">(</font><font color="#0000BB">$bz</font><font color="#007700">, </font><font color="#0000BB">$str</font><font color="#007700">);<br /><br /></font><font color="#FF8000">// fecha o arquivo<br /></font><font color="#0000BB">bzclose</font><font color="#007700">(</font><font color="#0000BB">$bz</font><font color="#007700">);<br /><br /></font><font color="#FF8000">// abre o arquivo para leitura<br /></font><font color="#0000BB">$bz </font><font color="#007700">= </font><font color="#0000BB">bzopen</font><font color="#007700">(</font><font color="#0000BB">$arquivo</font><font color="#007700">, </font><font color="#DD0000">"r"</font><font color="#007700">);<br /><br /></font><font color="#FF8000">// lê 10 caracteres<br /></font><font color="#007700">echo </font><font color="#0000BB">bzread</font><font color="#007700">(</font><font color="#0000BB">$bz</font><font color="#007700">, </font><font color="#0000BB">10</font><font color="#007700">);<br /><br /></font><font color="#FF8000">// imprime até o final do arquivo (ou os próximos 1024 caracteres) <br /></font><font color="#007700">echo </font><font color="#0000BB">bzread</font><font color="#007700">(</font><font color="#0000BB">$bz</font><font color="#007700">);<br /><br /></font><font color="#FF8000">// fecha o arquivo<br /></font><font color="#0000BB">bzclose</font><font color="#007700">(</font><font color="#0000BB">$bz</font><font color="#007700">);<br /><br /></font><font color="#0000BB">?></font> </font> </code></TD ></TR ></TABLE ></DIV ></TD ></TR ></TABLE ></DIV ></DIV ><DIV CLASS="TOC" ><DL ><DT ><B >Índice</B ></DT ><DT ><A HREF="function.bzclose.html" >bzclose</A > -- Fecha um ponteiro de arquivo bzip2</DT ><DT ><A HREF="function.bzcompress.html" >bzcompress</A > -- Comprime uma string em dados no formato bzip2</DT ><DT ><A HREF="function.bzdecompress.html" >bzdecompress</A > -- Descomprime dados no formato bzip2</DT ><DT ><A HREF="function.bzerrno.html" >bzerrno</A > -- Retorna um número de erro do bzip2</DT ><DT ><A HREF="function.bzerror.html" >bzerror</A > -- Retorna o número e string de erro do bzip2 como um array</DT ><DT ><A HREF="function.bzerrstr.html" >bzerrstr</A > -- Retorna a string de erro do bzip2</DT ><DT ><A HREF="function.bzflush.html" >bzflush</A > -- Força a escrita de todos os dados que estão no buffer</DT ><DT ><A HREF="function.bzopen.html" >bzopen</A > -- Abre um arquivo comprimido com bzip2</DT ><DT ><A HREF="function.bzread.html" >bzread</A > -- Leitura binary-safe de um arquivo bzip2</DT ><DT ><A HREF="function.bzwrite.html" >bzwrite</A > -- Escrita binary-safe em um arquivo bzip2</DT ></DL ></DIV ></DIV ></DIV ><DIV CLASS="NAVFOOTER" ><HR ALIGN="LEFT" WIDTH="100%"><TABLE SUMMARY="Footer navigation table" WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" ><TR ><TD WIDTH="33%" ALIGN="left" VALIGN="top" ><A HREF="function.bcompiler-write-included-filename.html" ACCESSKEY="P" >Anterior</A ></TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="index.html" ACCESSKEY="H" >Principal</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" ><A HREF="function.bzclose.html" ACCESSKEY="N" >Próxima</A ></TD ></TR ><TR ><TD WIDTH="33%" ALIGN="left" VALIGN="top" >bcompiler_write_included_filename</TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="funcref.html" ACCESSKEY="U" >Acima</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" >bzclose</TD ></TR ></TABLE ></DIV ></BODY ></HTML >