Path: utzoo!utgpu!news-server.csri.toronto.edu!clyde.concordia.ca!uunet!optilink!cramer From: cramer@optilink.UUCP (Clayton Cramer) Newsgroups: comp.os.msdos.programmer Subject: Re: Help. End of Diskette VS EOF Message-ID: <4164@optilink.UUCP> Date: 10 Aug 90 23:47:29 GMT References: <1990Aug9.004845.16663@sun.soe.clarkson.edu> Organization: Optilink Corporation, Petaluma, CA Lines: 74 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 #include #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)