program notgzip; import Compress; import Binary; import System; import IO; Void compressFile(String fn) { cfile = open(fn,[Read]); ofile = open(fn+".ez",[Write]); IO::putStr(ofile,fn); fblocks = []; while(!eof(cfile)) { push(fblocks,readBlock(cfile, 655350)); } putInt(ofile, size(fblocks)); putStrLn("Writing "+size(fblocks)+" blocks"); for b in fblocks { compressed = compressBinary(b); csize = blockSize(compressed); putInt(ofile, csize); writeBlock(ofile,compressed); } close(cfile); close(ofile); } Void uncompressFile(String fn) { ofile = open(fn,[Read]); // Read original name onm = getString(ofile); cfile = open(onm,[Write]); putStrLn("Uncompressing "+onm); blocks = getInt(ofile); putStrLn("Reading "+blocks+" blocks"); // Read blocks for x in [1..blocks] { // Get block length chunkLength = getInt(ofile); putStrLn("Length "+chunkLength); b = readBlock(ofile, chunkLength); unb = uncompressBinary(b, 655350); writeBlock(cfile, unb); } close(cfile); close(ofile); } Void usage() { putStrLn("notgzip (c) 2005 Edwin Brady"); putStrLn("----------------------------"); putStrLn("Usage: notgzip [file] [-c|-u]"); exit(1); } Void main() { args = getArgs(); if (size(args)<2) { usage(); } fn = args[1]; if (args[2]=="-c") { compressFile(fn); } else if (args[2]=="-u") { uncompressFile(fn); } else { usage(); } }