Open Exchange App Tar compress tool in ObjectScript

I'm sure most of you have already familiar with the possibility of using GZIP in InterSystems products. But, the problem is that GZIP working only with one file or stream, and it does not support folders. When you work in Unix systems, there is a possibility how to solve it, using tar compress tool which goes with every Linux system from out of the box. But what to do if you have work on Windows as well, which does not have it. 

I am pleased to offer you my new project isc-tar, which will help you do not care about operating system, and deal with tar files anywhere.

Installation

  • Go to releases page, download latest zUtils.FileBinaryTar.xml.
  • Import and compile in a preferable way to any namespace.
    %SYS>Do $system.OBJ.Load("zUtils.FileBinaryTar.xml", "c")
  • And it now available from any place by class name %zUtils.FileBinaryTar

Requirements and limitations

It was tested on InterSystems IRIS Community Edition 2019.1, but should work on almost any versions. With one exception class %Stream.FileBinaryGzip which used to deal with gzip, was appeared in 2015.1.

At this time, this tool does not care about permissions stored in tar, just only the structure of folders and files content.

Usage

  • Compact any folder or just a file, where filename not required, it still returns compressed stream.
      Set gzip = 1
      Set archive = ##class(%zUtils.FileBinaryTar).Compact("/tmp/some/place", gzip, "/tmp/some.tgz")
    
  • Extract file to some temporary structure extended from %ArrayOfDatatypes, so, you can find any file if you know the exact name
      Set gzip = 1
      Set extracted = ##class(%zUtils.FileBinaryTar).ExtractFile("/tmp/some.tgz", gzip)
      Set tSC = extracted.FindPath("folder/subfolder/test.txt", .file)
      Set fileContent = file.fileData
      While 'fileContent.AtEnd {
        /// read file from archive
      }
    
  • Save extracted to some folder
      Set tSC = extracted.ExtractTo("/tmp/some/place")
    
  • Or extract just a stream
      Set extracted = ##class(%zUtils.FileBinaryTar).ExtractStream(stream)
    

Note: second parameter gzip is on by default.

Any issues or pull-requests always very welcome in the repository

Comments

Great!

Here's zip archive/unarchive support. Maybe you can unite these two projects?