Bug 122892: nsLocalFile::Clone should preserve stat info.

make nsLocalFile* impls use copy constructors for their nsIFile::Clone methods.
This avoids unnecessary |stat| calls inherent in using NS_NewNativeLocalFile.

b=122892, r=dougt, sr=darin, with many thanks to biesi & mkaply for testing on other
plats.
This commit is contained in:
dwitte@stanford.edu
2003-07-18 22:14:16 +00:00
parent 79cb2abcc7
commit 9c4ca41ac2
8 changed files with 51 additions and 45 deletions

View File

@@ -201,6 +201,13 @@ nsLocalFile::nsLocalFile() :
{
}
nsLocalFile::nsLocalFile(const nsLocalFile& other)
: mCachedStat(other.mCachedStat)
, mPath(other.mPath)
, mHaveCachedStat(other.mHaveCachedStat)
{
}
nsLocalFile::~nsLocalFile()
{
}
@@ -240,18 +247,13 @@ nsLocalFile::FillStatCache() {
NS_IMETHODIMP
nsLocalFile::Clone(nsIFile **file)
{
NS_ENSURE_ARG(file);
// Just copy-construct ourselves
*file = new nsLocalFile(*this);
if (!*file)
return NS_ERROR_OUT_OF_MEMORY;
nsLocalFile* localFile = new nsLocalFile();
if (!localFile)
return NS_ERROR_OUT_OF_MEMORY;
nsresult rv = localFile->InitWithNativePath(mPath);
if (NS_FAILED(rv))
return rv;
*file = NS_STATIC_CAST(nsIFile *, localFile);
NS_ADDREF(*file);
return NS_OK;
}