Class DGZipFile

Inherits from:
Object
Conforms to:
DDataReadable, DDataWritable, DTextReadable, DTextWritable
Declared in:
DGZipFile.h

Class Hierarchy

    Object
      |
      +---DGZipFile

Class Description

The DGZipFile class implements a number of methods for opening of, writing to, reading from and closing of gzip files.

Example:
#include <stdio.h>
#include "ofc/DGZipFile.h"

int main(int argc, char *argv[])
{
  DGZipFile *file1 = [DGZipFile new];
  DGZipFile *file2 = [DGZipFile alloc];
  DText     *str;

  if ([file1 open :"example.gz" :"w"])   // Open a gzip text file for writing, default compression
  {
    if (![file1 writeLine :"First text line for example.gz."])  // Write a text line in the gzip file
      printf("exampel.gz could not be written:%d.\n", [file1 error]);

    if (![file1 writeLine :"Second text line for example.gz."])
      printf("exampel.gz could not be written:%d.\n", [file1 error]);

    [file1 close];
  }
  else
    printf("example.gz could not be opened for writing:%d.\n", [file1 error]);


  [file2 init :"example.gz" :"r"];       // Init and open a gzip file for reading

  if ([file2 isOpen])                    // Check if open succeeded
  {
    while (![file2 isEof])               // Read all lines
    {
      str = [file2 readLine];

      printf("%s\n", [str cstring]);

      [str free];
    }

    [file2 close];

    printf("example.gz succesfull read.\n");
  }
  else
    printf("example.gz could not be opened: %d\n", [file2 error]);

  [file1 free];                        // Cleanup
  [file2 free];

  return 0;
}
Last modified:
02-Aug-2008 (DGZipFile.h)

Instance Variables

private void *_file
the file pointer

Method Index


generated 06-Sep-2008 by ObjcDoc 3.0.0