Short: Cut data from FILE with position, and length (with source) Author: LouiSe Uploader: LouiSe Type: util/conv Architecture: m68k-amigaos Simple file cutter by LouiSe Usage: LSFileCut --------------------------------------------------------- check out our projects @ - http://AMIGAonly.ahol.com AMIGAonly, the hungarian Amiga magazin - http://AMIGAonly.ahol.com/louise/ LouiSe's home - http://AMIGAonly.ahol.com/amilinux/ Amiga Linux page --- CUT HERE for THE SOURCE ! --------------------------- #include #include #include #include #define BUFFSIZE 200000UL void main(int argc, char *argv[]) { BPTR fhi, fho; long pos,bytes; char buffer[BUFFSIZE]; long allbytes=0; long fr=0; if(argc<5) { printf("usage:\n"); printf(" LSFileCut \n"); exit(0); } if(strchr(argv[3],'x')!=NULL) sscanf(argv[3],"%x",&pos); else pos=atol(argv[3]); if(strchr(argv[4],'x')!=NULL) sscanf(argv[4],"%x",&bytes); else bytes=atol(argv[4]); printf("FileCut v1.05 by LouiSe 1999\n\n"); printf("Input file : %s\n",argv[1]); printf("Output file : %s\n",argv[2]); printf("Cut position : %lu\n",pos); printf("Bytes to Cut : %lu\n",bytes); if((fhi=Open(argv[1],MODE_OLDFILE))==NULL) { printf("*** couldn't open input file: []\n",argv[1]); exit(-1); } else { if((fho=Open(argv[2],MODE_NEWFILE))==NULL) { printf("*** couldn't open output file: []\n",argv[2]); exit(-2); } else { allbytes=0; Seek(fhi,pos,OFFSET_BEGINNING); while(1) { fr=Read(fhi,buffer,sizeof(buffer)); if(fr<=0) break; allbytes=allbytes+fr; // printf("fr=%lu, allbytes=%lu\n",fr,allbytes); if(allbytesbytes) { Write(fho,buffer,bytes); } else { Write(fho,buffer,allbytes-bytes); } break; } } Close(fhi); Close(fho); } } }