comparison src/os/linux/vm/os_linux.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 98ba8ca25feb
children f03d0a26bf83 96d554193f72
comparison
equal deleted inserted replaced
1330:4a9cc99938e3 1353:a2ea687fdc7c
1520 1520
1521 // DLL functions 1521 // DLL functions
1522 1522
1523 const char* os::dll_file_extension() { return ".so"; } 1523 const char* os::dll_file_extension() { return ".so"; }
1524 1524
1525 const char* os::get_temp_directory() { return "/tmp/"; } 1525 const char* os::get_temp_directory() {
1526 const char *prop = Arguments::get_property("java.io.tmpdir");
1527 return prop == NULL ? "/tmp" : prop;
1528 }
1526 1529
1527 static bool file_exists(const char* filename) { 1530 static bool file_exists(const char* filename) {
1528 struct stat statbuf; 1531 struct stat statbuf;
1529 if (filename == NULL || strlen(filename) == 0) { 1532 if (filename == NULL || strlen(filename) == 0) {
1530 return false; 1533 return false;
2303 } 2306 }
2304 2307
2305 char buf[40]; 2308 char buf[40];
2306 int num = Atomic::add(1, &cnt); 2309 int num = Atomic::add(1, &cnt);
2307 2310
2308 sprintf(buf, "/tmp/hs-vm-%d-%d", os::current_process_id(), num); 2311 snprintf(buf, sizeof(buf), "%s/hs-vm-%d-%d",
2312 os::get_temp_directory(), os::current_process_id(), num);
2309 unlink(buf); 2313 unlink(buf);
2310 2314
2311 int fd = open(buf, O_CREAT | O_RDWR, S_IRWXU); 2315 int fd = open(buf, O_CREAT | O_RDWR, S_IRWXU);
2312 2316
2313 if (fd != -1) { 2317 if (fd != -1) {