🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.sys.ibm.pc.misc
Article #9372

Re: SPLIT

#9372
From: Clayton Cramer
Date: Fri, 19 Apr 1991 20:37
123 lines
4046 bytes
In article <1991Apr15.024343.6027@cs.mcgill.ca>, storm@cs.mcgill.ca (Marc WANDSCHNEIDER) writes:
> 
> I am looking for any program that will split up large files into smaller ones
> on the hard drive.  I am aware of some that will split up files over floppies
> but I would like one that will split them up right on the hard drive.
> 
> If you could also give me an ftp site or Compu$erve joint where I can get it
> I would appreciate it.
> 
> storm@cs.mcgill.ca         McGill University           It's 11pm, do YOU

Couldn't find a valid path to you, and this may be generally useful:

======================================================================
#include <stdio.h>
#include <malloc.h>
#include <stdlib.h>
#include <errno.h>
#include "std.h"

main(Argc, Argv)

int		Argc;
char*	Argv[];

	{
	long		BytesThisPartFile;
	long		BytesPerPart;
	int			PartNbr;
	char		OutFileName[40];
	FILE*		OutFile;
	FILE*		FileToPart;
	char*		Bytes;
	bool		MoreBytes = TRUE;
	int			BytesRead;
	
	if(Argc < 3)
		{
		fprintf(stderr, "Three arguments required.\n");
		DisplayHelp();
		exit(2);
		}
	else
		{
		FileToPart = fopen(Argv[1], "rb");
		if(FileToPart)
			{
			if(1 == sscanf(Argv[3], "%ld", &BytesPerPart))
				{
				BytesPerPart *= 1000L;
				Bytes = malloc(1000);
				if((Bytes) && (FileToPart))
					{
					PartNbr = 0;
					sprintf(OutFileName, Argv[2], PartNbr);
					fprintf(stderr, "creating %s\n", OutFileName);
					BytesThisPartFile = 0L;
					OutFile = fopen(OutFileName, "wb");
					if(OutFile)
						{
						while(MoreBytes && !feof(OutFile) && !ferror(OutFile))
							{
							BytesRead = fread(Bytes, sizeof(char), 
											  sizeof(Bytes), FileToPart);
							fwrite(Bytes, sizeof(char), BytesRead, OutFile);
							BytesThisPartFile += sizeof(Bytes);
							if(feof(FileToPart))
								MoreBytes = FALSE;
							else if(BytesThisPartFile >= BytesPerPart)
								{
								PartNbr++;
								fclose(OutFile);
								sprintf(OutFileName, Argv[2], PartNbr);
								fprintf(stderr, "creating %s\n", OutFileName);
								BytesThisPartFile = 0L;
								OutFile = fopen(OutFileName, "wb");
								}
							}
						if(feof(OutFile) || ferror(OutFile))
							fprintf(stderr, "On %s: %s\n", 
									OutFileName, sys_errlist[errno]);
						}
					else
						{
						fprintf(stderr, "Unable to create file %s: %s\n", 
								OutFileName, sys_errlist[errno]);
						exit(2);
						}
					}
				fclose(OutFile);
				}
			else
				{
				fprintf(stderr, "Invalid size for partition: %s\n", Argv[3]);
				DisplayHelp();
				}
			}
		else
			{
			fprintf(stderr, "Unable to open file %s\n", Argv[1]);
			DisplayHelp();
			}
		}
	}

DisplayHelp()

	{
	fprintf(stderr, "PART filetopart partspec partsize\n");
	fprintf(stderr, "filetopart is the file to be partitioned\n");
	fprintf(stderr, "partspec is the format control string for file names\n");
	fprintf(stderr, "         which must contain %%d within it.\n");
	fprintf(stderr, "partsize is the number of 1K blocks in each\n");
	fprintf(stderr, "         output partitioned file\n");
	}
======================================================================
Link it with the setargv.obj module that comes with the Microsoft
C compiler, and everything will be wonderful.
-- 
Clayton E. Cramer {uunet,pyramid,pixar,tekbspa}!optilink!cramer
You must be kidding!  No company would hold opinions like mine!
Article IX, "Sec. 21.  That the right of citizens to bear arms, in defence of
themselves and the State, shall not be questioned." -- PA State Const. of 1790
Technical Details
Message-ID: <6256@optilink.UUCP>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!swrinde!elroy.jpl.nasa.gov!lll-winken!uunet!optilink!cramer
References: <1991Apr15.024343.6027@cs.mcgill.ca>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!swrinde!elroy.jpl.nasa.gov!lll-winken!uunet!optilink!cramer
From: cramer@optilink.UUCP (Clayton Cramer)
Newsgroups: comp.sys.ibm.pc.misc
Subject: Re: SPLIT
Message-ID: <6256@optilink.UUCP>
Date: 19 Apr 91 20:37:39 GMT
References: <1991Apr15.024343.6027@cs.mcgill.ca>
Organization: Optilink Corporation, Petaluma, CA
Lines: 123