2 Copyright © 2003, 2009, The AROS Development Team. All rights reserved.
6 /******************************************************************************
22 Command to unpack/unarchive AROS .pkg files.
26 NAME - The name of the file to unpack.
27 TO – The drive or path to be unpacked.
32 Standard DOS error codes.
36 This command is not a tool like lha, lzx or unzip.
37 The .pkg files may be created with the python program
38 in tools/package/pkg and compressed with bzip2 afterwards.
43 Unpack AROS.pkg TO Ram:
53 04.05.2000 SDuvan implemented
55 ******************************************************************************/
58 #include <dos/rdargs.h>
59 #include <proto/exec.h>
60 #include <proto/dos.h>
62 #define SH_GLOBAL_DOSBASE 1
63 #define SH_GLOBAL_SYSBASE 1
65 #include <aros/shcommands.h>
71 struct IntuitionBase
*IntuitionBase
;
72 struct GfxBase
*GfxBase
;
73 struct Library
*BZ2Base
;
78 AROS_SHA( STRPTR
, , FILE, /A
, NULL
),
79 AROS_SHA( STRPTR
, , TO
, /A
, NULL
)
88 if( SHArg(FILE) == NULL
) goto cleanup
;
89 if( SHArg(TO
) == NULL
) goto cleanup
;
91 IntuitionBase
= (struct IntuitionBase
*)OpenLibrary( "intuition.library", 0 );
92 GfxBase
= (struct GfxBase
*)OpenLibrary( "graphics.library", 0 );
93 BZ2Base
= OpenLibrary( "bz2.library", 0 );
95 //Printf( "%s, %s\n", SHArg(FILE), SHArg(TO) );
97 pkg
= PKG_Open( SHArg(FILE), MODE_READ
);
98 if( pkg
== NULL
) goto cleanup
;
100 newDir
= Lock( SHArg(TO
), SHARED_LOCK
);
101 if( newDir
== BNULL
) goto cleanup
;
102 oldDir
= CurrentDir( newDir
);
104 if( !GUI_Open() ) goto cleanup
;
106 PKG_ExtractEverything( pkg
);
111 if( oldDir
!= BNULL
) CurrentDir( oldDir
);
112 if( newDir
!= BNULL
) UnLock( newDir
);
113 if( pkg
!= NULL
) PKG_Close( pkg
);
115 if( BZ2Base
!= NULL
) CloseLibrary( BZ2Base
);
116 if( IntuitionBase
!= NULL
) CloseLibrary( (struct Library
*) IntuitionBase
);
117 if( GfxBase
!= NULL
) CloseLibrary( (struct Library
*) GfxBase
);