home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #30 / NN_1992_30.iso / spool / comp / sys / sgi / 18230 < prev    next >
Encoding:
Internet Message Format  |  1992-12-21  |  1.6 KB

  1. Xref: sparky comp.sys.sgi:18230 comp.sys.sgi.bugs:28 comp.unix.ultrix:8991
  2. 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
  3. From: cmr@world.std.com (Charles M Richmond)
  4. Newsgroups: comp.sys.sgi,comp.sys.sgi.bugs,comp.unix.ultrix
  5. Subject: tmpnam/tempnam
  6. Message-ID: <BzKIrq.GqI@world.std.com>
  7. Date: 20 Dec 92 17:19:02 GMT
  8. Organization: Integrated International Systems Corp. One Longfellow Place, Suite 3309, Boston, Ma.
  9. Lines: 28
  10.  
  11.  
  12.   All of this discussion about tmpnam/tempnam has lead to small bits of
  13. foolishness on the part of a lot of people, myself not excepted.
  14.  
  15. Lets discuss the proper use of tmpnam/tempnam.  After creating the filename
  16. one should open the file as quickly as possible , inorder to preclude the
  17. creation of an a same named file by another process. Naturally enough one
  18. would also want to verify the uniqueness of the file name at the start. The
  19. tmpnam/tempnam duo handles this quite nicely by testing for you. The proper 
  20. sequence of code would then be thus:
  21.  
  22.  
  23. fname = tmpnam(arg);
  24. if (errno == ENOENT)
  25.    {
  26.    open(.....
  27.  
  28. You can massage this in many ways.  As an example one could add on a while
  29. loop for errno != ENOENT to continuously try new names until a unique one
  30. is found.
  31.  
  32. Charlie
  33.  
  34. -- 
  35. *****************************************************************************
  36. *  Charles Richmond     Integrated International Systems Corporation        *
  37. *  cmr@world.std.com    (Temporary) cmr@koneko.shr.dec.com            *
  38. *  Specializing in UNIX, X, Image Processing, and Communications.           *
  39.