Re: File name from stream
From: Gordon Burditt (gordonb.r8qjp_at_burditt.org)
Date: 04/28/05
- Next message: JS: "Problems running TeXniCcenter with wine"
- Previous message: Bjorn Reese: "Re: How to use xtrace?"
- In reply to: Russell Shaw: "Re: File name from stream"
- Next in thread: Russell Shaw: "Re: File name from stream"
- Reply: Russell Shaw: "Re: File name from stream"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Thu, 28 Apr 2005 17:14:32 -0000
>>>I think it's an oversight that the original implementation of streams
>>>didn't record the file name being opened. If i pass the stream as a
>>>parameter to a function, the function cannot print an error message
>>>that includes the file name of the stream.
>>
>> This is a *GOOD* thing, as if I pass stdin, stdout, or stderr to
>> that function, it won't *HAVE* a name to print (to say nothing of
>> the issue that unnamed pipes and sockets don't even HAVE names).
>> I also don't want the output looking different due to the program's
>> opinion of where I directed the output.
>>
>> Gordon L. Burditt
>
>But it could have been implemented so that streams of stdin, stdout,
>stderr, and pipe automatically got names: "stdin", "stdout", "stderr",
>and "pipe".
That's fine if there's a law that you can't use the name for anything
but an error message to be read by a human. Also, someone is going
to write code that gets upset when fopen(get_filename_from_stream(f),
"r") fails.
Hmm, and what happens when stdin *IS* a pipe, which is not that
uncommon.
And then some idiot is going to write code like:
int dosomething(FILE *f, double ***v) {
int result;
if (strcmp(get_filename_from_stream(f), "pipe") == 0) {
/* do something different */
} else {
/* do the normal thing */
}
return result;
}
Ever hear of data hiding in C++? There's a reason why I pass streams
and DON'T pass file names as arguments to most functions that deal
with streams.
One guy wanted to take a read-only stream I passed in, figure out
the file name, open it for write, and fix (style) errors in it.
Then he got upset when doing that destroyed a lot of his source
code (due to a slight bug in the "fix" code, plus the fact that he
didn't know I was using his code in more than one program) which
he wasn't expecting to have directly passed to that function. The
really disturbing part was that his code was getting mangled and
he didn't realize that any changes were being made at all (so the
last couple of backups also had the corrupted code).
Gordon L. Burditt
- Next message: JS: "Problems running TeXniCcenter with wine"
- Previous message: Bjorn Reese: "Re: How to use xtrace?"
- In reply to: Russell Shaw: "Re: File name from stream"
- Next in thread: Russell Shaw: "Re: File name from stream"
- Reply: Russell Shaw: "Re: File name from stream"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|