void nsEscapeNativePath(nsCString& nativePath) { #if defined(XP_WIN) || defined(XP_OS2) nativePath.Insert('/', 0); MsgReplaceChar(nativePath, '\\', '/'); #endif }
static HPOINTER GetIcon(nsCString& file, bool fExists, bool fMini, bool *fWpsIcon) { HPOINTER hRtn = 0; *fWpsIcon = false; if (file.IsEmpty()) { // append something so that we get at least the generic icon file.Append("pmwrlw"); } // if RWS is enabled, try to get the icon from the WPS if (sUseRws) { nsCOMPtr<nsIRwsService> rwsSvc(do_GetService("@mozilla.org/rwsos2;1")); if (!rwsSvc) sUseRws = false; else { if (fExists) { rwsSvc->IconFromPath(file.get(), false, fMini, (uint32_t*)&hRtn); } else { const char *ptr = file.get(); if (*ptr == '.') ptr++; rwsSvc->IconFromExtension(ptr, fMini, (uint32_t*)&hRtn); } } } // if we got an icon from the WPS, set the flag & exit if (hRtn) { *fWpsIcon = true; return hRtn; } // if the file exists already, get its icon if (fExists) return WinLoadFileIcon(file.get(), FALSE); // otherwise, create a temporary file with the correct extension, // then retrieve whatever icon PM assigns it if (file.First() == '.') file.Insert("moztmp", 0); nsCOMPtr<nsIFile> tempPath; if (NS_FAILED(NS_GetSpecialDirectory(NS_OS_TEMP_DIR, getter_AddRefs(tempPath))) || NS_FAILED(tempPath->AppendNative(file))) return 0; nsAutoCString pathStr; tempPath->GetNativePath(pathStr); FILE* fp = fopen(pathStr.get(), "wb+"); if (fp) { fclose(fp); hRtn = WinLoadFileIcon(pathStr.get(), FALSE); remove(pathStr.get()); } return hRtn; }
static nsresult MangleKeywordIntoURI(const char *aKeyword, const char *aURL, nsCString& query) { query = (*aKeyword == '?') ? (aKeyword + 1) : aKeyword; query.Trim(" "); // pull leading/trailing spaces. // encode char * encQuery = nsEscape(query.get(), url_XPAlphas); if (!encQuery) return NS_ERROR_OUT_OF_MEMORY; query.Adopt(encQuery); // prepend the query with the keyword url // XXX this url should come from somewhere else query.Insert(aURL, 0); return NS_OK; }