Make file with no extension have correct type and creator info based on MIME type.

This commit is contained in:
sgehani@netscape.com
2001-05-03 01:12:15 +00:00
parent a26d64c519
commit c617f89d19
4 changed files with 45 additions and 16 deletions

View File

@@ -2822,24 +2822,30 @@ NS_IMETHODIMP nsLocalFile::SetFileTypeFromSuffix(const char *suffix)
return SetOSTypeAndCreatorFromExtension(suffix);
}
NS_IMETHODIMP nsLocalFile::SetFileTypeFromMIMEType(const char *mimetype)
NS_IMETHODIMP nsLocalFile::SetFileTypeAndCreatorFromMIMEType(const char *aMIMEType)
{
NS_ENSURE_ARG(mimetype);
NS_ENSURE_ARG(aMIMEType);
nsresult rv;
NS_WITH_SERVICE(nsIInternetConfigService, icService, NS_INTERNETCONFIGSERVICE_CONTRACTID, &rv);
nsCOMPtr<nsIInternetConfigService> icService(do_GetService
(NS_INTERNETCONFIGSERVICE_CONTRACTID, &rv));
if (NS_SUCCEEDED(rv))
{
nsCOMPtr<nsIMIMEInfo> mimeInfo;
rv = icService->FillInMIMEInfo(mimetype, nsnull, getter_AddRefs(mimeInfo));
PRUint32 fileType = 'TEXT';
PRUint32 fileCreator = nsILocalFileMac::CURRENT_PROCESS_CREATOR;
rv = icService->FillInMIMEInfo(aMIMEType,
nsnull, getter_AddRefs(mimeInfo));
if (NS_SUCCEEDED(rv))
{
PRUint32 osType;
rv = mimeInfo->GetMacType(&osType);
if (NS_SUCCEEDED(rv))
mType = osType;
}
rv = mimeInfo->GetMacType(&fileType);
if (NS_SUCCEEDED(rv))
rv = mimeInfo->GetMacCreator(&fileCreator);
if (NS_SUCCEEDED(rv))
rv = SetFileTypeAndCreator(fileType, fileCreator);
}
return rv;
}