daroczig/saves — Issue #4: Fix use of tempdir()
Author: nalimilan
Created: 2011-10-11 19:52:33+00:00
State: open

save() doesn't use tempdir() correctly, which leads to warnings when calling it several times : the same file is being overwritten again and again. If you look at ?tempdir, you'll see that you shouldn't do:
tmp <- paste(tempdir(), '/saves.temp', sep='')
but
tmp <- tempfile('saves', fileext='.RDatas')

The reason is, tempdir() always returns the same dir, and that's why tempfile() exists: to find a unique name. This also avoids security issues, as malicious programs could trick you into writing to some weird place be creating a symlink at the place they know you'll create the temp file (remember, most of the time, any user on the system can write to temp directories).