C+ C NAME: C iOSgunzip C PURPOSE: C Unzip zip file C CATEGORY: C gen/for/os C CALLING SEQUENCE: function iOSgunzip(cZipFile, cUnzippedFile) C INPUTS: C cZipFile character*(*) name of zipped file (with extension .gz) C OUTPUTS: C iOK integer 0: unzip not succesfull C 1: unzip succesfull C cUnzippedFile character*(*) name of unzipped file C the file is created in $temp with the same filename C as cZipFile with the prefix _tmp_ added. C CALLS: C iSetFileSpec, iGetFileSpec, iFilePath, Str2Str, iOSSpawnCmd C INCLUDE: include 'dirspec.h' include 'filparts.h' C RESTRICTIONS: C Input file name must have extension .gz C The gzip executable should be located in $smei/gen/exe/linux C Currently Linux and Windows is available. C The environment variable smei must be defined in $HOME/LOGFIL.TXT C PROCEDURE: C cUnzippedFile is modified only if the unzip is successfull, i.e. the call C iOK = iOSgunzip(cFile,cFile) C is legal, and modifies cFile only after gzip has been executed. C MODIFICATION HISTORY: C APR-2003, Paul Hick (UCSD/CASS; pphick@ucsd.edu) C- character cZipFile*(*) character cUnzippedFile*(*) character cSay*9 /'iOSgunzip'/ character cSubs(4)*8 /'ucsd','gen','exe',cOpSubdir/ character cFile*(FIL__LENGTH) character cStr *(FIL__LENGTH) integer Str2Str iOSgunzip = 0 I = iSetFileSpec(cZipFile) I = iGetFileSpec(FIL__NAME,FIL__TYPE,cStr) if (cStr(I-2:) .eq. '.gz') then ! File type is .gz cStr(I-2:) = '' ! Clear the .gz extension I = iFilePath(cTemp,0,' ','_tmp_', cFile) I = Str2Str(cStr,cFile(I+1:)) ! Name of output file in $temp if (cOpSys .eq. OS__DOS) then I = iFilePath(cEnvi//'smei',3,cSubs,'gzip',cStr)+1 else I = Str2Str('gzip',cStr)+1 ! gzip must be in PATH end if I = I+Str2Str('--decompress --stdout',cStr(I+1:))+1 I = I+Str2Str(cZipFile,cStr(I+1:))+1 I = I+Str2Str('> '//cFile, cStr(I+1:)) iOSgunzip = iOSSpawnCmd(cStr,0) if (iOSgunzip .eq. 1) cUnzippedFile = cFile end if return end