30 #include <nsIFileURL.h>
31 #include <nsIIOService.h>
34 #include <nsNetError.h>
35 #include <nsStringAPI.h>
36 #include <nsThreadUtils.h>
40 static inline nsresult
43 NS_ENSURE_ARG_POINTER(aURI);
45 nsCString strExtension;
48 nsresult rv = aURI->GetPath(strPath);
49 NS_ENSURE_SUCCESS(rv, rv);
51 if (strPath.IsEmpty())
54 PRInt32 fileExtPosStart = strPath.RFindChar(
'.');
55 PRInt32 fileExtPosEnd = strPath.RFindChar(
'?');
57 if(fileExtPosEnd > fileExtPosStart) {
58 strExtension = Substring(strPath, fileExtPosStart, fileExtPosEnd - fileExtPosStart);
61 strExtension = Substring(strPath, fileExtPosStart);
65 strExtension.Trim(
".");
67 _retval.Assign(strExtension);
72 static inline nsresult
75 NS_ENSURE_ARG_POINTER(aFileURL);
86 rv = aFileURL->GetScheme(scheme);
87 NS_ENSURE_SUCCESS(rv, rv);
88 rv = aFileURL->SetScheme(scheme);
89 NS_ENSURE_SUCCESS(rv, rv);
103 static inline nsresult
110 if (NS_IsMainThread()) {
111 ioService = do_GetService(NS_IOSERVICE_CONTRACTID, &rv);
112 NS_ENSURE_SUCCESS(rv, rv);
116 NS_ENSURE_SUCCESS(rv, rv);
120 ioService.forget(aIOService);
138 static inline nsresult
140 const nsACString& aSpec,
141 const char* aCharSet = nsnull,
142 nsIURI* aBaseURI = nsnull)
149 NS_ENSURE_SUCCESS(rv, rv);
152 nsCOMPtr<nsIURI>
uri;
153 rv = ioService->NewURI(aSpec, aCharSet, aBaseURI, getter_AddRefs(uri));
154 NS_ENSURE_SUCCESS(rv, rv);
158 NS_ENSURE_SUCCESS(rv, rv);
161 mainThreadURI.forget(aURI);
166 static inline nsresult
168 const nsAString& aSpec,
169 const char* aCharSet = nsnull,
170 nsIURI* aBaseURI = nsnull)
172 return SB_NewURI(aURI, NS_ConvertUTF16toUTF8(aSpec), aCharSet, aBaseURI);
175 static inline nsresult
178 nsIURI* aBaseURI = nsnull)
180 return SB_NewURI(aURI, nsDependentCString(aSpec), nsnull, aBaseURI);
static nsresult sbGetFileExtensionFromURI(nsIURI *aURI, nsACString &_retval)
const NS_ERROR_MALFORMED_URI
static nsresult SB_NewURI(nsIURI **aURI, const nsACString &aSpec, const char *aCharSet=nsnull, nsIURI *aBaseURI=nsnull)
const sbCreateProxiedComponent do_ProxiedGetService(const nsCID &aCID, nsresult *error=0)
sbMainThreadQueryInterface do_MainThreadQueryInterface(nsISupports *aSupports, nsresult *aResult=nsnull)
static nsresult sbInvalidateFileURLCache(nsIFileURL *aFileURL)
static nsresult SB_GetIOService(nsIIOService **aIOService)