2 Copyright © 2003-2014, 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:
51 ******************************************************************************/
54 #include <dos/rdargs.h>
55 #include <proto/exec.h>
56 #include <proto/dos.h>
58 #define SH_GLOBAL_DOSBASE 1
59 #define SH_GLOBAL_SYSBASE 1
61 #include <aros/shcommands.h>
67 struct IntuitionBase
*IntuitionBase
;
68 struct GfxBase
*GfxBase
;
69 struct Library
*BZ2Base
;
74 AROS_SHA( STRPTR
, , FILE, /A
, NULL
),
75 AROS_SHA( STRPTR
, , TO
, /A
, NULL
)
84 if( SHArg(FILE) == NULL
) goto cleanup
;
85 if( SHArg(TO
) == NULL
) goto cleanup
;
87 IntuitionBase
= (struct IntuitionBase
*)OpenLibrary( "intuition.library", 0 );
88 GfxBase
= (struct GfxBase
*)OpenLibrary( "graphics.library", 0 );
89 BZ2Base
= OpenLibrary( "bz2.library", 0 );
91 //Printf( "%s, %s\n", SHArg(FILE), SHArg(TO) );
93 pkg
= PKG_Open( SHArg(FILE), MODE_READ
);
94 if( pkg
== NULL
) goto cleanup
;
96 newDir
= Lock( SHArg(TO
), SHARED_LOCK
);
97 if( newDir
== BNULL
) goto cleanup
;
98 oldDir
= CurrentDir( newDir
);
100 if( !GUI_Open() ) goto cleanup
;
102 PKG_ExtractEverything( pkg
);
107 if( oldDir
!= BNULL
) CurrentDir( oldDir
);
108 if( newDir
!= BNULL
) UnLock( newDir
);
109 if( pkg
!= NULL
) PKG_Close( pkg
);
111 if( BZ2Base
!= NULL
) CloseLibrary( BZ2Base
);
112 if( IntuitionBase
!= NULL
) CloseLibrary( (struct Library
*) IntuitionBase
);
113 if( GfxBase
!= NULL
) CloseLibrary( (struct Library
*) GfxBase
);