From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,a42a9e2a65b6a5c7 X-Google-Attributes: gid103376,public From: "Jeffrey D. Cherry" Subject: Re: Temporary files in Ada95. Date: 1999/03/31 Message-ID: <37026630.D6B9207C@utech.net>#1/1 X-Deja-AN: 461245640 Content-Transfer-Encoding: 7bit References: <36FFD831.AF11BA9C@utech.net> <7dfrv7$gvv$1@nnrp1.dejanews.com> <7de1t6$usl$1@nnrp1.dejanews.com> <36FBB978.D44CF370@utech.net> <1999Mar26.164208.1@eisner> X-Accept-Language: en Content-Type: text/plain; charset=us-ascii X-Trace: 922904415 200 (none) 206.61.179.74 Organization: Logicon Geodynamics MIME-Version: 1.0 Newsgroups: comp.lang.ada Date: 1999-03-31T00:00:00+00:00 List-Id: Jeffrey, (Great name BTW.) I don't think you want to ask "Is there a way to make ada not write temporary files to the root directory?" since it's not really a language issue. I view it as an implementation issue. I would have thought that GNAT would create the temporary file in a directory where the user has write access. My test showed I was mistaken and your results are apparently the same. From this limited experiment I conclude that the default behavior for creating temporary files, as defined in the Ada LRM, must be used with caution, i.e., trap exceptions for the case where write access is denied by the operating system. In terms of GNAT, I'm guessing their implementation decision was due to either portability issues or simplification based on standard C I/O functions. To their credit, I haven't found any violation of the rules defined in the Ada LRM. For your particular development effort on Windows NT, may I suggest you look in the Win32 library of services. Specifically, look in the package Win32.Winbase and you will find two functions that are designed for creating temporary files. These functions are named GetTempPath and GetTempFileName. The GetTempPath function provides the path defined by the environment variable TMP, or TEMP is TMP does not exist, or the current directory if neither TMP or TEMP exist. This path can then be passed to GetTempFileName which will provide you with a unique file name within the given directory. Refer to the documentation for GetTempFileName for additional options. This should work for all users under NT unless the Administrator has denied them access to the system TEMP directory; an unusual condition in which case your program may have to abort or ask the user to provide a location where a temporary file may be created. Please note that the downside of this method is that the file is NOT deleted once the program terminates. You must remember to delete it yourself. Hope this helps! Regards, Jeffrey D. Cherry