home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #16 / NN_1992_16.iso / spool / comp / unix / programm / 4043 < prev    next >
Encoding:
Text File  |  1992-07-31  |  1.1 KB  |  34 lines

  1. Newsgroups: comp.unix.programmer
  2. Path: sparky!uunet!ferkel.ucsb.edu!taco!dwthoma1
  3. From: dwthoma1@eos.ncsu.edu (DAVID W THOMAS)
  4. Subject: Re: /tmp files
  5. Message-ID: <1992Jul31.184928.6018@ncsu.edu>
  6. Originator: dwthoma1@c00041-118dan.eos.ncsu.edu
  7. Lines: 20
  8. Sender: news@ncsu.edu (USENET News System)
  9. Reply-To: dwthoma1@eos.ncsu.edu (DAVID W THOMAS)
  10. Organization: North Carolina State University, Project Eos
  11. References:  <1992Jul31.095122@is.morgan.com>
  12. Date: Fri, 31 Jul 1992 18:49:28 GMT
  13.  
  14.  
  15. In article <1992Jul31.095122@is.morgan.com>, scairns@is.morgan.com writes:
  16. |> Is there a system call to randomly generate unique file names
  17. |> in /tmp?  
  18.  
  19. yep, try tempnam(3s).
  20.  
  21. (e.g.  tempnam("/usr/spool/batch", "job")  --> /usr/spool/batch/jobAAA12345
  22.        tempnam("/tmp", "mine")             --> /tmp/mineAAA12345
  23. )
  24.  
  25. it uses a combination of the string you give it, the current process id,
  26. and other letters so that multiple temporary files can be generated
  27. by the same program.
  28.  
  29. you also get to choose which directory to use, and it checks in that directory
  30. to ensure the file name is unique (at the time the name is created).
  31.  
  32. David W. Thomas
  33. dwthoma1@eos.ncsu.edu
  34.