VirtualBox

Changeset 74715 in vbox


Ignore:
Timestamp:
Oct 9, 2018 11:56:08 AM (6 years ago)
Author:
vboxsync
Message:

DnD/URIList: Added support for handling UNC paths.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/VBox/GuestHost/DragAndDrop.h

    r74714 r74715  
    268268#define DNDURILIST_FLAGS_LAZY                   RT_BIT(3)
    269269
     270/** Mask of all valid DnD URI list flags. */
     271#define DNDURILIST_FLAGS_VALID_MASK             UINT32_C(0xF)
     272
    270273class DnDURIList
    271274{
  • trunk/src/VBox/GuestHost/DragAndDrop/DnDURIList.cpp

    r74714 r74715  
    339339{
    340340    AssertPtrReturn(pszURI, VERR_INVALID_POINTER);
    341 
     341    AssertReturn(!(fFlags & ~DNDURILIST_FLAGS_VALID_MASK), VERR_INVALID_FLAGS);
    342342    /** @todo Check for string termination?  */
    343 #ifdef DEBUG_andy
    344     LogFlowFunc(("pszPath=%s, fFlags=0x%x\n", pszURI, fFlags));
    345 #endif
    346     int rc = VINF_SUCCESS;
    347 
    348     /* Query the path component of a file URI. If this hasn't a
    349      * file scheme NULL is returned. */
    350     char *pszSrcPath = RTUriFilePath(pszURI);
    351     if (pszSrcPath)
     343
     344    RTURIPARSED Parsed;
     345    int rc = RTUriParse(pszURI, &Parsed);
     346    if (RT_FAILURE(rc))
     347        return rc;
     348
     349    char *pszSrcPath = NULL;
     350
     351    /* file://host.example.com/path/to/file.txt */
     352    const char *pszParsedAuthority = RTUriParsedAuthority(pszURI, &Parsed);
     353    if (   pszParsedAuthority
     354        && pszParsedAuthority[0] != '\0') /* Authority present? */
     355    {
     356        const char *pszParsedPath = RTUriParsedPath(pszURI, &Parsed);
     357        if (pszParsedPath)
     358        {
     359            /* Always use UNIXy paths internally. */
     360            if (RTStrAPrintf(&pszSrcPath,  "//%s%s", pszParsedAuthority, pszParsedPath) == -1)
     361                rc = VERR_NO_MEMORY;
     362        }
     363        else
     364            rc = VERR_INVALID_PARAMETER;
     365    }
     366    else
     367    {
     368        pszSrcPath = RTUriFilePath(pszURI);
     369        if (!pszSrcPath)
     370            rc = VERR_INVALID_PARAMETER;
     371    }
     372
     373    LogFlowFunc(("pszURI=%s, fFlags=0x%x -> pszParsedAuthority=%s, pszSrcPath=%s, rc=%Rrc\n",
     374                 pszURI, fFlags, pszParsedAuthority ? pszParsedAuthority : "<None>", pszSrcPath, rc));
     375
     376    if (RT_SUCCESS(rc))
    352377    {
    353378        /* Add the path to our internal file list (recursive in
     
    366391                m_lstRoot.append(pszDstPath);
    367392
    368                 LogFlowFunc(("pszFilePath=%s, pszFileName=%s, pszRoot=%s\n",
     393                LogFlowFunc(("pszSrcPath=%s, pszFileName=%s, pszRoot=%s\n",
    369394                             pszSrcPath, pszFileName, pszDstPath));
    370395
     
    376401        else
    377402            rc = VERR_INVALID_PARAMETER;
    378 
    379         RTStrFree(pszSrcPath);
    380     }
    381     else
    382         rc = VERR_INVALID_PARAMETER;
     403    }
     404
     405    RTStrFree(pszSrcPath);
    383406
    384407    LogFlowFuncLeaveRC(rc);
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