graham@sce.carleton.ca (Doug Graham) (06/24/90)
In article <6983@star.cs.vu.nl> jdvries@cs.vu.nl (Vries de Jeroen) writes: >In response to article <1990Jun21.153307.19229@cbnewsc.att.com> tjr@cbnewsc.att.com (thomas.j.roberts): > [about text mode vs. binary mode] >2) True, but if you want your copy routine to be able to > concatenate text files as well (and why not?) be sure to open > your files in text mode anyway or else your result will contain > multiple EOF marks. Well, you can't have it both ways. But even if you did want to concatenate text files, you could do it much faster by opening the files in binary mode, and diddling the EOF marks yourself. All that CRLF mapping done in text mode takes a lot of time (especially on write's), and is unecessary if you're just going to copy the text from one file to another. On writes, it's not the CRLF mapping itself that takes most of the time, it's because the actual disk I/O would have to be done in smaller chunks, and because, the amount of data actually written to the disk per write call, would no long be a multiple of the sector size, so the DOS buffers get involved. [about read/write vs. fread/fwrite] >3) True again but it doesn't make that much of a difference when > using fread and fwrite. This depends very much on the implementation of the stdio package. Your comment is true for MSC, but not for Turbo C. It seems that the Turbo C fread/fread will copy the data through the stdio buffers, and do the the disk I/O in BUFSIZ chunks. Needless to say, this drastically reduces performance. >4) Don't use filelength(), use stat() instead. Why? Is the subject now portability, or is this somehow related to speed? -- Doug.