/* static */ RTCString RTCString::joinEx(const RTCList<RTCString, RTCString *> &a_rList, const RTCString &a_rstrPrefix /* = "" */, const RTCString &a_rstrSep /* = "" */) { RTCString strRet; if (a_rList.size() > 1) { /* calc the required size */ size_t cbNeeded = a_rstrSep.length() * (a_rList.size() - 1) + 1; cbNeeded += a_rstrPrefix.length() * (a_rList.size() - 1) + 1; for (size_t i = 0; i < a_rList.size(); ++i) cbNeeded += a_rList.at(i).length(); strRet.reserve(cbNeeded); /* do the appending. */ for (size_t i = 0; i < a_rList.size() - 1; ++i) { if (a_rstrPrefix.isNotEmpty()) strRet.append(a_rstrPrefix); strRet.append(a_rList.at(i)); strRet.append(a_rstrSep); } strRet.append(a_rList.last()); } /* special case: one list item. */ else if (a_rList.size() > 0) { if (a_rstrPrefix.isNotEmpty()) strRet.append(a_rstrPrefix); strRet.append(a_rList.last()); } return strRet; }
RTCString DnDURIList::RootToString(const RTCString &strBasePath /* = "" */, const RTCString &strSeparator /* = "\r\n" */) { RTCString strRet; for (size_t i = 0; i < m_lstRoot.size(); i++) { const char *pszCurRoot = m_lstRoot.at(i).c_str(); #ifdef DEBUG_andy LogFlowFunc(("pszCurRoot=%s\n", pszCurRoot)); #endif if (strBasePath.isNotEmpty()) { char *pszPath = RTPathJoinA(strBasePath.c_str(), pszCurRoot); if (pszPath) { char *pszPathURI = RTUriFileCreate(pszPath); if (pszPathURI) { strRet += RTCString(pszPathURI) + strSeparator; #ifdef DEBUG_andy LogFlowFunc(("URI: %s\n", strRet.c_str())); #endif RTStrFree(pszPathURI); } else break; RTStrFree(pszPath); } else break; } else { char *pszPathURI = RTUriFileCreate(pszCurRoot); if (pszPathURI) { strRet += RTCString(pszPathURI) + strSeparator; #ifdef DEBUG_andy LogFlowFunc(("URI: %s\n", strRet.c_str())); #endif RTStrFree(pszPathURI); } else break; } } return strRet; }