Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!uunet!mtxinu!shore From: shore@mtxinu.COM (Melinda Shore) Newsgroups: comp.unix.sysv386 Subject: Re: Converting DOS text files Keywords: SCO ODT Message-ID: <1375@mtxinu.UUCP> Date: 19 Oct 90 01:27:22 GMT References: <1477@pai.UUCP> <4339@rsiatl.UUCP> Reply-To: shore@mtxinu.com (Melinda Shore) Organization: mt Xinu, Berkeley Lines: 34 In article <4339@rsiatl.UUCP> jgd@rsiatl.UUCP (John G. DeArmond) writes: >While one could (successfully) argue that a system() or fork() system >call would be more expensive than processing small files a byte at a time, >for typical files, this would not be the case. And for machines that >process I/O system calls slowly (NCR towers come to mind), even small >files would seriously degrade performance, especially if you are doing >a lot of them. I'm not going to get into whether or not the program was great code, but it's worth pointing out that using stdio *is* a reasonably efficient general-case approach. Remember that the library is doing i/o buffering for you in BUFSIZ chunks, which allows you to do what looks like single-character processing on top of buffered i/o. Also, underneath it all, the OS is not going to be doing a disk read for every read() - that's what the buffer cache is all about. (It may do a memory/memory copy, but that's another matter.) Anyway, the point is that you shouldn't be afraid to use stdio if you're worried about efficiency. I never use the system() library routine on SCO. Well, I never use it anyway (it gets the shell involved and does more than I usually want done), but it seems to me that it's particularly to be avoided with SCO because of the way it resets certain signal handlers, in particular SIGCLD. You can avoid doing the copy yourself if the files are on the same filesystem by doing something like link(oldfile, newfile); unlink(oldfile); If the files are on different filesystems somebody is going to have to do the copy, whether it's mv or you do it yourself. Again, stdio will handle the buffering for you and doing getc()/putc() kinds of things isn't inherently inefficient. -- Melinda Shore shore@mtxinu.com mt Xinu ..!uunet!mtxinu.com!shore