troubleshooting Question

Compress in GZIP

Avatar of goldentine
goldentine asked on
Web Servers
3 Comments1 Solution383 ViewsLast Modified:
I have this function to Unzip Gzip compressed files.  What I need is to be able to compress files in the Gzip format.

Using this function as an example, how could I rewrite it to compress in to a "*.gz" file?  Thanks in advance.

 * Unzip a gzipped (.gz) file.
 * @param infilePath        Full path to gz file. (Required)
 * @param outputPath        Where to extract the gzfile. Defaults to current directory. (Optional)
 * @return Returns a boolean.
function gunzipFile(infilePath) {
      var zipfile = "";
      var outfile = "";
      var outputPath = "";
      var infile = "";
      var gzInStream = createObject('java','');
      var outStream = createObject('java','');
      var inStream = createObject('java','');
      var buffer = repeatString(" ",1024).getBytes();
      var length = 0;
      var rv = true;
      var e = "";
      if (arrayLen(Arguments) gte 2) outputPath = arguments[2];
      else outputPath = getDirectoryFromPath(infilePath);
      if (right(infilePath,3) neq '.gz') infilePath = infilePath & '.gz';
      if(right(outputPath,1) neq "/" and right(outputPath,1) neq "\") outputPath = outputPath & "/";

      try {
            infile = getFileFromPath(infilePath);
            outfile = outputPath & left(infile,len(infile) - 3);
            do {
                  length =,0,1024);
            if (length neq -1) outStream.write(buffer,0,length);
            } while (length neq -1);
      catch (any e) {
            rv = false;
            try {
            } catch (any e) { }
                  try {
                  } catch (any e) { }
      return rv;
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 3 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 3 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros