зеркало из https://github.com/mozilla/pjs.git
Fix bug # 122757: Mac OS 9/X packages. Also, de-tab. r=tingley sr=waterson
This commit is contained in:
Родитель
a7b8afcb82
Коммит
e53363dd82
|
@ -1,4 +1,4 @@
|
|||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8; c-file-style: "stroustrup" -*- */
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
|
@ -19,9 +19,6 @@
|
|||
* Portions created by the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Pierre Phaneuf <pp@ludusdesign.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
|
@ -80,7 +77,6 @@
|
|||
#include "nsIPlatformCharset.h"
|
||||
#include "nsICharsetConverterManager.h"
|
||||
#include "nsICharsetAlias.h"
|
||||
|
||||
#include "windef.h"
|
||||
#include "winbase.h"
|
||||
#endif
|
||||
|
@ -103,6 +99,7 @@ static NS_DEFINE_CID(kCharsetConverterManagerCID, NS_ICHARSETCONVERTERMANAGER_C
|
|||
#define NS_MOZICON_SCHEME "moz-icon:"
|
||||
|
||||
static const char kURINC_FileSystemRoot[] = "NC:FilesRoot";
|
||||
static const char kFileProtocol[] = "file://";
|
||||
|
||||
|
||||
|
||||
|
@ -159,7 +156,6 @@ public:
|
|||
// helper methods
|
||||
static PRBool isFileURI(nsIRDFResource* aResource);
|
||||
static PRBool isDirURI(nsIRDFResource* aSource);
|
||||
|
||||
static nsresult GetVolumeList(nsISimpleEnumerator **aResult);
|
||||
static nsresult GetFolderList(nsIRDFResource *source, PRBool allowHidden, PRBool onlyFirst, nsISimpleEnumerator **aResult);
|
||||
static nsresult GetName(nsIRDFResource *source, nsIRDFLiteral** aResult);
|
||||
|
@ -201,6 +197,8 @@ nsIRDFResource *FileSystemDataSource::kNC_FileSystemObject;
|
|||
nsIRDFResource *FileSystemDataSource::kNC_pulse;
|
||||
nsIRDFResource *FileSystemDataSource::kRDF_InstanceOf;
|
||||
nsIRDFResource *FileSystemDataSource::kRDF_type;
|
||||
nsIRDFLiteral *FileSystemDataSource::kLiteralTrue;
|
||||
nsIRDFLiteral *FileSystemDataSource::kLiteralFalse;
|
||||
|
||||
#ifdef USE_NC_EXTENSION
|
||||
nsIRDFResource *FileSystemDataSource::kNC_extension;
|
||||
|
@ -217,14 +215,6 @@ nsIRDFResource *FileSystemDataSource::kNC_NetPositiveObject;
|
|||
char *FileSystemDataSource::netPositiveDir;
|
||||
#endif
|
||||
|
||||
nsIRDFLiteral *FileSystemDataSource::kLiteralTrue;
|
||||
nsIRDFLiteral *FileSystemDataSource::kLiteralFalse;
|
||||
|
||||
|
||||
|
||||
|
||||
static const char kFileProtocol[] = "file://";
|
||||
|
||||
|
||||
|
||||
PRBool
|
||||
|
@ -245,6 +235,8 @@ FileSystemDataSource::isFileURI(nsIRDFResource *r)
|
|||
return(isFileURIFlag);
|
||||
}
|
||||
|
||||
|
||||
|
||||
PRBool
|
||||
FileSystemDataSource::isDirURI(nsIRDFResource* source)
|
||||
{
|
||||
|
@ -264,10 +256,25 @@ FileSystemDataSource::isDirURI(nsIRDFResource* source)
|
|||
rv = aDir->IsDirectory(&isDirFlag);
|
||||
if (NS_FAILED(rv)) return(PR_FALSE);
|
||||
|
||||
#ifdef XP_MAC
|
||||
// Hide directory structure of packages under Mac OS 9/X
|
||||
nsCOMPtr<nsILocalFileMac> aMacFile = do_QueryInterface(aDir);
|
||||
if (aMacFile)
|
||||
{
|
||||
PRBool isPackageFlag = PR_FALSE;
|
||||
rv = aMacFile->IsPackage(&isPackageFlag);
|
||||
if (NS_SUCCEEDED(rv) && (isPackageFlag == PR_TRUE))
|
||||
{
|
||||
isDirFlag = PR_FALSE;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
return(isDirFlag);
|
||||
}
|
||||
|
||||
|
||||
|
||||
FileSystemDataSource::FileSystemDataSource(void)
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
|
@ -284,38 +291,19 @@ FileSystemDataSource::FileSystemDataSource(void)
|
|||
nsSpecialSystemDirectory ieFavoritesFolder(nsSpecialSystemDirectory::Win_Favorites);
|
||||
nsFileURL ieFavoritesURLSpec(ieFavoritesFolder);
|
||||
const char *ieFavoritesURI = ieFavoritesURLSpec.GetAsString();
|
||||
|
||||
if (ieFavoritesURI)
|
||||
{
|
||||
ieFavoritesDir = nsCRT::strdup(ieFavoritesURI);
|
||||
}
|
||||
gRDFService->GetResource(NC_NAMESPACE_URI "IEFavorite", &kNC_IEFavoriteObject);
|
||||
gRDFService->GetResource(NC_NAMESPACE_URI "IEFavoriteFolder", &kNC_IEFavoriteFolder);
|
||||
/*
|
||||
nsCOMPtr<nsIPlatformCharset> platformCharset =
|
||||
do_GetService(kPlatformCharsetCID, &rv);
|
||||
if (NS_SUCCEEDED(rv) && (platformCharset))
|
||||
{
|
||||
nsAutoString defaultCharset;
|
||||
if (NS_SUCCEEDED(rv = platformCharset->GetCharset(kPlatformCharsetSel_4xBookmarkFile,
|
||||
defaultCharset)))
|
||||
{
|
||||
// found the default platform charset
|
||||
// now try and get a decoder from it to Unicode
|
||||
nsCOMPtr<nsICharsetConverterManager> charsetConv =
|
||||
do_GetService(kCharsetConverterManagerCID, &rv);
|
||||
if (NS_SUCCEEDED(rv) && (charsetConv))
|
||||
{
|
||||
rv = charsetConv->GetUnicodeDecoder(&defaultCharset,
|
||||
getter_AddRefs(mUnicodeDecoder));
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
#endif
|
||||
|
||||
#ifdef XP_BEOS
|
||||
nsSpecialSystemDirectory netPositiveFolder(nsSpecialSystemDirectory::BeOS_SettingsDirectory);
|
||||
nsFileURL netPositiveURLSpec(netPositiveFolder);
|
||||
|
||||
netPositiveURLSpec += "NetPositive/Bookmarks/";
|
||||
const char *netPositiveURI = netPositiveURLSpec.GetAsString();
|
||||
if (netPositiveURI)
|
||||
|
@ -605,7 +593,7 @@ FileSystemDataSource::GetTarget(nsIRDFResource *source,
|
|||
// Oh this is evil. Somebody kill me now.
|
||||
nsCOMPtr<nsISimpleEnumerator> children;
|
||||
rv = GetFolderList(source, PR_FALSE, PR_TRUE, getter_AddRefs(children));
|
||||
if (NS_FAILED(rv)) return(rv);
|
||||
if (NS_FAILED(rv) || (rv == NS_RDF_NO_VALUE)) return(rv);
|
||||
|
||||
PRBool hasMore;
|
||||
rv = children->HasMoreElements(&hasMore);
|
||||
|
@ -841,7 +829,8 @@ FileSystemDataSource::HasAssertion(nsIRDFResource *source,
|
|||
if (property == kRDF_type)
|
||||
{
|
||||
nsCOMPtr<nsIRDFResource> resource( do_QueryInterface(target) );
|
||||
if (resource.get() == kRDF_type) {
|
||||
if (resource.get() == kRDF_type)
|
||||
{
|
||||
*hasAssertion = PR_TRUE;
|
||||
}
|
||||
}
|
||||
|
@ -850,11 +839,15 @@ FileSystemDataSource::HasAssertion(nsIRDFResource *source,
|
|||
{
|
||||
// Cheat just a little here by making dirs always match
|
||||
if (isDirURI(source))
|
||||
{
|
||||
*hasAssertion = PR_TRUE;
|
||||
else {
|
||||
}
|
||||
else
|
||||
{
|
||||
nsCOMPtr<nsIRDFLiteral> extension;
|
||||
GetExtension(source, getter_AddRefs(extension));
|
||||
if (extension.get() == target) {
|
||||
if (extension.get() == target)
|
||||
{
|
||||
*hasAssertion = PR_TRUE;
|
||||
}
|
||||
}
|
||||
|
@ -866,8 +859,11 @@ FileSystemDataSource::HasAssertion(nsIRDFResource *source,
|
|||
PRBool isEqual = PR_FALSE;
|
||||
target->EqualsNode(kLiteralTrue, &isEqual);
|
||||
if (isEqual)
|
||||
{
|
||||
*hasAssertion = isDir;
|
||||
else {
|
||||
}
|
||||
else
|
||||
{
|
||||
target->EqualsNode(kLiteralFalse, &isEqual);
|
||||
if (isEqual)
|
||||
*hasAssertion = !isDir;
|
||||
|
@ -879,12 +875,15 @@ FileSystemDataSource::HasAssertion(nsIRDFResource *source,
|
|||
}
|
||||
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
FileSystemDataSource::HasArcIn(nsIRDFNode *aNode, nsIRDFResource *aArc, PRBool *result)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
FileSystemDataSource::HasArcOut(nsIRDFResource *aSource, nsIRDFResource *aArc, PRBool *result)
|
||||
{
|
||||
|
@ -920,6 +919,7 @@ FileSystemDataSource::HasArcOut(nsIRDFResource *aSource, nsIRDFResource *aArc, P
|
|||
}
|
||||
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
FileSystemDataSource::ArcLabelsIn(nsIRDFNode *node,
|
||||
nsISimpleEnumerator ** labels /* out */)
|
||||
|
@ -944,7 +944,8 @@ FileSystemDataSource::ArcLabelsOut(nsIRDFResource *source,
|
|||
|
||||
nsresult rv;
|
||||
|
||||
if (source == kNC_FileSystemRoot) {
|
||||
if (source == kNC_FileSystemRoot)
|
||||
{
|
||||
nsCOMPtr<nsISupportsArray> array;
|
||||
rv = NS_NewISupportsArray(getter_AddRefs(array));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
@ -960,12 +961,14 @@ FileSystemDataSource::ArcLabelsOut(nsIRDFResource *source,
|
|||
*labels = result;
|
||||
return NS_OK;
|
||||
}
|
||||
else if (isFileURI(source)) {
|
||||
else if (isFileURI(source))
|
||||
{
|
||||
nsCOMPtr<nsISupportsArray> array;
|
||||
rv = NS_NewISupportsArray(getter_AddRefs(array));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
if (isDirURI(source)) {
|
||||
if (isDirURI(source))
|
||||
{
|
||||
#ifdef XP_WIN
|
||||
if (isValidFolder(source) == PR_TRUE)
|
||||
{
|
||||
|
@ -1255,23 +1258,30 @@ nsresult
|
|||
FileSystemDataSource::GetFolderList(nsIRDFResource *source, PRBool allowHidden,
|
||||
PRBool onlyFirst, nsISimpleEnumerator** aResult)
|
||||
{
|
||||
if (!isDirURI(source))
|
||||
return(NS_RDF_NO_VALUE);
|
||||
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsISupportsArray> nameArray;
|
||||
|
||||
rv = NS_NewISupportsArray(getter_AddRefs(nameArray));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
if (NS_FAILED(rv))
|
||||
return(rv);
|
||||
|
||||
const char *parentURI = nsnull;
|
||||
rv = source->GetValueConst(&parentURI);
|
||||
if (NS_FAILED(rv)) return(rv);
|
||||
if (!parentURI) return(NS_ERROR_UNEXPECTED);
|
||||
if (NS_FAILED(rv))
|
||||
return(rv);
|
||||
if (!parentURI)
|
||||
return(NS_ERROR_UNEXPECTED);
|
||||
|
||||
nsCOMPtr<nsIURI> aIURI;
|
||||
if (NS_FAILED(rv = NS_NewURI(getter_AddRefs(aIURI), parentURI)))
|
||||
return(rv);
|
||||
|
||||
nsCOMPtr<nsIFileURL> fileURL = do_QueryInterface(aIURI);
|
||||
if (!fileURL) return(PR_FALSE);
|
||||
if (!fileURL)
|
||||
return(PR_FALSE);
|
||||
|
||||
nsCOMPtr<nsIFile> aDir;
|
||||
if (NS_FAILED(rv = fileURL->GetFile(getter_AddRefs(aDir))))
|
||||
|
@ -1280,14 +1290,13 @@ FileSystemDataSource::GetFolderList(nsIRDFResource *source, PRBool allowHidden,
|
|||
// ensure that we DO NOT resolve aliases
|
||||
nsCOMPtr<nsILocalFile> aDirLocal = do_QueryInterface(aDir);
|
||||
if (aDirLocal)
|
||||
{
|
||||
aDirLocal->SetFollowLinks(PR_FALSE);
|
||||
}
|
||||
|
||||
nsCOMPtr<nsISimpleEnumerator> dirContents;
|
||||
if (NS_FAILED(rv = aDir->GetDirectoryEntries(getter_AddRefs(dirContents))))
|
||||
return(rv);
|
||||
if (!dirContents) return(NS_ERROR_UNEXPECTED);
|
||||
if (!dirContents)
|
||||
return(NS_ERROR_UNEXPECTED);
|
||||
|
||||
PRBool hasMore;
|
||||
while(NS_SUCCEEDED(rv = dirContents->HasMoreElements(&hasMore)) &&
|
||||
|
@ -1298,14 +1307,16 @@ FileSystemDataSource::GetFolderList(nsIRDFResource *source, PRBool allowHidden,
|
|||
break;
|
||||
|
||||
nsCOMPtr<nsIFile> aFile = do_QueryInterface(isupports);
|
||||
if (!aFile) break;
|
||||
if (!aFile)
|
||||
break;
|
||||
|
||||
if (allowHidden == PR_FALSE)
|
||||
{
|
||||
PRBool hiddenFlag = PR_FALSE;
|
||||
if (NS_FAILED(rv = aFile->IsHidden(&hiddenFlag)))
|
||||
break;
|
||||
if (hiddenFlag == PR_TRUE) continue;
|
||||
if (hiddenFlag == PR_TRUE)
|
||||
continue;
|
||||
}
|
||||
|
||||
// XXX We should use nsIFile::GetUnicodeLeafName().
|
||||
|
@ -1316,7 +1327,8 @@ FileSystemDataSource::GetFolderList(nsIRDFResource *source, PRBool allowHidden,
|
|||
char *leafStr = nsnull;
|
||||
if (NS_FAILED(rv = aFile->GetLeafName(&leafStr)))
|
||||
break;
|
||||
if (!leafStr) continue;
|
||||
if (!leafStr)
|
||||
continue;
|
||||
|
||||
nsCAutoString fullURI;
|
||||
fullURI.Assign(parentURI);
|
||||
|
@ -1329,7 +1341,8 @@ FileSystemDataSource::GetFolderList(nsIRDFResource *source, PRBool allowHidden,
|
|||
Recycle(leafStr);
|
||||
leafStr = nsnull;
|
||||
|
||||
if (!escLeafStr) continue;
|
||||
if (!escLeafStr)
|
||||
continue;
|
||||
|
||||
nsCAutoString leaf(escLeafStr);
|
||||
Recycle(escLeafStr);
|
||||
|
@ -1350,9 +1363,7 @@ FileSystemDataSource::GetFolderList(nsIRDFResource *source, PRBool allowHidden,
|
|||
rv = aFile->IsDirectory(&dirFlag);
|
||||
if (NS_SUCCEEDED(rv) && (dirFlag == PR_TRUE))
|
||||
{
|
||||
// XXX hmmm, causes problems getting name,
|
||||
// so comment it out for the short term
|
||||
// fullURI.Append(PRUnichar('/'));
|
||||
fullURI.Append('/');
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIRDFResource> fileRes;
|
||||
|
@ -1360,7 +1371,8 @@ FileSystemDataSource::GetFolderList(nsIRDFResource *source, PRBool allowHidden,
|
|||
|
||||
nameArray->AppendElement(fileRes);
|
||||
|
||||
if (onlyFirst == PR_TRUE) break;
|
||||
if (onlyFirst == PR_TRUE)
|
||||
break;
|
||||
}
|
||||
|
||||
nsISimpleEnumerator* result = new nsArrayEnumerator(nameArray);
|
||||
|
@ -1385,26 +1397,27 @@ FileSystemDataSource::GetLastMod(nsIRDFResource *source, nsIRDFDate **aResult)
|
|||
|
||||
rv = source->GetValueConst(&uri);
|
||||
if (NS_FAILED(rv)) return(rv);
|
||||
if (!uri) return(NS_ERROR_UNEXPECTED);
|
||||
if (!uri)
|
||||
return(NS_ERROR_UNEXPECTED);
|
||||
|
||||
nsCOMPtr<nsIURI> aIURI;
|
||||
if (NS_FAILED(rv = NS_NewURI(getter_AddRefs(aIURI), uri)))
|
||||
return(rv);
|
||||
|
||||
nsCOMPtr<nsIFileURL> fileURL = do_QueryInterface(aIURI);
|
||||
if (!fileURL) return(PR_FALSE);
|
||||
if (!fileURL)
|
||||
return(PR_FALSE);
|
||||
|
||||
nsCOMPtr<nsIFile> aFile;
|
||||
if (NS_FAILED(rv = fileURL->GetFile(getter_AddRefs(aFile))))
|
||||
return(rv);
|
||||
if (!aFile) return(NS_ERROR_UNEXPECTED);
|
||||
if (!aFile)
|
||||
return(NS_ERROR_UNEXPECTED);
|
||||
|
||||
// ensure that we DO NOT resolve aliases
|
||||
nsCOMPtr<nsILocalFile> aFileLocal = do_QueryInterface(aFile);
|
||||
if (aFileLocal)
|
||||
{
|
||||
aFileLocal->SetFollowLinks(PR_FALSE);
|
||||
}
|
||||
|
||||
PRInt64 lastModDate;
|
||||
if (NS_FAILED(rv = aFile->GetLastModifiedTime(&lastModDate)))
|
||||
|
@ -1421,6 +1434,7 @@ FileSystemDataSource::GetLastMod(nsIRDFResource *source, nsIRDFDate **aResult)
|
|||
}
|
||||
|
||||
|
||||
|
||||
nsresult
|
||||
FileSystemDataSource::GetFileSize(nsIRDFResource *source, nsIRDFInt **aResult)
|
||||
{
|
||||
|
@ -1430,27 +1444,29 @@ FileSystemDataSource::GetFileSize(nsIRDFResource *source, nsIRDFInt **aResult)
|
|||
const char *uri = nsnull;
|
||||
|
||||
rv = source->GetValueConst(&uri);
|
||||
if (NS_FAILED(rv)) return(rv);
|
||||
if (!uri) return(NS_ERROR_UNEXPECTED);
|
||||
if (NS_FAILED(rv))
|
||||
return(rv);
|
||||
if (!uri)
|
||||
return(NS_ERROR_UNEXPECTED);
|
||||
|
||||
nsCOMPtr<nsIURI> aIURI;
|
||||
if (NS_FAILED(rv = NS_NewURI(getter_AddRefs(aIURI), uri)))
|
||||
return(rv);
|
||||
|
||||
nsCOMPtr<nsIFileURL> fileURL = do_QueryInterface(aIURI);
|
||||
if (!fileURL) return(PR_FALSE);
|
||||
if (!fileURL)
|
||||
return(PR_FALSE);
|
||||
|
||||
nsCOMPtr<nsIFile> aFile;
|
||||
if (NS_FAILED(rv = fileURL->GetFile(getter_AddRefs(aFile))))
|
||||
return(rv);
|
||||
if (!aFile) return(NS_ERROR_UNEXPECTED);
|
||||
if (!aFile)
|
||||
return(NS_ERROR_UNEXPECTED);
|
||||
|
||||
// ensure that we DO NOT resolve aliases
|
||||
nsCOMPtr<nsILocalFile> aFileLocal = do_QueryInterface(aFile);
|
||||
if (aFileLocal)
|
||||
{
|
||||
aFileLocal->SetFollowLinks(PR_FALSE);
|
||||
}
|
||||
|
||||
// don't do anything with directories
|
||||
PRBool isDir = PR_FALSE;
|
||||
|
@ -1463,7 +1479,8 @@ FileSystemDataSource::GetFileSize(nsIRDFResource *source, nsIRDFInt **aResult)
|
|||
#ifdef XP_MAC
|
||||
// on Mac, get total file size (data + resource fork)
|
||||
nsCOMPtr<nsILocalFileMac> aMacFile = do_QueryInterface(aFile);
|
||||
if (!aMacFile) return(NS_ERROR_UNEXPECTED);
|
||||
if (!aMacFile)
|
||||
return(NS_ERROR_UNEXPECTED);
|
||||
if (NS_FAILED(rv = aMacFile->GetFileSizeWithResFork(&aFileSize64)))
|
||||
return(rv);
|
||||
#else
|
||||
|
@ -1489,39 +1506,59 @@ FileSystemDataSource::GetName(nsIRDFResource *source, nsIRDFLiteral **aResult)
|
|||
const char *uri = nsnull;
|
||||
|
||||
rv = source->GetValueConst(&uri);
|
||||
if (NS_FAILED(rv)) return(rv);
|
||||
if (!uri) return(NS_ERROR_UNEXPECTED);
|
||||
if (NS_FAILED(rv))
|
||||
return(rv);
|
||||
if (!uri)
|
||||
return(NS_ERROR_UNEXPECTED);
|
||||
|
||||
nsCOMPtr<nsIURI> aIURI;
|
||||
if (NS_FAILED(rv = NS_NewURI(getter_AddRefs(aIURI), uri)))
|
||||
return(rv);
|
||||
|
||||
nsCOMPtr<nsIFileURL> fileURL = do_QueryInterface(aIURI);
|
||||
if (!fileURL) return(PR_FALSE);
|
||||
if (!fileURL)
|
||||
return(PR_FALSE);
|
||||
|
||||
nsCOMPtr<nsIFile> aFile;
|
||||
if (NS_FAILED(rv = fileURL->GetFile(getter_AddRefs(aFile))))
|
||||
return(rv);
|
||||
if (!aFile) return(NS_ERROR_UNEXPECTED);
|
||||
if (!aFile)
|
||||
return(NS_ERROR_UNEXPECTED);
|
||||
|
||||
// ensure that we DO NOT resolve aliases
|
||||
nsCOMPtr<nsILocalFile> aFileLocal = do_QueryInterface(aFile);
|
||||
if (aFileLocal)
|
||||
{
|
||||
aFileLocal->SetFollowLinks(PR_FALSE);
|
||||
}
|
||||
|
||||
PRUnichar *nameUni = nsnull;
|
||||
if (NS_FAILED(rv = aFile->GetUnicodeLeafName(&nameUni)))
|
||||
return(rv);
|
||||
if (!nameUni) return(NS_ERROR_UNEXPECTED);
|
||||
if (!nameUni)
|
||||
return(NS_ERROR_UNEXPECTED);
|
||||
|
||||
nsAutoString name(nameUni);
|
||||
Recycle(nameUni);
|
||||
nameUni = nsnull;
|
||||
|
||||
#ifdef XP_WIN
|
||||
#ifdef XP_MAC
|
||||
nsCOMPtr<nsILocalFileMac> aMacFile = do_QueryInterface(aFile);
|
||||
if (aMacFile)
|
||||
{
|
||||
PRBool isPackageFlag = PR_FALSE;
|
||||
rv = aMacFile->IsPackage(&isPackageFlag);
|
||||
if (NS_SUCCEEDED(rv) && (isPackageFlag == PR_TRUE))
|
||||
{
|
||||
// mungle package names under Mac OS 9/X
|
||||
PRUint32 len = name.Length();
|
||||
if (name.RFind(".app", PR_TRUE) == len - 4)
|
||||
{
|
||||
name.SetLength(len-4);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef XP_WIN
|
||||
// special hack for IE favorites under Windows; strip off the
|
||||
// trailing ".url" or ".lnk" at the end of IE favorites names
|
||||
PRInt32 nameLen = name.Length();
|
||||
|
@ -1582,23 +1619,30 @@ FileSystemDataSource::GetName(nsIRDFResource *source, nsIRDFLiteral **aResult)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
#ifdef USE_NC_EXTENSION
|
||||
nsresult
|
||||
FileSystemDataSource::GetExtension(nsIRDFResource *source, nsIRDFLiteral **aResult)
|
||||
{
|
||||
nsCOMPtr<nsIRDFLiteral> name;
|
||||
nsresult rv = GetName(source, getter_AddRefs(name));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
const PRUnichar* unicodeLeafName;
|
||||
rv = name->GetValueConst(&unicodeLeafName);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
nsAutoString filename(unicodeLeafName);
|
||||
PRInt32 lastDot = filename.RFindChar('.');
|
||||
if (lastDot == -1) {
|
||||
if (lastDot == -1)
|
||||
{
|
||||
gRDFService->GetLiteral(NS_LITERAL_STRING("").get(), aResult);
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
nsAutoString extension;
|
||||
filename.Right(extension, (filename.Length() - lastDot));
|
||||
gRDFService->GetLiteral(extension.get(), aResult);
|
||||
|
@ -1608,6 +1652,8 @@ FileSystemDataSource::GetExtension(nsIRDFResource *source, nsIRDFLiteral **aResu
|
|||
}
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#ifdef XP_WIN
|
||||
nsresult
|
||||
FileSystemDataSource::getIEFavoriteURL(nsIRDFResource *source, nsString aFileURL, nsIRDFLiteral **urlLiteral)
|
||||
|
@ -1627,6 +1673,7 @@ FileSystemDataSource::getIEFavoriteURL(nsIRDFResource *source, nsString aFileURL
|
|||
else if (aFileURL.Length() > 4)
|
||||
{
|
||||
nsAutoString extension;
|
||||
|
||||
aFileURL.Right(extension, 4);
|
||||
if (!extension.EqualsIgnoreCase(".url"))
|
||||
{
|
||||
|
@ -1685,8 +1732,11 @@ FileSystemDataSource::GetURL(nsIRDFResource *source, PRBool *isFavorite, nsIRDFL
|
|||
|
||||
nsresult rv;
|
||||
const char *uri;
|
||||
|
||||
rv = source->GetValueConst(&uri);
|
||||
if (NS_FAILED(rv)) return(rv);
|
||||
if (NS_FAILED(rv))
|
||||
return(rv);
|
||||
|
||||
nsAutoString url;
|
||||
url.AssignWithConversion(uri);
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче