🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: comp.os.msdos.programmer
3 messages
3 total messages Started by Allanon Thu, 09 Aug 1990 00:48
Help. End of Diskette VS EOF
#1824
Author: Allanon
Date: Thu, 09 Aug 1990 00:48
24 lines
1575 bytes
I would like to know if a C program will return different error codes if
it reaches the end of a file or reaches the end of a diskette, are these
two things the same or can I tell them apart.

If anyone has an established, or just working, way to save files across
volumes I would like to know, please E-Mail me.  I will post summary if
there is enough interest.

And, yes  now DOS backup does something like this, I am looking for
another way, I need to break .ZIP files across diskettes.

Thanks in advance.

Walden

---------------------------------------------------------------------------
Walden H. Leverich III               | Inet: levericw@clutx.clarkson.edu
     ECE Dept.                       | CServ: 73237,2212
 Clarkson University                 | SnailMail: 100 Market St.
                                     |            N.C.M. Apt 10
                                     |            Potsdam, NY 13676-1702
Just once, I wish we would encounter an alien menace that wasn't immune to 
bullets.    -The Brigader [Dr. Who]
--------------------------------------------------------------------------
Re: Help. End of Diskette VS EOF
#1834
Author: Joe Morris
Date: Thu, 09 Aug 1990 15:32
20 lines
1713 bytes
In a recent article levericw@clutx.clarkson.edu (Allanon) writes:
>I would like to know if a C program will return different error codes if
>it reaches the end of a file or reaches the end of a diskette, are these
>two things the same or can I tell them apart.

Unless the application which writes the file leaves some out-of-band information
about the ending status, there is no way to distinguish the cases.  By 
definition a file ends when the forward pointer in the FAT is the EOF flag,
and DOS does not define the concept of a multi-volume file.  One could
probably be devised which would provide a multiplex interrupt hook to
let the writing program mark EOV instead of EOF, and let the reader know
which one terminated the read, but there's nothing there now.  (Microsoft,
are you reading this?)

Programs like BACKUP have a separate file for the out-of-band signals such as
disk number and EOF/EOV status.  DOS has nothing to do with the ability
of these programs to carry large files across multiple volumes.  

For your particular application what is needed is a special dump/restore type
of program.  There's gotta be someone who has written such a beastie...
Re: Help. End of Diskette VS EOF
#1847
Author: Clayton Cramer
Date: Fri, 10 Aug 1990 23:47
74 lines
2564 bytes
In article <1990Aug9.004845.16663@sun.soe.clarkson.edu>, levericw@clutx.clarkson.edu (Allanon) writes:
> I would like to know if a C program will return different error codes if
> it reaches the end of a file or reaches the end of a diskette, are these
> two things the same or can I tell them apart.

I don't believe that there's any difference, as far as something
like fwrite cares.

> If anyone has an established, or just working, way to save files across
> volumes I would like to know, please E-Mail me.  I will post summary if
> there is enough interest.

> Walden H. Leverich III               | Inet: levericw@clutx.clarkson.edu

#include <stdio.h>
#include <malloc.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;
	
	FileToPart = fopen(Argv[1], "rb");
	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)
				{
				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");
					}
				}
			}
		fclose(OutFile);
		}
	}
-- 
Clayton E. Cramer {pyramid,pixar,tekbspa}!optilink!cramer
"Our Constitution is color-blind.  The arbitrary separation of citizens,
on the basis of race... is a badge of servitude wholly inconsistent with
civil freedom." -- Justice John Marshall Harlan (1896)
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads