home *** CD-ROM | disk | FTP | other *** search
- Xref: sparky comp.sys.sgi:18230 comp.sys.sgi.bugs:28 comp.unix.ultrix:8991
- Path: sparky!uunet!noc.near.net!hri.com!spool.mu.edu!uwm.edu!zaphod.mps.ohio-state.edu!sol.ctr.columbia.edu!eff!world!cmr
- From: cmr@world.std.com (Charles M Richmond)
- Newsgroups: comp.sys.sgi,comp.sys.sgi.bugs,comp.unix.ultrix
- Subject: tmpnam/tempnam
- Message-ID: <BzKIrq.GqI@world.std.com>
- Date: 20 Dec 92 17:19:02 GMT
- Organization: Integrated International Systems Corp. One Longfellow Place, Suite 3309, Boston, Ma.
- Lines: 28
-
-
- All of this discussion about tmpnam/tempnam has lead to small bits of
- foolishness on the part of a lot of people, myself not excepted.
-
- Lets discuss the proper use of tmpnam/tempnam. After creating the filename
- one should open the file as quickly as possible , inorder to preclude the
- creation of an a same named file by another process. Naturally enough one
- would also want to verify the uniqueness of the file name at the start. The
- tmpnam/tempnam duo handles this quite nicely by testing for you. The proper
- sequence of code would then be thus:
-
-
- fname = tmpnam(arg);
- if (errno == ENOENT)
- {
- open(.....
-
- You can massage this in many ways. As an example one could add on a while
- loop for errno != ENOENT to continuously try new names until a unique one
- is found.
-
- Charlie
-
- --
- *****************************************************************************
- * Charles Richmond Integrated International Systems Corporation *
- * cmr@world.std.com (Temporary) cmr@koneko.shr.dec.com *
- * Specializing in UNIX, X, Image Processing, and Communications. *
-