home *** CD-ROM | disk | FTP | other *** search
-
- /********************* Split *****************************************
-
- File splitter - V1.0 Copyright 1987-1988 by Richard Lee Stockton
- permission granted for non-profit use and
- distribution. However, contributions sent
- to the author will be gladly and most
- gratefully spent. (address below)
-
- USAGE: Split <path>filename <partsize>
-
- EXAMPLE:
- cd ram:
- split df1:City.anim - will break City.anim from df1: into 100k files
- named 1, 2, etc. on the RAM: disk.
- EXAMPLE:
- cd vd0:
- split War.data 150000 - will break War.data on VD0: into 150k files
- named 1, 2, etc. on VD0:.
-
- Split was written to fill a need for a simple file splitter to
- break down the size of those very large animation files into files
- that your average BBS user can download within his time limit. Feel
- free to use it for any other purpose you can imagine. It will work
- on ANY type of file.
-
- Destination files are written to the CURRENT directory. They are named
- using numerals 1-9 then capital letters A-Z. If split is unable to
- find the sourcefilename, it will quit.
-
- Split does not test to see if there is enough room in the current
- directory for all the partfiles. That part is up to you.
-
- DEFAULT partsize = 100k bytes.
- MINimum partsize = 1k bytes. (why would you want 'em this small?)
- MAXimum partsize = 1 Million bytes. (1000k) (...or this big?)
-
- If <partsize> falls out of range, the default partsize (100k) will be
- used. Maximum number of parts = 35 (suffix = 1-9 then A-Z).
-
- RE-CONNECT EXAMPLE:
- join 1 2 3 4 5 6 7 8 9 A B C D E F as Action.anim
-
- REMEMBER!:
- The `join' command limits the number of parts to 15. (The 15th part
- is F). If you have more than 15 parts, join them in sections and
- then join the sections. (Put an `executeme' file in with the pieces,
- so nobody gets confused! :-)
- 8/15/87 updated 3/8/88
-
- Comments/Contributions:
- Richard Lee Stockton
- 21305 60th Ave. West
- MtLkTerr, Wash 98043
- (206) 776-1253
-
- ********* Thanks to Andry Rachmat for the `skeleton'! :-) ***********/
-
-
- /* Split.c */
- /* cc split.c then ln split.o -lc with Manx 3.4 */
-
- #include <exec/types.h>
- #include <libraries/dos.h>
-
- #define MINSIZE 1000L
- #define NRMSIZE 100000L
- #define MAXSIZE 1000000L
-
- #define USAGE "\n\
- File splitter - V1.4 - partsize from 1k-1meg, default=100k\n\
- \xa9 1987-1988 RLStockton 21305 60th West, MtLkTerr, WA 98043\n\n\
- USAGE: Split <path>filename <partsize>\n"
-
- extern struct FileHandle *Open();
- extern char *AllocMem();
- extern long Seek(), Read(), Write(), Output(), atol();
- void _abort(), _wb_parse();
-
- Enable_Abort=1; /* Bail-Out is set to ON! */
-
- struct FileHandle *infile=NULL, *outfile=NULL;
- long iosize, actual;
- char *buffer=NULL;
- char partname[2];
- int partsuffix=1;
-
- main(argc, argv)
- int argc;
- char *argv[];
- {
-
- /* if no args, give (c), usage and exit */
-
- if(argc<2)
- {
- Write(Output(),USAGE,(long)strlen(USAGE)); _abort();
- }
-
- /* check and set iosize from argv[2] */
-
- if (argv[2]) actual = atol(argv[2]);
- if (actual < MINSIZE) actual = NRMSIZE;
- if (actual > MAXSIZE) actual = NRMSIZE;
- iosize = actual;
-
- /* allocate buffer */
-
- if ((buffer=AllocMem(iosize,0L))==NULL) _abort();
-
- /* open source file */
-
- if (!(infile=Open(argv[1],MODE_OLDFILE))) _abort();
- Seek(infile,0L,OFFSET_BEGINNING);
-
- /* !!! start of do loop !!! */
-
- do
- {
- /* construct new partname */
-
- partname[0] = (long)partsuffix + '0'; partname[1] = '\0';
-
- /* inform user of file creation */
-
- Write(Output(),"creating ",10L);
- Write(Output(),partname,2L);
- Write(Output(),"\n",2L);
-
- /* fill buffer, write partfile */
-
- if ((actual=Read(infile,buffer,iosize))==-1L) _abort();
- if (!(outfile=Open(partname,MODE_NEWFILE))) _abort();
- if (Write(outfile,buffer,actual)!=actual) _abort();
-
- /* close the partfile and check for a CTRL 'c' */
-
- Close(outfile); outfile=NULL; Chk_Abort();
-
- /* increment suffix index */
-
- partsuffix++;
- if (partsuffix>42)
- {
- Write(Output(),"\nMore than 35 parts!\n",22L);
- _abort();
- }
-
- /* skip over punctuation to caps */
-
- if(partsuffix==10) partsuffix = 17;
-
- }
-
- /* loop as long as we have a full size file */
-
- while(actual==iosize);
-
- /* clean up, quit, and go home. */
-
- _abort();
- }
-
-
- void _abort() /* declare our own _abort() and save a few bytes */
- {
- if ( outfile) Close(outfile);
- if ( infile ) Close(infile);
- if ( buffer ) FreeMem(buffer,iosize);
- _exit(0);
- }
-
- void _wb_parse() {} /* this stub saves a few bytes */
-
-
- /***** end of split.c *****/
-