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
62 #include <aros/shcommands.h>
64 #define AROS_SH2(a,b,c,d) main()
65 #define AROS_SHCOMMAND_INIT
66 #define AROS_SHCOMMAND_EXIT
75 struct IntuitionBase
*IntuitionBase
;
76 struct GfxBase
*GfxBase
;
77 struct Library
*BZ2Base
;
82 AROS_SHA( STRPTR
, , FILE, /A
, NULL
),
83 AROS_SHA( STRPTR
, , TO
, /A
, NULL
)
92 if( SHArg(FILE) == NULL
) goto cleanup
;
93 if( SHArg(TO
) == NULL
) goto cleanup
;
95 IntuitionBase
= (struct IntuitionBase
*)OpenLibrary( "intuition.library", 0 );
96 GfxBase
= (struct GfxBase
*)OpenLibrary( "graphics.library", 0 );
97 BZ2Base
= OpenLibrary( "bz2.library", 0 );
99 //Printf( "%s, %s\n", SHArg(FILE), SHArg(TO) );
101 pkg
= PKG_Open( SHArg(FILE), MODE_READ
);
102 if( pkg
== NULL
) goto cleanup
;
104 newDir
= Lock( SHArg(TO
), SHARED_LOCK
);
105 if( newDir
== BNULL
) goto cleanup
;
106 oldDir
= CurrentDir( newDir
);
108 if( !GUI_Open() ) goto cleanup
;
110 PKG_ExtractEverything( pkg
);
115 if( oldDir
!= BNULL
) CurrentDir( oldDir
);
116 if( newDir
!= BNULL
) UnLock( newDir
);
117 if( pkg
!= NULL
) PKG_Close( pkg
);
119 if( BZ2Base
!= NULL
) CloseLibrary( BZ2Base
);
120 if( IntuitionBase
!= NULL
) CloseLibrary( (struct Library
*) IntuitionBase
);
121 if( GfxBase
!= NULL
) CloseLibrary( (struct Library
*) GfxBase
);