diff options
author | B. Watson <urchlay@slackware.uk> | 2024-05-10 17:24:40 -0400 |
---|---|---|
committer | B. Watson <urchlay@slackware.uk> | 2024-05-10 17:24:40 -0400 |
commit | f9dcbdd176785dfc9d49f3113ec6110199e9a246 (patch) | |
tree | f132ba50240e442f3c669bdbbfe014843db47701 /ksiders/atrextr.c | |
parent | 516fd094e69c64cecab68ce7a7751c0fa5d868ef (diff) | |
download | bw-atari8-tools-f9dcbdd176785dfc9d49f3113ec6110199e9a246.tar.gz |
import ken siders atr utilities.
Diffstat (limited to 'ksiders/atrextr.c')
-rw-r--r-- | ksiders/atrextr.c | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/ksiders/atrextr.c b/ksiders/atrextr.c new file mode 100644 index 0000000..2aeb898 --- /dev/null +++ b/ksiders/atrextr.c @@ -0,0 +1,63 @@ +/* Copyright 1997 Ken Siders */ + +#include <stdio.h> +#include <string.h> +#include <stdlib.h> +#include <sys/stat.h> +#include <sys/types.h> +#include "atr.h" +#include "atdos.h" + +int main( int argc, char **argv) { + AtrFilePtr atr; + int stat = 0, ret = 0; + char *file = "*.*"; + char *path = NULL; + + printf("AtrExtr Version 0.9u (c)1997 Ken Siders\n"); + printf("Ported and modified by B. Watson, 2007\n"); + printf("This program may be freely distributed\n\n"); + + if(argc < 2 || argc > 4) { + printf("usage: atrextr atrname.atr [file] [dir]\n" + "Wildcards may be used for file (default: *.*)\n" + "dir will be created, if it does not exist\n"); + exit(-1); + } + + atr = OpenAtr(argv[1]); + if(atr == 0) { + printf("Error reading ATR file: %s\n", argv[1]); + CloseAtr(atr); + exit(2); + } + + CloseAtr(atr); + + if(argc >= 3 && argv[2][0]) + file = argv[2]; + + if(argc == 4) { + path = argv[3]; + mkdir(path, 0777); /* ignore errors (ExtractAtariFile() will fail instead) */ + } + + while ( !stat ) { + SetVerbose(1); + stat = ExtractAtariFile( argv[1], file, path ); + SetVerbose(0); + } + + if( stat < 0 ) { + printf("\nError encountered when extracting file(s)\n"); + printf("some files may have been extracted incorrectly\n"); + stat = -stat; + ret = 1; + } + + printf("\n%d file(s) extracted\n", stat); + + exit(ret); +} + + |