- Timestamp:
- May 2, 2007, 11:43:02 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/libc/src/kNIX/os2/fs-os2.c
r3214 r3289 169 169 /** The full path to the executable directory. */ 170 170 char __libc_gszExecPath[CCHMAXPATH]; 171 172 /** 173 * The special /@executable_path rewrite rule. 174 */ 175 static __LIBC_PATHREWRITE gExecRewriteRule = 176 { 177 __LIBC_PRWF_CASE_SENSITIVE | __LIBC_PRWF_TYPE_DIR, "/@executable_path", 17, __libc_gszExecPath, 0 171 /** The system drive. */ 172 char __libc_gszSystemDrive[4] = "C:"; 173 /** The full path to the host system root directory. */ 174 char __libc_gszSystemRoot[8] = "C:/OS2"; 175 /** The path to the default tmp directory (might be a winding path). */ 176 char __libc_gszTmpDir[CCHMAXPATH] = "C:/TEMP"; 177 178 /** 179 * The misc rewrite rules. 180 */ 181 static __LIBC_PATHREWRITE gaMiscRewriteRules[4] = 182 { 183 { __LIBC_PRWF_CASE_SENSITIVE | __LIBC_PRWF_TYPE_DIR, "/@executable_path", 17, __libc_gszExecPath, 0 }, 184 { __LIBC_PRWF_CASE_SENSITIVE | __LIBC_PRWF_TYPE_DIR, "/@system_drive", 14, __libc_gszSystemDrive, 2 }, 185 { __LIBC_PRWF_CASE_SENSITIVE | __LIBC_PRWF_TYPE_DIR, "/@system_root", 13, __libc_gszSystemRoot, 6 }, 186 { __LIBC_PRWF_CASE_SENSITIVE | __LIBC_PRWF_TYPE_DIR, "/@tmpdir", 8, __libc_gszTmpDir, 7 } 178 187 }; 179 188 … … 285 294 psz--; 286 295 *psz = '\0'; 287 g ExecRewriteRule.cchTo = psz - &__libc_gszExecPath[0];296 gaMiscRewriteRules[0].cchTo = psz - &__libc_gszExecPath[0]; 288 297 } 289 298 else 290 299 { 291 300 LIBC_ASSERTM_FAILED("DosQueryModuleName(exe) failed: hmte=%lx rc=%d\n", pPib->pib_hmte, rc); 292 gExecRewriteRule.cchTo = 1; 293 gExecRewriteRule.pszTo = "/"; 294 } 295 if (__libc_PathRewriteAdd(&gExecRewriteRule, 1)) 296 LIBCLOG_RETURN_INT(-1); 301 gaMiscRewriteRules[0].cchTo = 1; 302 gaMiscRewriteRules[0].pszTo = "/"; 303 } 304 305 /* 306 * Setup the the (host) system root path and system root drive rewrite rules. 307 */ 308 ULONG ulBootDrive; 309 if (DosQuerySysInfo(QSV_BOOT_DRIVE, QSV_BOOT_DRIVE, &ulBootDrive, sizeof(ulBootDrive))) 310 ulBootDrive = 'C' - 'A' - 1; /* A = 1 */ 311 __libc_gszTmpDir[0] = __libc_gszSystemRoot[0] = __libc_gszSystemDrive[0] 312 = (char)ulBootDrive + 'A' - 1; 313 314 /* 315 * Setup the the temp path rewrite rule. 316 */ 317 size_t cchTmp = 0; 318 char *pszTmp = getenv("TMP"); 319 if (pszTmp) 320 cchTmp = strlen(pszTmp); 321 if (!pszTmp || cchTmp >= sizeof(__libc_gszTmpDir) - 1) 322 { 323 pszTmp = getenv("TEMP"); 324 if (pszTmp) 325 cchTmp = strlen(pszTmp); 326 if (!pszTmp || cchTmp >= sizeof(__libc_gszTmpDir) - 1) 327 { 328 pszTmp = getenv("TMPDIR"); 329 if (pszTmp) 330 cchTmp = strlen(pszTmp); 331 } 332 } 333 if (pszTmp && cchTmp <= sizeof(__libc_gszTmpDir) - 1) 334 { 335 /** @todo cleanup the thing so it won't get rejected! */ 336 memcpy(__libc_gszTmpDir, pszTmp, cchTmp + 1); 337 gaMiscRewriteRules[3].cchTo = cchTmp; 338 } 339 340 /* 341 * Finally register the rules. 342 */ 343 /** @todo Make static rules from these and only update the replacement value and length. */ 344 if (__libc_PathRewriteAdd(&gaMiscRewriteRules[0], 4)) 345 { 346 /* tmp rewrite rule is busted by the env.var., use the default. */ 347 memcpy(__libc_gszTmpDir, "C:/TEMP", sizeof("C:/TEMP")); 348 gaMiscRewriteRules[3].cchTo = sizeof("C:/TEMP") - 1; 349 if (__libc_PathRewriteAdd(&gaMiscRewriteRules[0], 4)) 350 LIBCLOG_RETURN_INT(-1); 351 } 352 297 353 298 354 /*
Note:
See TracChangeset
for help on using the changeset viewer.