1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527
|
<?xml version="1.0" encoding="iso-8859-1"?>
<reference id="ref.zlib">
<title>Funciones de Compresión</title>
<titleabbrev>Zlib</titleabbrev>
<partintro>
<para>
Este módulo usa la función de <ulink url="&url.zlib;">zlib</ulink> de Jean-loup Gailly y Mark Adler para
leer y grabar archivos comprimidos .gz, de un modo transparente. Con este módulo, es requisito usar una versión
de zlib igual o posterior a 1.0.9.
</para>
<para>
Este módulo contiene versiones de la mayoría de las funciones de <link linkend="ref.filesystem">Sistema de archivos</link>
que funcionan con los archivos comprimidos con gzip (y con los no-comprimidos tambien, pero no con conectores (sockets)).
</para>
<sect1 id="zlib-example">
<title>Pequeño código de ejemlo</title>
<para>
Abre un archivo temporal y escribe en él, una cadena de prueba, y luego presenta el
cotenido del archivo dos veces
</para>
<example>
<title>Ejemplo de Zlib</title>
<programlisting role="php">
<?php
$filename = tempnam('/tmp', 'zlibtest').'.gz';
print "<html>\n<head></head>\n<body>\n<pre>\n";
$s = "Sólo es una prueba, prueba, prueba,prueba, prueba, prueba!\n";
// Abre el archivo para escribirlo con máximo de compresión
$zp = gzopen($filename, "w9");
// Escribe la cadena en él
gzwrite($zp, $s);
// Cierra el fichero
gzclose($zp);
// Abre el fichero para lectura
$zp = gzopen($filename, "r");
// Lee 3 caracteres
print gzread($zp, 3);
// Salida hasta el final del fichero, para cerrarlo luego.
gzpassthru($zp);
print "\n";
// Abre el fichero y muestra su contenido (por segunda vez).
if (readgzfile($filename) != strlen($s)) {
echo "Error con las funciones zlib!";
}
unlink($filename);
print "<pre>\n</h1></body>\n</html>\n";
?>
</programlisting>
</example></sect1>
</partintro>
<refentry id="function.gzclose">
<refnamediv>
<refname>gzclose</refname>
<refpurpose>cierra un puntero a archivo-gz abierto</refpurpose>
</refnamediv>
<refsect1>
<title>Descripción</title>
<methodsynopsis>
<type>int</type><methodname>gzclose</methodname>
<methodparam><type>int</type><parameter>zp</parameter></methodparam>
</methodsynopsis>
<para>
El archivo-gz al que apunta zp se cierra.</para>
<para>
Devuelve &true; (verdadero) si fue exitoso, si hubo errores devuelve &false;.</para>
<para>
El puntero al archivo-gz debe ser válido y debe apuntar
a un archivo correctamente abierto con <function>gzopen</function>.</para>
</refsect1>
</refentry>
<refentry id="function.gzeof">
<refnamediv>
<refname>gzeof</refname>
<refpurpose>prueba el fin-de-archivo de un puntero de archivo-gz</refpurpose>
</refnamediv>
<refsect1>
<title>Descripción</title>
<methodsynopsis>
<type>int</type><methodname>gzeof</methodname>
<methodparam><type>int</type><parameter>zp</parameter></methodparam>
</methodsynopsis>
<para>
Devuelve verdadero si el puntero-a-archivo está en el fin-de-archivo, o ha
ocurrido un error. De otro modo devuelve falso.</para>
<para>
El puntero al archivo-gz debe ser válido y debe apuntar
a un archivo correctamente abierto con <function>gzopen</function>.</para>
</refsect1>
</refentry>
<refentry id="function.gzfile">
<refnamediv>
<refname>gzfile</refname> <refpurpose>lee el archivo gz completo en un arreglo</refpurpose>
</refnamediv>
<refsect1>
<title>Descripción</title>
<methodsynopsis>
<type>array</type><methodname>gzfile</methodname>
<methodparam><type>string</type><parameter>nombre_archivo</parameter></methodparam>
<methodparam choice="opt"><type>int</type><parameter>usar_include_path</parameter></methodparam>
</methodsynopsis>
<para> Identico a <function>readgzfile</function>, solo que gzfile()
devuelve el fichero en un arreglo.</para>
<para>
Se puede usar el segundo parámetro opcional poniéndolo a "1",
si se quiere que la función busque también el archivo en la trayectoria definida como <link linkend="ini.include-path">include_path.</link></para>
<para> Vea también <function>readgzfile</function>, y
<function>gzopen</function>.</para>
</refsect1>
</refentry>
<refentry id="function.gzgetc">
<refnamediv>
<refname>gzgetc</refname>
<refpurpose>toma caracteres de un archivo-gz</refpurpose>
</refnamediv>
<refsect1>
<title>Descripción</title>
<methodsynopsis>
<type>cadena</type><methodname>gzgetc</methodname>
<methodparam><type>int</type><parameter>zp</parameter></methodparam>
</methodsynopsis>
<para>
Devuelve una cadena conteniendo un caracter en particular (sin comprimir)
leído del archivo al que apunta zp. Devuelve &false; cuando está al final
del archivo (al igual que <function>gzeof</function>).</para>
<para>
El puntero al archivo-gz debe ser válido y debe apuntar
a un archivo correctamente abierto con <function>gzopen</function>.</para>
<para> Vea también
<function>gzopen</function>, y
<function>gzgets</function>.</para>
</refsect1>
</refentry>
<refentry id="function.gzgets">
<refnamediv>
<refname>gzgets</refname>
<refpurpose>toma una linea del archivo apuntado</refpurpose>
</refnamediv>
<refsect1>
<title>Descripción</title>
<methodsynopsis>
<type>string</type><methodname>gzgets</methodname>
<methodparam><type>int</type><parameter>zp</parameter></methodparam>
<methodparam><type>int</type><parameter>longitud</parameter></methodparam>
</methodsynopsis>
<para>
Devuelve una cadena (descomprimida) con longitud - 1 bytes de largo,
leída del archivo apuntado por fp. La lectura finaliza cuando se han leído longitud - 1
bytes, ante un salto de linea o un fin-de-archivo (lo que ocurra primero).</para>
<para> Si ocurre un error, devuelve falso.</para>
<para>
El puntero al archivo-gz debe ser válido y debe apuntar
a un archivo correctamente abierto con <function>gzopen</function>.</para>
<para> Vea también <function>gzopen</function>,
<function>gzgetc</function>, y <function>fgets</function>.</para>
</refsect1>
</refentry>
<refentry id="function.gzgetss">
<refnamediv>
<refname>gzgetss</refname>
<refpurpose>toma una linea del archivo-gz apuntado y le quita los tags HTML</refpurpose>
</refnamediv>
<refsect1>
<title>Descripción</title>
<methodsynopsis>
<type>string</type><methodname>gzgetss</methodname>
<methodparam><type>int</type><parameter>zp</parameter></methodparam>
<methodparam><type>int</type><parameter>longitud</parameter></methodparam>
<methodparam choice="opt"><type>string</type><parameter>tags_permitidos</parameter></methodparam>
</methodsynopsis>
<para>
Idéntica a <function>gzgets</function>,
excepto que gzgetss intenta quitar cualquier "tag" HTML o PHP del texto que lee.</para>
<para>
Se puede usar el tercer parámetro para indicar qué parametros no deben ser extraídos.
<note>
<para>
<parameter>tags_permitidos</parameter> fue agregado en la versión de PHP 3.0.13, PHP4B3.</para>
</note></para>
<para>
Véase también <function>gzgets</function>,
<function>gzopen</function>, y <function>strip_tags</function>.</para>
</refsect1>
</refentry>
<refentry id="function.gzopen">
<refnamediv>
<refname>gzopen</refname>
<refpurpose>open gz-file</refpurpose>
</refnamediv>
<refsect1>
<title>Descripción</title>
<methodsynopsis>
<type>int</type><methodname>gzopen</methodname>
<methodparam><type>string</type><parameter>nombre_fichero</parameter></methodparam>
<methodparam><type>string</type><parameter>modo</parameter></methodparam>
<methodparam choice="opt"><type>int</type><parameter>use_include_path</parameter></methodparam>
</methodsynopsis>
<para>
Abre un archivo gzip (.gz) para lectura o escritura. El parámetro
modo es, como en <function>fopen</function> ("rb" o "wb") pero
puede incluir tambien el nivel de compresión ("wb9") o la estrategia: 'f'
para filtrado de datos como en "wb6f", 'h' para comprimir solo por Huffman
igual que en "wb1h". (Ver la descripción de deflateInit2 en zlib.h para más
información sobre el parámetro de estrategia.)</para>
<para>
Gzopen puede usarse para leer o escribir un fichero que no esté en formato gzip; en
ese caso <function>gzread</function> leerá el archivo directamente, sin descomprimirlo.</para>
<para>
Gzopen devuelve un puntero al archivo abierto y luego, cualquier proceso de lectura o escritura
relacionado con ese descriptor de archivo, será transparente: se comprimirá o descomprimirá
los datos según la necesidad, de manera automática.</para>
<para>
Si la apertura fallase, se devolverá falso.</para>
<para>
Se puede usar el tercer parámetro opcional, poniéndolo a "1", si se
quiere buscar también el fichero en la trayectoria <link linkend="ini.include-path">include_path</link>.</para>
<para><example>
<title>ejemplo de gzopen() </title>
<programlisting>
$fp = gzopen("/tmp/file.gz", "r");
</programlisting></example></para>
<para>
Vea también <function>gzclose</function>.</para>
</refsect1>
</refentry>
<refentry id="function.gzpassthru">
<refnamediv>
<refname>gzpassthru</refname>
<refpurpose>Devuelve el remanente de datos de un fichero-gz</refpurpose>
</refnamediv>
<refsect1>
<title>Descripción</title>
<methodsynopsis>
<type>int</type><methodname>gzpassthru</methodname>
<methodparam><type>int</type><parameter>zp</parameter></methodparam>
</methodsynopsis>
<para>
Lee hasta el Fin-De-Archivo del archivo gz dado, y escribe los resultados
(descomprimidos) en la salida standard.</para>
<para>
Si ocurre un error, devuelve Falso.</para>
<para>
El puntero al archivo-gz debe ser válido y debe apuntar
a un archivo correctamente abierto con <function>gzopen</function>.</para>
<para>
El archivo-gz es cerrado cuando <function>gzpassthru</function> termina de leerlo
(dejando <parameter>zp</parameter> sin utilidad).</para>
</refsect1>
</refentry>
<refentry id="function.gzputs">
<refnamediv>
<refname>gzputs</refname>
<refpurpose>escribe al fichero-gz que se apunta</refpurpose>
</refnamediv>
<refsect1>
<title>Descripción</title>
<methodsynopsis>
<type>int</type><methodname>gzputs</methodname>
<methodparam><type>int</type><parameter>zp</parameter></methodparam>
<methodparam><type>string</type><parameter>str</parameter></methodparam>
<methodparam choice="opt"><type>int</type><parameter>longitud</parameter></methodparam>
</methodsynopsis>
<para>
<function>gzputs</function> es un alias a
<function>gzwrite</function>, y es absolutamente idéntico.</para>
</refsect1>
</refentry>
<refentry id="function.gzread">
<refnamediv>
<refname>gzread</refname>
<refpurpose>Lee archivos-gz en modo Binario</refpurpose>
</refnamediv>
<refsect1>
<title>Descripción</title>
<methodsynopsis>
<type>string</type><methodname>gzread</methodname>
<methodparam><type>int</type><parameter>zp</parameter></methodparam>
<methodparam><type>int</type><parameter>longitud</parameter></methodparam>
</methodsynopsis>
<simpara>
<function>gzread</function> lee hasta
<parameter>longitud</parameter> bytes del archivo-gz apuntado por el parámetro
<parameter>zp</parameter>. La lectura termina cuando se han leído
<parameter>longitud</parameter> bytes (descomprimidos) o se
alcanza el fin-de-archivo, lo que sucediera primero.</simpara>
<para>
<informalexample>
<programlisting>
// Pone los contenidos del gz, a una cadena
$filename = "/usr/local/algo.txt.gz";
$zd = gzopen( $filename, "r" );
$contents = gzread( $zd, 10000 );
gzclose( $zd );
</programlisting>
</informalexample></para>
<simpara>
Ver también <function>gzwrite</function>, <function>gzopen</function>,
<function>gzgets</function>, <function>gzgetss</function>,
<function>gzfile</function>, y <function>gzpassthru</function>.</simpara>
</refsect1>
</refentry>
<refentry id="function.gzrewind">
<refnamediv>
<refname>gzrewind</refname>
<refpurpose>Reposiciona al puntero de archivo-gz, al inicio de aquel</refpurpose>
</refnamediv>
<refsect1>
<title>Descripción</title>
<methodsynopsis>
<type>int</type><methodname>gzrewind</methodname>
<methodparam><type>int</type><parameter>zp</parameter></methodparam>
</methodsynopsis>
<para> Reubica el indicador de posición del archivo, al comienzo del mismo.</para>
<para> si surge un error, devuelve 0.</para>
<para> El puntero al archivo-gz debe ser válido y debe apuntar
a un archivo correctamente abierto con <function>gzopen</function>.</para>
<para>
Ver también: <function>gzseek</function> y <function>gztell</function>.</para>
</refsect1>
</refentry>
<refentry id="function.gzseek">
<refnamediv>
<refname>gzseek</refname>
<refpurpose>Posiciona el puntero del archivo-gz</refpurpose>
</refnamediv>
<refsect1>
<title>Descripción</title>
<methodsynopsis>
<type>int</type><methodname>gzseek</methodname>
<methodparam><type>int</type><parameter>zp</parameter></methodparam>
<methodparam><type>int</type><parameter>offset</parameter></methodparam>
</methodsynopsis>
<para>
Busca la posición dentro del archivo zp, indicada en bytes por el parametro de
desplazamiento offset. Es equivalente a llamar (en C)
<literal>gzseek( zp, offset, SEEK_SET )</literal>.</para>
<para>
Si el archivo se abre para lectura, la función será emulada, pero puede ponerse
extremadamente lenta. Si se trata de escritura, solo está soportada
la búsqueda hacia adelante; gzseek comprime entonces una secuencia de ceros
hasta que alcanza la nueva ubicación.</para>
<para>
Si se completa el pedido con éxito, devuelve 0; de lo contrario, devuelve -1. Note que la busqueda
más allá del fin-de-archivo no se considera un error.</para>
<para>
Vea también <function>gztell</function> y
<function>gzrewind</function>.</para>
</refsect1>
</refentry>
<refentry id="function.gztell">
<refnamediv>
<refname>gztell</refname>
<refpurpose>Indica la posición de lecto-escritura en el archivo</refpurpose>
</refnamediv>
<refsect1>
<title>Descripción</title>
<methodsynopsis>
<type>int</type><methodname>gztell</methodname>
<methodparam><type>int</type><parameter>zp</parameter></methodparam>
</methodsynopsis>
<para>
Devuelve la posición dentro del fichero referido por zp; p.e.,
su desplazamiento en el cuerpo del archivo.</para>
<para>
Si hay algún error, devuelve falso.</para>
<para>
El puntero al archivo-gz debe ser válido y debe apuntar
a un archivo correctamente abierto con <function>gzopen</function>.</para>
<para> Ver también <function>gzopen</function>,
<function>gzseek</function> y <function>gzrewind</function>.</para>
</refsect1>
</refentry>
<refentry id="function.gzwrite">
<refnamediv>
<refname>gzwrite</refname>
<refpurpose>Escritura de ficheros gz en modo Binario</refpurpose>
</refnamediv>
<refsect1>
<title>Descripción</title>
<methodsynopsis>
<type>int</type><methodname>gzwrite</methodname>
<methodparam><type>int</type><parameter>zp</parameter></methodparam>
<methodparam><type>string</type><parameter>cadena</parameter></methodparam>
<methodparam choice="opt"><type>int</type><parameter>largo</parameter></methodparam>
</methodsynopsis>
<simpara>
<function>gzwrite</function> escribe el contenido de
<parameter>cadena</parameter> al fichero gz referido por <parameter>zp</parameter>.
Si el parámetro <parameter>largo</parameter>
está presente, se detendrá la escritura luego de escribir
<parameter>largo</parameter> bytes (descomprimidos) o al llegar el final de la <parameter>cadena</parameter>,
lo que ocurriese primero.</simpara>
<simpara>
Note que si se pasa el argumento <parameter>largo</parameter>,
la opcion <link linkend="ini.magic-quotes-runtime">magic_quotes_runtime</link>
será ignorada y no se quitarán barras de la <parameter>cadena</parameter> en cuestión.</simpara>
<simpara>
Ver también <function>gzread</function>, <function>gzopen</function>,
y <function>gzputs</function>.</simpara>
</refsect1>
</refentry>
<refentry id="function.readgzfile">
<refnamediv>
<refname>readgzfile</refname>
<refpurpose>devuelve el fichero-gz</refpurpose>
</refnamediv>
<refsect1>
<title>Descripción</title>
<methodsynopsis>
<type>int</type><methodname>readgzfile</methodname>
<methodparam><type>string</type><parameter>nombre_archivo</parameter></methodparam>
<methodparam choice="opt"><type>int</type><parameter>usar_trayectoria_include</parameter></methodparam>
</methodsynopsis>
<para> Lee el archivo, lo descomprime y lo escribe en la salida estándar.</para>
<para>
Readgzfile() puede usarse para leer un archivo comprimido o no con gzip;
en cuyo caso readgzfile() leerá directamente el archivo, sin descomprimirlo.</para>
<para> Devuelve el numero de bytes (descomprimidos) leídos del archivo,
si ocurre un error, se devuelve falso y hasta que se llame como @readgzfile,
se imprime un mensaje de error.</para>
<para> El archivo <parameter>nombre_archivo</parameter> se abrirá en el sistema de archivos
y su contenido enviado a la salida estándar.</para>
<para>
Puede usarse el segundo paametro opcional dándole el valor "1", si se quiere
que se busque el archivo también dentro de la trayectoria "include": <link linkend="ini.include-path">include_path</link>.</para>
<para>
Ver también <function>gzpassthru</function>,
<function>gzfile</function>, y <function>gzopen</function>.</para>
</refsect1>
</refentry>
</reference>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
indent-tabs-mode:nil
sgml-parent-document:nil
sgml-default-dtd-file:"../manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
-->
|