6938627: Make temporary directory use property java.io.tmpdir when specified

Get java.io.tmpdir property in os::get_temp_directory() and call this instead of harcoding "/tmp".  Don't assume trailing file_separator either.

Reviewed-by: dholmes, kamg
This commit is contained in:
Coleen Phillimore 2010-03-31 16:51:18 -07:00
parent 7aaaad73cf
commit 47cda47c42
11 changed files with 83 additions and 51 deletions

View file

@ -147,11 +147,11 @@ static char* get_user_tmp_dir(const char* user) {
const char* tmpdir = os::get_temp_directory();
const char* perfdir = PERFDATA_NAME;
size_t nbytes = strlen(tmpdir) + strlen(perfdir) + strlen(user) + 2;
size_t nbytes = strlen(tmpdir) + strlen(perfdir) + strlen(user) + 3;
char* dirname = NEW_C_HEAP_ARRAY(char, nbytes);
// construct the path name to user specific tmp directory
snprintf(dirname, nbytes, "%s%s_%s", tmpdir, perfdir, user);
snprintf(dirname, nbytes, "%s/%s_%s", tmpdir, perfdir, user);
return dirname;
}
@ -322,8 +322,9 @@ static char* get_user_name_slow(int vmid, TRAPS) {
}
char* usrdir_name = NEW_C_HEAP_ARRAY(char,
strlen(tmpdirname) + strlen(dentry->d_name) + 1);
strlen(tmpdirname) + strlen(dentry->d_name) + 2);
strcpy(usrdir_name, tmpdirname);
strcat(usrdir_name, "/");
strcat(usrdir_name, dentry->d_name);
DIR* subdirp = os::opendir(usrdir_name);