Path: utzoo!attcan!uunet!lll-winken!lll-lcc!ames!mailrus!nrl-cmf!ukma!psuvm.bitnet!rice.bitnet!storkel From: STORKEL@RICE.BITNET (Scott Storkel) Newsgroups: comp.sys.mac.programmer Subject: How I hate MPW stdio... Message-ID: <344STORKEL@RICE> Date: 7 Jun 88 23:03:50 GMT Organization: Rice University - ICSA Lines: 27 I just discovered a VERY interesting little fact about using stdio from MPW C. For the last few days, I have been working on writing a Macintosh interface for a program that converts MacWrite files to into Script. This program was originally written to run on Unix machines. No problem, I thought, I'll just write some Mac routines to get the file names, and let the stdio routines built into MPW C do all the work for me. I finally managed to get the Mac stuff working, and the program which runs fine on a Sun, doesn't work on the Mac. The problem was that the output file was truncated. The part of the file that was there was fine, but part of it was missing. After trying all kinds of variations of fflush, fclose, and so on I finally found the problem. I was calling ExitToShell() to quit from the program, and NOT exit(). It seems to me that as long as I have called fclose() to close the file, I should not have to call exit(). However, if I don't call exit() the output file is truncated, and the Finder says that it is locked or in use. It seems that this is a BAD policy. What if the user converts a file, then sits around for a few minutes staring at the wonderful About.. dialog box, and then power goes out? BOOM, his file is trashed. Is there any way around this type of situation? Will changing the way in which the stream is buffered make any difference? Please mail any response directly to me, if possible. Scott Storkel Macintosh Software Development Rice University Houston, Texas