added concrete implementations of putc(), getc(), getchar() and gets()
[tangerine.git] / workbench / c / Unpack / unpack.c
blobfe6dedb8b3fe81c27f2930e0b872fc959cead102
1 /*
2 Copyright © 2003, The AROS Development Team. All rights reserved.
3 $Id$
4 */
6 /******************************************************************************
8 NAME
10 Unpack
12 SYNOPSIS
14 FILE/A, TO/A
16 LOCATION
18 Sys:C
20 FUNCTION
22 Command to unpack/unarchive AROS .pkg files.
24 INPUTS
26 NAME - The name of the file to unpack.
27 TO – The drive or path to be unpacked.
30 RESULT
32 Standard DOS error codes.
34 NOTES
36 This command is not a tool like lha, lzx or unzip.
37 The .pkg files are not compressed.
40 EXAMPLE
42 Unpack AROS.pkg TO Ram:
44 BUGS
46 SEE ALSO
48 INTERNALS
50 HISTORY
52 04.05.2000 SDuvan implemented
54 ******************************************************************************/
56 #include <dos/dos.h>
57 #include <dos/rdargs.h>
58 #include <proto/exec.h>
59 #include <proto/dos.h>
61 #define SH_GLOBAL_DOSBASE 1
62 #define SH_GLOBAL_SYSBASE 1
64 #include <aros/shcommands.h>
66 #include "modes.h"
67 #include "package.h"
68 #include "gui.h"
70 struct IntuitionBase *IntuitionBase;
71 struct GfxBase *GfxBase;
73 AROS_SH2
75 Unpack, 1.0,
76 AROS_SHA( STRPTR, , FILE, /A, NULL ),
77 AROS_SHA( STRPTR, , TO, /A, NULL )
80 AROS_SHCOMMAND_INIT
82 BPTR oldDir = NULL,
83 newDir = NULL;
84 APTR pkg = NULL;
86 if( SHArg(FILE) == NULL ) goto cleanup;
87 if( SHArg(TO) == NULL ) goto cleanup;
89 IntuitionBase = (struct IntuitionBase *)OpenLibrary( "intuition.library", 0 );
90 GfxBase = (struct GfxBase *)OpenLibrary( "graphics.library", 0 );
92 //Printf( "%s, %s\n", SHArg(FILE), SHArg(TO) );
94 pkg = PKG_Open( SHArg(FILE), MODE_READ );
95 if( pkg == NULL ) goto cleanup;
97 newDir = Lock( SHArg(TO), SHARED_LOCK );
98 if( newDir == NULL ) goto cleanup;
99 oldDir = CurrentDir( newDir );
101 if( !GUI_Open() ) goto cleanup;
103 PKG_ExtractEverything( pkg );
105 cleanup:
106 GUI_Close();
108 if( oldDir != NULL ) CurrentDir( oldDir );
109 if( newDir != NULL ) UnLock( newDir );
110 if( pkg != NULL ) PKG_Close( pkg );
112 if( IntuitionBase != NULL ) CloseLibrary( (struct Library *) IntuitionBase );
113 if( GfxBase != NULL ) CloseLibrary( (struct Library *) GfxBase );
115 return 0;
117 AROS_SHCOMMAND_EXIT