Object
|
+---DBZipFile
The DBZipFile class implements a number of methods for opening of, writing to, reading from and closing of bzip2 files. See the open method for used settings for the bzip2 library.
#include <stdio.h>
#include "ofc/DBZipFile.h"
int main(int argc, char *argv[])
{
DBZipFile *file = [DBZipFile new];
DText *str;
char name[] = "output.bz2";
if ([file open :name :"w"]) // Open a bzipped text file for writing
{
if (![file writeLine :"A line full of text .."])
printf("\"%s\" could not be written: %d\n", name, [file error]);
[file close];
printf("\"%s\" succesfull written.\n", name);
}
else
printf("\"%s\" could not be opened: %d\n", name, [file error]);
if ([file open :name :"r"]) // Open a bzipped text file for reading
{
while (![file isEof]) // Read all lines
{
str = [file readLine];
printf("%s\n", [str cstring]);
[str free];
}
[file close];
printf("\"%s\" succesfull read.\n", name);
}
else
printf("\"%s\" could not be opened: %d\n", name, [file error]);
[file free];
return 0;
}