VirtualBox

Changeset 15756 in vbox for trunk/src/VBox/Runtime


Ignore:
Timestamp:
Dec 25, 2008 11:12:42 AM (16 years ago)
Author:
vboxsync
Message:

Runtime: RTPathAbs: Fixed the "." case on POSIX, fixed the "" case on Windows.

Location:
trunk/src/VBox/Runtime
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Runtime/r3/posix/path-posix.cpp

    r15754 r15756  
    180180    fsCleanPath(szTmpPath);
    181181
     182    /*
     183     * fsCleanPath will leave the single dot alone, we don't need it here.
     184     */
     185    if (szTmpPath[0] == '.' && !szTmpPath[1])
     186        szTmpPath[0] = '\0';
     187
    182188    char *pszCur = szTmpPath;
    183189
     
    214220
    215221        {
    216             /*
    217              * Convert result and copy it to the return buffer.
    218              */
    219222            char *pszUtf8CurDir;
    220223            int rc = rtPathFromNative(&pszUtf8CurDir, szCurDir);
  • trunk/src/VBox/Runtime/r3/win/path-win.cpp

    r15755 r15756  
    9999RTDECL(int) RTPathAbs(const char *pszPath, char *pszAbsPath, size_t cchAbsPath)
    100100{
     101    Assert(VALID_PTR(pszPath));
     102
     103    /*
     104     * When the input path is just "", GetFullPathNameW() will return a full
     105     * executable name instead of the current directory (as the POSIX sister .
     106     * does). Go the POSIX way with the following workaround.
     107     */
     108    static const char szSingleDot[] = ".";
     109    if (!pszPath[0])
     110        pszPath = szSingleDot;
     111
    101112    /*
    102113     * Convert to UTF-16, call Win32 API, convert back.
  • trunk/src/VBox/Runtime/testcase/tstPath.cpp

    r15754 r15756  
    101101    {
    102102#if defined (RT_OS_OS2) || defined (RT_OS_WINDOWS)
    103 //  { NULL, "", VINF_SUCCESS, "%p" },
    104 //  { NULL, ".", VINF_SUCCESS, "%p" },
     103    { NULL, "", VINF_SUCCESS, "%p" },
     104    { NULL, ".", VINF_SUCCESS, "%p" },
    105105    { NULL, "\\", VINF_SUCCESS, "%d\\" },
    106106    { NULL, "\\..", VINF_SUCCESS, "%d\\" },
     
    114114    { "relative_base/dir/", "relative_also", VINF_SUCCESS, "%p\\relative_base\\dir\\relative_also" },
    115115#else
    116 //  { NULL, "", VINF_SUCCESS, "/" },
    117 //  { NULL, ".", VINF_SUCCESS, "%p" },
     116    { NULL, "", VINF_SUCCESS, "%p" },
     117    { NULL, ".", VINF_SUCCESS, "%p" },
    118118    { NULL, "/", VINF_SUCCESS, "/" },
    119119    { NULL, "/..", VINF_SUCCESS, "/" },
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette