home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.unix.programmer
- Path: sparky!uunet!ferkel.ucsb.edu!taco!dwthoma1
- From: dwthoma1@eos.ncsu.edu (DAVID W THOMAS)
- Subject: Re: /tmp files
- Message-ID: <1992Jul31.184928.6018@ncsu.edu>
- Originator: dwthoma1@c00041-118dan.eos.ncsu.edu
- Lines: 20
- Sender: news@ncsu.edu (USENET News System)
- Reply-To: dwthoma1@eos.ncsu.edu (DAVID W THOMAS)
- Organization: North Carolina State University, Project Eos
- References: <1992Jul31.095122@is.morgan.com>
- Date: Fri, 31 Jul 1992 18:49:28 GMT
-
-
- In article <1992Jul31.095122@is.morgan.com>, scairns@is.morgan.com writes:
- |> Is there a system call to randomly generate unique file names
- |> in /tmp?
-
- yep, try tempnam(3s).
-
- (e.g. tempnam("/usr/spool/batch", "job") --> /usr/spool/batch/jobAAA12345
- tempnam("/tmp", "mine") --> /tmp/mineAAA12345
- )
-
- it uses a combination of the string you give it, the current process id,
- and other letters so that multiple temporary files can be generated
- by the same program.
-
- you also get to choose which directory to use, and it checks in that directory
- to ensure the file name is unique (at the time the name is created).
-
- David W. Thomas
- dwthoma1@eos.ncsu.edu
-