int DnDURIList::AppendNativePath(const char *pszPath, uint32_t fFlags) { AssertPtrReturn(pszPath, VERR_INVALID_POINTER); int rc; char *pszPathNative = RTStrDup(pszPath); if (pszPathNative) { RTPathChangeToUnixSlashes(pszPathNative, true /* fForce */); char *pszPathURI = RTUriCreate("file" /* pszScheme */, "/" /* pszAuthority */, pszPathNative, NULL /* pszQuery */, NULL /* pszFragment */); if (pszPathURI) { rc = AppendURIPath(pszPathURI, fFlags); RTStrFree(pszPathURI); } else rc = VERR_INVALID_PARAMETER; RTStrFree(pszPathNative); } else rc = VERR_NO_MEMORY; return rc; }
/* static */ int DnDURIObject::RebaseURIPath(RTCString &strPathAbs, const RTCString &strBaseOld /* = "" */, const RTCString &strBaseNew /* = "" */) { char *pszPath = RTUriFilePath(strPathAbs.c_str()); if (!pszPath) /* No URI? */ pszPath = RTStrDup(strPathAbs.c_str()); int rc; if (pszPath) { const char *pszPathStart = pszPath; const char *pszBaseOld = strBaseOld.c_str(); if ( pszBaseOld && RTPathStartsWith(pszPath, pszBaseOld)) { pszPathStart += strlen(pszBaseOld); } rc = VINF_SUCCESS; if (RT_SUCCESS(rc)) { char *pszPathNew = RTPathJoinA(strBaseNew.c_str(), pszPathStart); if (pszPathNew) { char *pszPathURI = RTUriCreate("file" /* pszScheme */, "/" /* pszAuthority */, pszPathNew /* pszPath */, NULL /* pszQuery */, NULL /* pszFragment */); if (pszPathURI) { LogFlowFunc(("Rebasing \"%s\" to \"%s\"\n", strPathAbs.c_str(), pszPathURI)); strPathAbs = RTCString(pszPathURI) + "\r\n"; RTStrFree(pszPathURI); } else rc = VERR_INVALID_PARAMETER; RTStrFree(pszPathNew); } else rc = VERR_NO_MEMORY; } RTStrFree(pszPath); } else rc = VERR_NO_MEMORY; return rc; }
/** @todo Put this into an own class like DnDURIPath : public RTCString? */ int DnDURIObject::RebaseURIPath(RTCString &strPath, const RTCString &strBaseOld, const RTCString &strBaseNew) { int rc; const char *pszPath = RTUriPath(strPath.c_str()); if (pszPath) { const char *pszPathStart = pszPath; const char *pszBaseOld = strBaseOld.c_str(); if ( pszBaseOld && RTPathStartsWith(pszPath, pszBaseOld)) { pszPathStart += strlen(pszBaseOld); } rc = VINF_SUCCESS; if (RT_SUCCESS(rc)) { char *pszPathNew = RTPathJoinA(strBaseNew.c_str(), pszPathStart); if (pszPathNew) { char *pszPathURI = RTUriCreate("file" /* pszScheme */, "/" /* pszAuthority */, pszPathNew /* pszPath */, NULL /* pszQuery */, NULL /* pszFragment */); if (pszPathURI) { #ifdef DEBUG_andy LogFlowFunc(("Rebasing \"%s\" to \"%s\"", strPath.c_str(), pszPathURI)); #endif strPath = RTCString(pszPathURI) + "\r\n"; RTStrFree(pszPathURI); rc = VINF_SUCCESS; } else rc = VERR_INVALID_PARAMETER; RTStrFree(pszPathNew); } else rc = VERR_NO_MEMORY; } } else rc = VERR_INVALID_PARAMETER; #ifdef DEBUG_andy LogFlowFuncLeaveRC(rc); #endif return rc; }