Archiver.st
changeset 1798 74535804fe1b
parent 1795 e52a638e2a81
child 1799 5bb8bb7d430f
equal deleted inserted replaced
1797:ef9ace7b0d6e 1798:74535804fe1b
   398 executeCommand:cmd directory:aDirectory
   398 executeCommand:cmd directory:aDirectory
   399 
   399 
   400 
   400 
   401     synchron isNil ifTrue:[synchron := true].
   401     synchron isNil ifTrue:[synchron := true].
   402     synchron ifTrue:[
   402     synchron ifTrue:[
   403          OperatingSystem 
   403         ^ OperatingSystem 
   404             executeCommand:cmd
   404             executeCommand:cmd
   405             inputFrom:nil
   405             inputFrom:nil
   406             outputTo:outStream
   406             outputTo:outStream
   407             errorTo:errorStream
   407             errorTo:errorStream
   408             inDirectory:aDirectory
   408             inDirectory:aDirectory
   424                 ].
   424                 ].
   425 
   425 
   426         ] priority:(Processor systemBackgroundPriority).
   426         ] priority:(Processor systemBackgroundPriority).
   427         process name:('Archiver command: ', cmd).
   427         process name:('Archiver command: ', cmd).
   428         process resume.
   428         process resume.
       
   429         ^true
   429     ]
   430     ]
   430 !
   431 !
   431 
   432 
   432 isValidOutputLine:line
   433 isValidOutputLine:line
   433     "return true, if line contains a valid list-files output line"
   434     "return true, if line contains a valid list-files output line"
   477 ! !
   478 ! !
   478 
   479 
   479 !Archiver::MultiFileArchive methodsFor:'actions'!
   480 !Archiver::MultiFileArchive methodsFor:'actions'!
   480 
   481 
   481 addFilesToArchive:colOfFiles
   482 addFilesToArchive:colOfFiles
   482     |cmd tempDir archivFile archivInTemp fileSize backupFile|
   483     |cmd tempDir archivFile archivInTemp fileSize backupFile result|
   483 
   484 
   484     archivFile := self fileName.
   485     archivFile := self fileName.
   485 
   486 
   486     tempDir := self temporaryDirectory.
   487     tempDir := self temporaryDirectory.
   487     archivInTemp := tempDir construct:(archivFile baseName).
   488     archivInTemp := tempDir construct:(archivFile baseName).
   507             file isDirectory
   508             file isDirectory
   508               ifTrue: [destName := tempDir]. 
   509               ifTrue: [destName := tempDir]. 
   509             file recursiveCopyTo:destName.
   510             file recursiveCopyTo:destName.
   510         ].
   511         ].
   511 
   512 
   512         "/ addFiles to the tar archive
   513         "/ addFiles to the archive. Synchron command execution answers
       
   514         "/ a boolean.
   513         cmd := self getCommandToAdd:colOfFiles toArchive:archivInTemp.
   515         cmd := self getCommandToAdd:colOfFiles toArchive:archivInTemp.
   514         self executeCommand:cmd directory:tempDir.
   516         result := self executeCommand:cmd directory:tempDir.
   515 
   517 
   516         "/ copy tar archiv back
   518         "/ copy the archive back
   517         archivInTemp copyTo:archivFile.
   519         (result == true and: [archivInTemp exists]) ifTrue:[
       
   520             archivInTemp copyTo:archivFile.
       
   521         ].
   518     ] ensure:[
   522     ] ensure:[
   519         "/ cg: remove the tempFile
   523         "/ cg: remove the tempFile
   520         archivInTemp remove.
   524         archivInTemp exists ifTrue:[ archivInTemp remove.].
   521         "/ cg: remove copied files
   525         "/ cg: remove copied files
   522        " colOfFiles do:[:file |
   526        " colOfFiles do:[:file |
   523             (tempDir construct:(file asFilename baseName)) remove.
   527             (tempDir construct:(file asFilename baseName)) remove.
   524         ]. "
   528         ]. "
   525         "/ boris: remove the temporary directory and its name, too.
   529         "/ boris: remove the temporary directory and its name, too.
   526         tempDir recursiveRemove.
   530         tempDir recursiveRemove.
   527         temporaryDirectory := nil.
   531         temporaryDirectory := nil.
   528 
   532     ].
   529     ].
   533 
       
   534     ^result == true.
   530 !
   535 !
   531 
   536 
   532 extractFiles:aColOfFilesOrNil to:aDirectory
   537 extractFiles:aColOfFilesOrNil to:aDirectory
   533     |execDir cmd|
   538     |execDir cmd|
   534 
   539 
  1289 ! !
  1294 ! !
  1290 
  1295 
  1291 !Archiver class methodsFor:'documentation'!
  1296 !Archiver class methodsFor:'documentation'!
  1292 
  1297 
  1293 version
  1298 version
  1294     ^ '$Header: /cvs/stx/stx/libbasic2/Archiver.st,v 1.30 2006-12-08 09:46:25 boris Exp $'
  1299     ^ '$Header: /cvs/stx/stx/libbasic2/Archiver.st,v 1.31 2007-01-09 15:07:19 boris Exp $'
  1295 ! !
  1300 ! !
  1296 
  1301 
  1297 Archiver initialize!
  1302 Archiver initialize!