home *** CD-ROM | disk | FTP | other *** search
/ Columbia Kermit / kermit.zip / archives / tools.zip / unjar < prev   
Text File  |  2011-08-19  |  828b  |  35 lines

  1. #!/opt/local/bin/kermit +
  2. #
  3. # Break a "jar" (join archive) file apart into its constituent files.
  4. #
  5. if != \v(argc) 2 {
  6.   echo " Usage: \fword(\%0,-1) jarfilename"
  7.   exit 1
  8. }
  9. fopen /read \%c \%1
  10. if fail exit 1
  11. .lines = 0
  12. .files = 0
  13. while 1 {
  14.     fread /line /trim \%c line
  15.     if fail {
  16.     if files fclose \%o 
  17.         exit 0 OK
  18.     }
  19.     increment lines
  20.     if == files 0 if not match "\m(line)" "<<< * >>>" continue
  21.     if  match "\m(line)" "<<< * >>>" {
  22.     if files fclose \%o
  23.         if fail exit 1 FCLOSE FAILED    
  24.         echo OK
  25.     .name := \fword(\m(line),2,\32,ALL)            
  26.     fopen /write \%o \m(name)
  27.     if fail exit 1 OPEN /WRITE FAILED: \m(name)
  28.         increment files
  29.     xecho \m(name)...
  30.         continue
  31.     }
  32.     fwrite /line \%o \m(line)    
  33.     if fail exit 1 FWRITE /LINE FAILED
  34. }
  35.