343 extractTo:aDirectory with:extractFiles |
313 extractTo:aDirectory with:extractFiles |
344 |
314 |
345 self unzipTo:aDirectory |
315 self unzipTo:aDirectory |
346 ! |
316 ! |
347 |
317 |
348 listFilesFromArchiv |
318 listFilesFromArchive |
349 |
319 |
350 | cmd dir| |
320 | cmd dir| |
351 |
321 |
352 self fileName isNil ifTrue:[ ^ self]. |
322 self fileName isNil ifTrue:[ ^ self]. |
353 dir := self fileName directory. |
323 dir := self fileName directory. |
354 cmd := self getFileListFromArchivCommand. |
324 cmd := self getFileListFromArchiveCommand. |
355 self executeCommand:cmd directory:dir |
325 self executeCommand:cmd directory:dir |
356 ! |
326 ! |
357 |
327 |
358 listFilesFromArchiv:aCol |
328 listFilesFromArchive:aCol |
359 |
329 |
360 self listFilesFromArchiv |
330 self listFilesFromArchive |
361 ! |
331 ! |
362 |
332 |
363 unzipTo:aDirectory |
333 unzipTo:aDirectory |
364 |
334 |
365 | cmd file newFile| |
335 | cmd file newFile| |
398 ! ! |
368 ! ! |
399 |
369 |
400 !Archiver::GZipArchive methodsFor:'command strings'! |
370 !Archiver::GZipArchive methodsFor:'command strings'! |
401 |
371 |
402 getFileListFromArchivCommand |
372 getFileListFromArchivCommand |
403 |
373 ^ 'gzip -l -v %1' bindWith:self fileName baseName |
404 | stream cmd| |
|
405 |
|
406 stream := WriteStream on:''. |
|
407 stream nextPutAll:self class GZipArchivZipCommand. |
|
408 stream space. |
|
409 stream nextPut:$-. |
|
410 stream nextPut:self class GZipArchivZipListOption. |
|
411 stream space. |
|
412 stream nextPut:$-. |
|
413 stream nextPut:self class GZipArchivZipVerboseOption. |
|
414 stream space. |
|
415 stream nextPutAll:self fileName baseName. |
|
416 cmd := stream contents. |
|
417 stream close. |
|
418 ^ cmd |
|
419 ! |
374 ! |
420 |
375 |
421 getUnzipCommand |
376 getUnzipCommand |
422 |
377 ^ self getUnzipCommandForFile:(self fileName baseName) |
423 | stream cmd| |
378 ! |
424 |
379 |
425 stream := WriteStream on:''. |
380 getUnzipCommandForFile:aFileName |
426 stream nextPutAll:self class GZipArchivUnzipCommand. |
381 ^ 'gunzip %1' bindWith:aFileName asString |
427 stream space. |
|
428 stream nextPutAll:self fileName baseName. |
|
429 cmd := stream contents. |
|
430 stream close. |
|
431 ^ cmd |
|
432 ! |
|
433 |
|
434 getUnzipCommandForFile:aFileName |
|
435 |
|
436 | stream cmd| |
|
437 |
|
438 stream := WriteStream on:''. |
|
439 stream nextPutAll:self class GZipArchivUnzipCommand. |
|
440 stream space. |
|
441 stream nextPutAll:aFileName asString. |
|
442 cmd := stream contents. |
|
443 stream close. |
|
444 ^ cmd |
|
445 ! |
382 ! |
446 |
383 |
447 getZipCommandForFile:aFileName |
384 getZipCommandForFile:aFileName |
448 |
385 ^ 'gzip %1' bindWith:aFileName asString |
449 | stream cmd| |
|
450 |
|
451 stream := WriteStream on:''. |
|
452 stream nextPutAll:self class GZipArchivZipCommand. |
|
453 stream space. |
|
454 stream nextPutAll:aFileName asString. |
|
455 cmd := stream contents. |
|
456 stream close. |
|
457 ^ cmd |
|
458 ! |
386 ! |
459 |
387 |
460 getZipCommandForFile:aFile to:newFile |
388 getZipCommandForFile:aFile to:newFile |
461 | stream cmd| |
389 ^ 'gzip -c %1 > %2' bindWith:aFile asString with:newFile asString |
462 |
|
463 stream := WriteStream on:''. |
|
464 stream nextPutAll:self class GZipArchivZipCommand. |
|
465 stream space. |
|
466 stream nextPut:$-. |
|
467 stream nextPutAll:self class GZipArchivWriteToStdioOption. |
|
468 stream space. |
|
469 stream nextPutAll:aFile asString. |
|
470 stream space. |
|
471 stream nextPut:$>. |
|
472 stream space. |
|
473 stream nextPutAll:newFile asString. |
|
474 cmd := stream contents. |
|
475 stream close. |
|
476 ^ cmd |
|
477 ! ! |
390 ! ! |
478 |
391 |
479 !Archiver::TarArchive class methodsFor:'columns'! |
392 !Archiver::TarArchive class methodsFor:'columns'! |
480 |
393 |
481 columns |
394 columns |
528 |
455 |
529 "/ copy tar archiv to tempDir |
456 "/ copy tar archiv to tempDir |
530 archivFile copyTo:archivInTemp. |
457 archivFile copyTo:archivInTemp. |
531 |
458 |
532 "/ addFiles to the tar archive |
459 "/ addFiles to the tar archive |
533 cmd := self getAddFilesToTarArchiveCommandForArchiv:archivInTemp with:colOfFiles. |
460 cmd := self getAddFilesToTarArchiveCommandForArchive:archivInTemp with:colOfFiles. |
534 self executeCommand:cmd directory:tempDir. |
461 self executeCommand:cmd directory:tempDir. |
535 |
462 |
536 "/ copy tar archiv back |
463 "/ copy tar archiv back |
537 archivInTemp copyTo:(self fileName). |
464 archivInTemp copyTo:(self fileName). |
538 ! |
465 ! |
564 tempFile recursiveCopyTo:(aDirectory construct:(aFileString asFilename baseName)). |
491 tempFile recursiveCopyTo:(aDirectory construct:(aFileString asFilename baseName)). |
565 ]. |
492 ]. |
566 ]. |
493 ]. |
567 ! |
494 ! |
568 |
495 |
569 listFilesFromArchiv |
496 listFilesFromArchive |
570 |
497 |
571 self listFilesFromArchiv:nil |
498 self listFilesFromArchive:nil |
572 ! |
499 ! |
573 |
500 |
574 listFilesFromArchiv:newColOfFiles |
501 listFilesFromArchive:newColOfFiles |
575 |
502 |
576 | cmd dir| |
503 | cmd dir| |
577 |
504 |
578 self fileName isNil ifTrue:[ ^ self]. |
505 self fileName isNil ifTrue:[ ^ self]. |
579 dir := self fileName directory. |
506 dir := self fileName directory. |
580 cmd := self getFileListFromArchivCommand:newColOfFiles. |
507 cmd := self getFileListFromArchiveCommand:newColOfFiles. |
581 self executeCommand:cmd directory:dir |
508 self executeCommand:cmd directory:dir |
582 ! |
509 ! |
583 |
510 |
584 removeFilesFromArchiv:aColOfFiles |
511 removeFilesFromArchive:aColOfFiles |
585 |
512 |
586 |cmd| |
513 |cmd| |
587 |
514 |
588 cmd := self getRemoveFilesFromTarArchivFor:aColOfFiles. |
515 cmd := self getRemoveFilesFromTarArchiveCommandFor:aColOfFiles. |
589 self executeCommand:cmd directory:(self fileName directory). |
516 self executeCommand:cmd directory:(self fileName directory). |
590 ! ! |
517 ! ! |
591 |
518 |
592 !Archiver::TarArchive methodsFor:'command strings'! |
519 !Archiver::TarArchive methodsFor:'command strings'! |
593 |
520 |
594 getAddFilesToTarArchiveCommandForArchiv:archivFile with:aColOfFiles |
521 getAddFilesToTarArchiveCommandForArchive:archivFile with:aColOfFiles |
595 | cmd stream| |
522 |stream| |
596 |
523 |
597 archivFile exists ifTrue:[ |
524 archivFile exists ifFalse:[^ nil]. |
598 stream := WriteStream on:''. |
525 |
599 |
526 stream := WriteStream on:''. |
600 "/ 'r' TarArchivAddOption |
527 |
601 "/ 'f' TarArchivFileOption |
528 "/ 'r' TarArchivAddOption |
602 stream nextPutAll:('%1 -rf "%2"' |
529 "/ 'f' TarArchivFileOption |
603 bindWith:self class TarArchivCommand |
530 stream nextPutAll:('%1 -rf "%2"' |
604 with:archivFile asString string). |
531 bindWith:self class tarArchiveCommand |
605 |
532 with:archivFile asString string). |
606 aColOfFiles do:[:el | |
533 |
607 stream nextPutAll:' "'. |
534 stream nextPutAll:(self class stringWithQuotedFileBaseNames:aColOfFiles). |
608 stream nextPutAll:(el asFilename baseName). |
535 ^ stream contents |
609 stream nextPutAll:'"' |
|
610 ]. |
|
611 cmd := stream contents |
|
612 ]. |
|
613 ^ cmd |
|
614 ! |
536 ! |
615 |
537 |
616 getExtractSelectedFilesCommandForDirectory:dir withSelection:sel |
538 getExtractSelectedFilesCommandForDirectory:dir withSelection:sel |
617 | stream| |
539 |stream| |
618 |
540 |
619 stream := WriteStream on:''. |
541 stream := WriteStream on:''. |
620 |
542 |
621 "/ 'x' TarArchivUnpackOption |
543 "/ 'x' TarArchivUnpackOption |
622 "/ 'f' TarArchivFileOption |
544 "/ 'f' TarArchivFileOption |
623 "/ 'C' TarArchivUnpackInDirectoryOption |
545 "/ 'C' TarArchivUnpackInDirectoryOption |
624 stream nextPutAll:('%1 -xf "%2" -C %3' |
546 stream nextPutAll:('%1 -xf "%2" -C %3' |
625 bindWith:self class TarArchivCommand |
547 bindWith:self class tarArchiveCommand |
626 with:self fileName asString string |
548 with:self fileName asString string |
627 with:dir asString). |
549 with:dir asString). |
628 |
550 |
629 sel notNil ifTrue:[ |
551 sel notNil ifTrue:[ |
630 sel do:[:el | |
552 sel do:[:el | |
634 ]. |
556 ]. |
635 ]. |
557 ]. |
636 ^ stream contents. |
558 ^ stream contents. |
637 ! |
559 ! |
638 |
560 |
639 getFileListFromArchivCommand:aColOfFiles |
561 getFileListFromArchiveCommand:aColOfFiles |
640 |
562 |stream| |
641 | stream| |
|
642 |
563 |
643 stream := WriteStream on:''. |
564 stream := WriteStream on:''. |
644 |
565 |
645 "/ 't' TarArchivListContentsOption |
566 "/ 't' TarArchivListContentsOption |
646 "/ 'v' TarArchivVerboseOption |
567 "/ 'v' TarArchivVerboseOption |
647 "/ 'f' TarArchivFileOption |
568 "/ 'f' TarArchivFileOption |
648 stream nextPutAll:('%1 -tvf "%2"' |
569 stream nextPutAll:('%1 -tvf "%2"' |
649 bindWith:self class TarArchivCommand |
570 bindWith:self class tarArchiveCommand |
650 with:self fileName baseName). |
571 with:self fileName baseName). |
651 |
572 |
652 aColOfFiles notNil ifTrue:[ |
573 stream nextPutAll:(self class stringWithQuotedFileBaseNames:aColOfFiles). |
653 aColOfFiles do:[:el | |
|
654 stream nextPutAll:' "'. |
|
655 stream nextPutAll:(el baseName). |
|
656 stream nextPutAll:'"'. |
|
657 ] |
|
658 ]. |
|
659 ^ stream contents. |
574 ^ stream contents. |
660 ! |
575 ! |
661 |
576 |
662 getRemoveFilesFromTarArchivFor:sel |
577 getRemoveFilesFromTarArchiveCommandFor:sel |
663 | stream filename| |
578 |stream filename| |
664 |
579 |
665 filename := self fileName. |
580 filename := self fileName. |
666 filename exists ifTrue:[ |
581 filename exists ifFalse:[^ nil]. |
667 stream := WriteStream on:''. |
582 |
668 |
583 stream := WriteStream on:''. |
669 "/ 'f' TarArchivFileOption |
584 |
670 stream nextPutAll:('%1 --delete -f "%2"' |
585 "/ 'f' TarArchivFileOption |
671 bindWith:self class TarArchivCommand |
586 stream nextPutAll:('%1 --delete -f "%2"' |
672 with:self fileName baseName). |
587 bindWith:self class tarArchiveCommand |
673 |
588 with:self fileName baseName). |
674 sel do:[:el | |
589 |
675 stream nextPutAll:'"'. |
590 stream nextPutAll:(self class stringWithQuotedFileBaseNames:sel). |
676 stream nextPutAll:el. |
591 ^ stream contents |
677 stream nextPutAll:' "'. |
|
678 ]. |
|
679 ^ stream contents |
|
680 ] |
|
681 ! ! |
592 ! ! |
682 |
593 |
683 !Archiver::TarGZipArchive class methodsFor:'columns'! |
594 !Archiver::TarGZipArchive class methodsFor:'columns'! |
684 |
595 |
685 columns |
596 columns |
725 tarArchiver := Archiver tarArchive with:tarFile. |
636 tarArchiver := Archiver tarArchive with:tarFile. |
726 ! ! |
637 ! ! |
727 |
638 |
728 !Archiver::TarGZipArchive methodsFor:'actions'! |
639 !Archiver::TarGZipArchive methodsFor:'actions'! |
729 |
640 |
730 addFilesToArchiv:colOfFiles |
641 addFilesToArchive:colOfFiles |
731 |
642 |
732 self setCommandOptions. |
643 self setCommandOptions. |
733 tarArchiver addFilesToArchiv:colOfFiles. |
644 tarArchiver addFilesToArchive:colOfFiles. |
734 "/ synchronize the tar archive under temporary file with archiv file position |
645 "/ synchronize the tar archive under temporary file with archiv file position |
735 self synchronize. |
646 self synchronize. |
736 ! |
647 ! |
737 |
648 |
738 extractTo:aDirectory |
649 extractTo:aDirectory |
750 |
661 |
751 self setCommandOptions. |
662 self setCommandOptions. |
752 tarArchiver extractWithOutDirectoryTo:aDirectory with:files. |
663 tarArchiver extractWithOutDirectoryTo:aDirectory with:files. |
753 ! |
664 ! |
754 |
665 |
755 listFilesFromArchiv |
666 listFilesFromArchive |
756 |
667 |
757 self listFilesFromArchiv:nil |
668 self listFilesFromArchive:nil |
758 ! |
669 ! |
759 |
670 |
760 listFilesFromArchiv:newColOfFiles |
671 listFilesFromArchive:newColOfFiles |
761 |
672 |
762 self setCommandOptions. |
673 self setCommandOptions. |
763 ^ tarArchiver listFilesFromArchiv:newColOfFiles. |
674 ^ tarArchiver listFilesFromArchive:newColOfFiles. |
764 ! |
675 ! |
765 |
676 |
766 removeFilesFromArchiv:aColOfFiles |
677 removeFilesFromArchive:aColOfFiles |
767 |
678 |
768 self setCommandOptions. |
679 self setCommandOptions. |
769 tarArchiver removeFilesFromArchiv:aColOfFiles. |
680 tarArchiver removeFilesFromArchive:aColOfFiles. |
770 self synchronize. |
681 self synchronize. |
771 ! ! |
682 ! ! |
772 |
683 |
773 !Archiver::TarGZipArchive methodsFor:'actions private'! |
684 !Archiver::TarGZipArchive methodsFor:'actions private'! |
774 |
685 |
908 tempFile recursiveCopyTo:targetFile. |
819 tempFile recursiveCopyTo:targetFile. |
909 ]. |
820 ]. |
910 ]. |
821 ]. |
911 ! |
822 ! |
912 |
823 |
913 listFilesFromArchiv |
824 listFilesFromArchive |
914 |
825 |
915 self listFilesFromArchiv:nil |
826 self listFilesFromArchive:nil |
916 ! |
827 ! |
917 |
828 |
918 listFilesFromArchiv:newColOfFiles |
829 listFilesFromArchive:newColOfFiles |
919 |
830 |
920 |dir cmd| |
831 |dir cmd| |
921 |
832 |
922 self fileName isNil ifTrue:[ ^ self]. |
833 self fileName isNil ifTrue:[ ^ self]. |
923 dir := self fileName directory. |
834 dir := self fileName directory. |
924 cmd := self getFileListFromArchivCommand:newColOfFiles. |
835 cmd := self getFileListFromArchiveCommand:newColOfFiles. |
925 self executeCommand:cmd directory:dir |
836 self executeCommand:cmd directory:dir |
926 ! |
837 ! |
927 |
838 |
928 removeFilesFromArchiv:aColOfFiles |
839 removeFilesFromArchive:aColOfFiles |
929 |
840 |
930 |cmd| |
841 |cmd| |
931 |
842 |
932 cmd := self getRemoveFilesFromArchivFor:aColOfFiles. |
843 cmd := self getRemoveFilesFromArchiveFor:aColOfFiles. |
933 self executeCommand:cmd directory:(self fileName directory). |
844 self executeCommand:cmd directory:(self fileName directory). |
934 ! ! |
845 ! ! |
935 |
846 |
936 !Archiver::ZipArchive methodsFor:'command strings'! |
847 !Archiver::ZipArchive methodsFor:'command strings'! |
937 |
848 |
938 getAddFilesToArchiveCommandForArchiv:archivFile with:aColOfFiles |
849 getAddFilesToArchiveCommandForArchive:archiveFile with:aColOfFiles |
939 | cmd stream| |
850 | cmd stream| |
940 |
851 |
941 archivFile exists ifTrue:[ |
852 archiveFile exists ifTrue:[ |
942 stream := WriteStream on:''. |
853 stream := WriteStream on:''. |
943 |
854 |
944 stream nextPutAll:('%1 -r "%2"' |
855 stream nextPutAll:('%1 -r "%2"' |
945 bindWith:self class ZipArchivCommand |
856 bindWith:self class ZipArchiveCommand |
946 with:archivFile asString string). |
857 with:archiveFile asString string). |
947 |
858 |
948 aColOfFiles do:[:el | |
859 aColOfFiles do:[:el | |
949 stream nextPutAll:' "'. |
860 stream nextPutAll:' "'. |
950 stream nextPutAll:(el asFilename baseName). |
861 stream nextPutAll:(el asFilename baseName). |
951 stream nextPutAll:'"' |
862 stream nextPutAll:'"' |
999 ] |
910 ] |
1000 ]. |
911 ]. |
1001 ^ stream contents. |
912 ^ stream contents. |
1002 ! |
913 ! |
1003 |
914 |
1004 getRemoveFilesFromArchivFor:sel |
915 getRemoveFilesFromArchiveFor:sel |
1005 |stream| |
916 |stream| |
1006 |
917 |
1007 stream := WriteStream on:''. |
918 stream := WriteStream on:''. |
1008 |
919 |
1009 stream nextPutAll:('%1 -d "%2"' |
920 stream nextPutAll:('%1 -d "%2"' |
1010 bindWith:self class ZipArchivCommand |
921 bindWith:self class ZipArchiveCommand |
1011 with:self fileName asString string). |
922 with:self fileName asString string). |
1012 |
923 |
1013 sel do:[:el | |
924 sel do:[:el | |
1014 stream nextPutAll:' "'. |
925 stream nextPutAll:' "'. |
1015 stream nextPutAll:(el asString). |
926 stream nextPutAll:(el asString). |