Re: Happy christmas
- From: Flash Gordon <spam@xxxxxxxxxxxxxxxxxx>
- Date: Thu, 27 Dec 2007 21:31:25 +0000
Bart C wrote, On 27/12/07 20:48:
"Flash Gordon" <spam@xxxxxxxxxxxxxxxxxx> wrote in message news:561d45x2q1.ln2@xxxxxxxxxxxxxxxxxxxxxxxxxxBart C wrote, On 27/12/07 13:23:
I'm used to text files using one of CR, LF or CRLF to terminate lines. I have routines that read a line at a time and take care of this. And binary mode means a 'getfilesize()' function is more accurate.So it fails under VMS.
I don't even know what VMS is; something to do with IBM?
No, when I was using it it was from the Digital Electric Company (IIRC) AKA DEC.
I'm hardly likely to have such a system as a hobbyist programmer in my front room.
You can if you want.
The computers I can buy tend to have Windows. And years ago when I was selling software my clients all had Windows too.
Mine are Windows and/or *nix these days.
Do you also correctly handle a ^Z in a text file if I use a Windows program that appends one to indicate the end?
If reading an entire file into memory, I append ETX and NUL to aid the caller when scanning the data. A double ETX won't do any harm.
This is the sort of thing that used to lead to text files slowly growing as each load/save cycle added another ^Z.
The NUL turns it into an ASCIIZ string (yes, I assume ASCII; the last non-ASCII machine I used was in 1977).
For many this is a valid assumption. I have no objection to it when it is known to be a limitation.
OK, so you prefer to have to write code to handle the vagaries of every implementation of interest. Just as long as you realise there can be a lot more variety than you are currently aware of.
I tend to overlay my own API over the C runtime library. Then it's slightly more immune to changes in the host OS.
This is indeed the "correct" way of dealing with system specifics and providing a higher level API when appropriate.
Although for some of us that's unlikely to be anything other than Windows or Linux. Except perhaps code running on servers? And perhaps embedded systems but that's a different world anyway.
For some the world is limited to a small subset of existing systems and there is nothing wrong with this. You seem to know about the portability limits you are placing on your code and decided that they are acceptable. I see nothing wrong with this where, as seems to be the case with you, you are *aware* that you are sacrificing some level of portability for other benefits such as ease of coding.
I also agree that sometimes there are good reasons for treating text files as binary, such as when your program has to deal with idiot lusers who use the wrong method of transferring text files, as long as again it is known that this limits the systems your code is portable to.
--
Flash Gordon
.
- Follow-Ups:
- Re: Happy christmas
- From: Bart C
- Re: Happy christmas
- References:
- Happy christmas
- From: jacob navia
- Re: Happy christmas
- From: Bart C
- Re: Happy christmas
- From: Keith Thompson
- Re: Happy christmas
- From: Bart C
- Re: Happy christmas
- From: Flash Gordon
- Re: Happy christmas
- From: Bart C
- Happy christmas
- Prev by Date: Re: Programming in standard c
- Next by Date: Re: Programming in standard c
- Previous by thread: Re: Happy christmas
- Next by thread: Re: Happy christmas
- Index(es):
Relevant Pages
|