Changeset 3214 for branches/libc-0.6/src


Ignore:
Timestamp:
Apr 25, 2007, 2:02:22 AM (18 years ago)
Author:
bird
Message:

/@executable_path. Fixes #153.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/libc-0.6/src/emx/src/lib/sys/fs.c

    r2543 r3214  
    194194 * The special /@unixroot rewrite rule.
    195195 */
    196 static __LIBC_PATHREWRITE   gaRewriteRule =
    197 {
    198     __LIBC_PRWF_CASE_SENSITIVE | __LIBC_PRWF_TYPE_DIR,      "/@unixroot",  10, __libc_gszUnixRoot, 0
     196static __LIBC_PATHREWRITE   gUnixRootRewriteRule =
     197{
     198    __LIBC_PRWF_CASE_SENSITIVE | __LIBC_PRWF_TYPE_DIR,  "/@unixroot",  10, __libc_gszUnixRoot, 0
    199199};
    200200
     201/** The full path to the executable directory. */
     202char __libc_gszExecPath[CCHMAXPATH];
     203
     204/**
     205 * The special /@executable_path rewrite rule.
     206 */
     207static __LIBC_PATHREWRITE   gExecRewriteRule =
     208{
     209    __LIBC_PRWF_CASE_SENSITIVE | __LIBC_PRWF_TYPE_DIR,  "/@executable_path",  17, __libc_gszExecPath, 0
     210};
    201211
    202212/** Array of pointers to fs info objects for all
     
    278288
    279289        /* Register rewrite rule. */
    280         gaRewriteRule.pszTo = "/";
    281         gaRewriteRule.cchTo = 1;
    282         if (__libc_PathRewriteAdd(&gaRewriteRule, 1))
     290        gUnixRootRewriteRule.pszTo = "/";
     291        gUnixRootRewriteRule.cchTo = 1;
     292        if (__libc_PathRewriteAdd(&gUnixRootRewriteRule, 1))
    283293            LIBCLOG_RETURN_INT(-1);
    284294    }
     
    308318
    309319                /* Register the rewrite rule. */
    310                 gaRewriteRule.cchTo = cch;
    311                 if (__libc_PathRewriteAdd(&gaRewriteRule, 1))
     320                gUnixRootRewriteRule.cchTo = cch;
     321                if (__libc_PathRewriteAdd(&gUnixRootRewriteRule, 1))
    312322                    LIBCLOG_RETURN_INT(-1);
    313323            }
     
    315325    }
    316326
     327
     328    /*
     329     * Setup the the executable path rewrite rule.
     330     */
     331    PTIB pTib;
     332    PPIB pPib;
     333    DosGetInfoBlocks(&pTib, &pPib);
     334    rc = DosQueryModuleName(pPib->pib_hmte, sizeof(__libc_gszExecPath), &__libc_gszExecPath[0]);
     335    if (!rc)
     336    {
     337        char *psz = strchr(&__libc_gszExecPath[0], '\0');
     338        while (     psz > &__libc_gszExecPath[0]
     339               &&   *psz != '\\'
     340               &&   *psz != '/'
     341               &&   *psz != ':')
     342            psz--;
     343        *psz = '\0';
     344        gExecRewriteRule.cchTo = psz - &__libc_gszExecPath[0];
     345    }
     346    else
     347    {
     348        LIBC_ASSERTM_FAILED("DosQueryModuleName(exe) failed: hmte=%lx rc=%d\n", pPib->pib_hmte, rc);
     349        gExecRewriteRule.cchTo = 1;
     350        gExecRewriteRule.pszTo = "/";
     351    }
     352    if (__libc_PathRewriteAdd(&gExecRewriteRule, 1))
     353        LIBCLOG_RETURN_INT(-1);
    317354
    318355    /*
     
    573610void __libc_back_fsUpdateUnixRoot(const char *pszUnixRoot)
    574611{
    575     gaRewriteRule.pszTo = "/";
    576     gaRewriteRule.cchTo = 1;
     612    gUnixRootRewriteRule.pszTo = "/";
     613    gUnixRootRewriteRule.cchTo = 1;
    577614
    578615    int cch = strlen(pszUnixRoot);
Note: See TracChangeset for help on using the changeset viewer.