static void __ReplaceSubstring (nsAString &string, nsAString &replace, nsAString &with) { PRInt32 i = string.Find (replace); while (i >= 0) { string.Replace (i, replace.Length(), with); i = string.Find (replace); } }
nsresult sbWinGetVolumeGUID(DEVINST aDevInst, nsAString& aVolumeGUID) { nsresult rv; // Start with the volume GUID path. rv = sbWinGetVolumeGUIDPath(aDevInst, aVolumeGUID); NS_ENSURE_SUCCESS(rv, rv); // Strip everything but the volume GUID. Transform // "\\?\Volume{26a21bda-a627-11d7-9931-806e6f6e6963}\" to // "{26a21bda-a627-11d7-9931-806e6f6e6963}". PRInt32 index; index = aVolumeGUID.Find("{"); NS_ENSURE_TRUE(index >= 0, NS_ERROR_UNEXPECTED); aVolumeGUID.Cut(0, index); index = aVolumeGUID.Find("}"); NS_ENSURE_TRUE(index >= 0, NS_ERROR_UNEXPECTED); aVolumeGUID.SetLength(index + 1); return NS_OK; }