help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: generating a user-specific string


From: Søren Hauberg
Subject: Re: generating a user-specific string
Date: Tue, 27 Apr 2010 15:37:01 -0700

tir, 27 04 2010 kl. 17:15 -0400, skrev Qianqian Fang:
> I am working on an octave toolbox that requires to save
> some intermediate outputs to a temporary directory (as returned
> by tempdir). However, multiple users may write to tempdir
> so they will face the permission conflict if the filenames are
> the same. So, I am thinking to create sub-folders under tempdir
> for each user, something like /tmp/session-user1/...
> 
> I don't know if it is possible for octave to return me a
> unique string for each user, so, everyone will be able to
> save to its own folder across multiple sessions.
> tempname is not preferred as it changes everytime,
> which presumably will leave a lot of folders under /tmp.

The 'tmpnam' function can be used for something like this. If you want
to include the user name in the string, you can (on Unix at least) get
it using

  getenv ("USER")

So,

  tmpnam ("/tmp", getenv ("USER"))

should essentially do what you want.

Søren



reply via email to

[Prev in Thread] Current Thread [Next in Thread]