comparison src/os/solaris/vm/perfMemory_solaris.cpp @ 1353:a2ea687fdc7c

6938627: Make temporary directory use property java.io.tmpdir when specified Summary: 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
author coleenp
date Wed, 31 Mar 2010 16:51:18 -0700
parents 98cb887364d3
children c18cbe5936b8
comparison
equal deleted inserted replaced
1330:4a9cc99938e3 1353:a2ea687fdc7c
145 // 145 //
146 static char* get_user_tmp_dir(const char* user) { 146 static char* get_user_tmp_dir(const char* user) {
147 147
148 const char* tmpdir = os::get_temp_directory(); 148 const char* tmpdir = os::get_temp_directory();
149 const char* perfdir = PERFDATA_NAME; 149 const char* perfdir = PERFDATA_NAME;
150 size_t nbytes = strlen(tmpdir) + strlen(perfdir) + strlen(user) + 2; 150 size_t nbytes = strlen(tmpdir) + strlen(perfdir) + strlen(user) + 3;
151 char* dirname = NEW_C_HEAP_ARRAY(char, nbytes); 151 char* dirname = NEW_C_HEAP_ARRAY(char, nbytes);
152 152
153 // construct the path name to user specific tmp directory 153 // construct the path name to user specific tmp directory
154 snprintf(dirname, nbytes, "%s%s_%s", tmpdir, perfdir, user); 154 snprintf(dirname, nbytes, "%s/%s_%s", tmpdir, perfdir, user);
155 155
156 return dirname; 156 return dirname;
157 } 157 }
158 158
159 // convert the given file name into a process id. if the file 159 // convert the given file name into a process id. if the file
320 if (strncmp(dentry->d_name, PERFDATA_NAME, strlen(PERFDATA_NAME)) != 0) { 320 if (strncmp(dentry->d_name, PERFDATA_NAME, strlen(PERFDATA_NAME)) != 0) {
321 continue; 321 continue;
322 } 322 }
323 323
324 char* usrdir_name = NEW_C_HEAP_ARRAY(char, 324 char* usrdir_name = NEW_C_HEAP_ARRAY(char,
325 strlen(tmpdirname) + strlen(dentry->d_name) + 1); 325 strlen(tmpdirname) + strlen(dentry->d_name) + 2);
326 strcpy(usrdir_name, tmpdirname); 326 strcpy(usrdir_name, tmpdirname);
327 strcat(usrdir_name, "/");
327 strcat(usrdir_name, dentry->d_name); 328 strcat(usrdir_name, dentry->d_name);
328 329
329 DIR* subdirp = os::opendir(usrdir_name); 330 DIR* subdirp = os::opendir(usrdir_name);
330 331
331 if (subdirp == NULL) { 332 if (subdirp == NULL) {