home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Club Amiga de Montreal - CAM
/
CAM_CD_1.iso
/
files
/
149.lha
/
dearc.c
< prev
next >
Wrap
C/C++ Source or Header
|
1988-04-25
|
4KB
|
148 lines
echo ; /* compiling and linking dearc.c .....
LC -v dearc.c
BLINK from lib:c.o, dearc.o LIB lib:lc.lib, lib:amiga.lib SC SD ND MAP dearc.map
QUIT
*/
#include "stdio.h"
#include "exec/types.h"
#include <string.h>
#include <stdlib.h>
#include "dos.h"
#include "proto/exec.h"
#include "proto/dos.h"
int fp;
VOID MemCleanup (){}
char s[20];
char command[80] = { "DELETE " };
char path[166] = "";
char pathname[166 + 34 + 1] = "";
char file_name[166 + 34 + 1 + 3] = "";
void main(argc, argv)
int argc;
char *argv[];
{
int result;
int more;
int *ip;
char temp[4];
int front;
char ext[4];
char *cp;
puts ( "\n DE-arc utility v2.0 - TASP Group, INC.\n");
if (( argc <= 1 ) || ( *argv[1] == '?' ))
{
puts("usage: dearc FILENAME.EXT \n");
puts(" where FILENAME.EXT = the arc file from which the");
puts(" extracted files, this utility");
puts(" will delete, came from.");
puts(" .EXT will default to .ARC ");
exit ( TRUE );
}
result = strcpy ( &file_name[0], argv[1] );
/* see if the user supplied an extension. if not make it .arc */
if ( 0 == ( stcgfe ( &ext[0], &file_name[0] ) ) )
{
strmfe ( &file_name[0], &file_name[0], "ARC" );
}
/* open the ARC file */
fp = Open(&file_name[0],MODE_OLDFILE);
if ( fp == 0 )
{
puts ( "Unable to open file" );
exit (FALSE);
}
/* extract the path portion of the input file name */
result = stcgfp ( &path, &file_name[0] );
/* set up the command string */
cp = strcpy(&command[0],"DELETE ");
front = 0;
/* get to the begining of the file */
result = Seek ( fp, 0, OFFSET_BEGINNING );
/* pull out all the arced file's names and delete those
files in the directory that the arced file is in */
do
{
more = FALSE;
result = Read(fp, &s[0], 1);
/* the first byte had better be a hex 1A */
if (( s[0] == 26 ) && ( s[0] != EOF ))
{
result = Read(fp, &s[0], 1);
/* the second byte should be something other than a zero */
if ( s[0] > 0 )
{
/* the next string is the file name max length = 12 bytes */
result = Read ( fp, &s[0], 13 );
/* make a full pathname */
strmfp( &pathname[0], &path[0], &s[0] );
/* create a delete command for AmigaDos */
cp = strcat( &command[0], &pathname[0]);
/* show the user what we are doing */
puts ( &command[0] );
/* delete the file */
result = DeleteFile ( &pathname[0] );
if ( ! result )
{
puts ("\n ** file was not deleted ** ");
}
/* set up the command for the next time */
command[7] = '\0';
/* get the offset to the next file name. Its in intel
word format ( ie. low high ) */
result = Seek ( fp, ( front + 15 ), OFFSET_BEGINNING );
result = Read ( fp, &temp[3], 1 );
result = Read ( fp, &temp[2], 1 );
result = Read ( fp, &temp[1], 1 );
result = Read ( fp, &temp[0], 1 );
ip = (int * )&temp[0];
/* next file is at begining of this entry + header
overhead + offset */
front = front + 29 + *ip;
result = Seek ( fp, front, OFFSET_BEGINNING );
more = TRUE;
}
}
else
{
puts ( "not an arc format file !" );
}
} while ( more );
Close( fp );
exit(TRUE);
}