Changeset 252 for trunk/openjdk/hotspot/src/os/os2
- Timestamp:
- Jan 28, 2011, 11:17:17 AM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/openjdk/hotspot/src/os/os2/vm/os_os2.cpp
r228 r252 217 217 return MIN2(size, maxMemBlock); 218 218 } 219 220 // Extracts the LIBPATH value from CONFIG.SYS and puts it to the environment 221 // under the JAVA_LIBPATH name unless JAVA_LIBPATH is already set in which 222 // case the existing value is simply returned. 223 const char *getLibPath() 224 { 225 const char *libPath = ::getenv("JAVA_LIBPATH"); 226 if (libPath) 227 return libPath; 228 229 os2_APIRET arc; 230 os2_ULONG drive; 231 arc = DosQuerySysInfo(os2_QSV_BOOT_DRIVE, os2_QSV_BOOT_DRIVE, 232 &drive, sizeof(drive)); 233 if (arc != os2_NO_ERROR) 234 return NULL; 235 236 char configSys[] = "?:\\CONFIG.SYS"; 237 *configSys = drive + 'A' - 1; 238 239 FILE *f = fopen(configSys, "r"); 240 if (!f) 241 return NULL; 242 243 char buf[1024]; 244 char *libPathBuf = NULL; 245 while (!feof(f) && !ferror(f)) { 246 if (fgets(buf, sizeof(buf), f)) { 247 int len = strlen(buf); 248 if (libPathBuf) { 249 // continuation of the LIBPATH string 250 libPathBuf = (char *)realloc(libPathBuf, strlen(libPathBuf) + len + 2); 251 if (!libPathBuf) 252 break; 253 } 254 else if (!strncmp(buf, "LIBPATH", 7)) { 255 // beginning of the LIBPATH string 256 libPathBuf = (char *)malloc(len + 1 + 5 /*JAVA_*/); 257 if (!libPathBuf) 258 break; 259 strcpy(libPathBuf, "JAVA_"); 260 } 261 if (libPathBuf) { 262 strcat(libPathBuf, buf); 263 if (buf[len - 1] == '\n') { 264 // this is the last part, terminate and leave 265 libPathBuf[strlen(libPathBuf) - 1] = '\0'; 266 break; 267 } 268 } 269 } 270 } 271 272 fclose(f); 273 274 ::putenv(libPathBuf); 275 return ::getenv("JAVA_LIBPATH"); 276 }
Note:
See TracChangeset
for help on using the changeset viewer.