Re: C, really portable?



Eric Sosman wrote:
jacob navia wrote:
3) If there is an error you do a sloppy job
like assuming any error is a disk full error.


    Thanks for your assessment of my code.  I'm just
the sloppiest guy going.


Well, that's what *I* do <grin>.

I assume that if fprintf returns a negative value the disk
is full.

It is the only portable thing I can do without tying the
code to some specific printf implementation.

It would be much better if I could portable write

err = fprintf(...);
if (err == EOF) {
	// no space. Erase temporary files
}

This could be encapsulated in a
int MyFprintf(FILE *f,char *fmt,...)
{
	int err = fprintf(... /*call ellided*/);
	switch (err) {
		case EOF:
			// No space. Erase temp files
			break;
		default:
			// Other errors
	}
	return err;
}
.



Relevant Pages

  • Re: BACKUP/COPY change files allocated size. WHY? How do I prevent this?
    ... If you really must preserve the random contents of the disk that are not ... why does SET FILE/END give me access to them? ... implementation out there that wouldn't stop at the eof, ... you run the risk of losing that data during normal VMS file operations. ...
    (comp.os.vms)
  • Re: BACKUP/COPY change files allocated size. WHY? How do I prevent this?
    ... John Laird wrote: ... If you really must preserve the random contents of the disk that are not ... The contents beyond EOF are not random and if they're not part ... SET FILE/END or the file attributes with CONVERT? ...
    (comp.os.vms)
  • Re: How can I read a locked VMS file?
    ... the file, but BACKUP should copy ... where the EOF pointer can't be trusted, ... If it forces a flush to disk, ... and file header allocation caches. ...
    (comp.os.vms)
  • Re: High File Watermarking question for Hoff Hoffman
    ... which suggested that blocks on disk would be zeroed when ... Opening a file is not the occasion for anything to get zeroed. ... Creating a file with an EOF at the end might be. ... What on earth does opening a NEW file mean that is different ...
    (comp.os.vms)
  • Err after OS upgrade.
    ... We have upgrade our OS from 5.8 to 5.9.The disks are in Veritas Control.We ... reomved the first disk out and did a OS upgrade in second disk through ... But when we reboot we are getting this err. ... The SUNWsrspx package is not installed ...
    (SunManagers)