2
* Copyright 2009 CrossWire Bible Society (http://www.crosswire.org)
3
* CrossWire Bible Society
7
* This program is free software; you can redistribute it and/or modify it
8
* under the terms of the GNU General Public License as published by the
9
* Free Software Foundation version 2.
11
* This program is distributed in the hope that it will be useful, but
12
* WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14
* General Public License for more details.
36
#ifndef NO_SWORD_NAMESPACE
37
using namespace sword;
40
class FileCompress: public SWCompress {
48
unsigned long GetChars(char *, unsigned long len);
49
unsigned long SendChars(char *, unsigned long len);
55
FileCompress::FileCompress(char *fname)
59
ufd = FileMgr::createPathAndFile(fname);
61
sprintf(buf, "%s.zzz", fname);
62
zfd = FileMgr::createPathAndFile(buf);
66
FileCompress::~FileCompress()
73
unsigned long FileCompress::GetChars(char *buf, unsigned long len)
75
return read(ifd, buf, len);
79
unsigned long FileCompress::SendChars(char *buf, unsigned long len)
81
return write(ofd, buf, len);
85
void FileCompress::Encode()
94
void FileCompress::Decode()
103
int main(int argc, char **argv)
109
fprintf(stderr, "usage: %s <filename|filename.zzz>\n", argv[0]);
113
if (strlen(argv[1]) > 4) {
114
if (!strcmp(&argv[1][strlen(argv[1])-4], ".zzz")) {
115
argv[1][strlen(argv[1])-4] = 0;
120
fobj = new FileCompress(argv[1]);