fixes a mailnews regression. We need to be able to create a unique directory. sr=dveditz, a=dveditz, bug 299133

This commit is contained in:
dougt%meer.net 2005-06-29 22:23:55 +00:00
Родитель fcf4dc8c22
Коммит dc3430b702
4 изменённых файлов: 27 добавлений и 8 удалений

Просмотреть файл

@ -896,17 +896,16 @@ nsFileSpec::nsFileSpec(const nsFileURL& inURL)
}
//----------------------------------------------------------------------------------------
void nsFileSpec::MakeUnique(const char* inSuggestedLeafName)
void nsFileSpec::MakeUnique(const char* inSuggestedLeafName, PRBool inCreateFile)
//----------------------------------------------------------------------------------------
{
if (inSuggestedLeafName && *inSuggestedLeafName)
SetLeafName(inSuggestedLeafName);
MakeUnique();
MakeUnique(inCreateFile);
} // nsFileSpec::MakeUnique
//----------------------------------------------------------------------------------------
void nsFileSpec::MakeUnique()
void nsFileSpec::MakeUnique(PRBool inCreateFile)
//----------------------------------------------------------------------------------------
{
// XXX: updated path starts empty. In case of error this will cause
@ -917,7 +916,8 @@ void nsFileSpec::MakeUnique()
NS_NewNativeLocalFile(nsDependentCString(*this), PR_TRUE, getter_AddRefs(localFile));
if (localFile)
{
nsresult rv = localFile->CreateUnique(nsIFile::NORMAL_FILE_TYPE, 0600);
nsresult rv = localFile->CreateUnique(inCreateFile ? nsIFile::NORMAL_FILE_TYPE :
nsIFile::DIRECTORY_TYPE, 0600);
if (NS_SUCCEEDED(rv))
localFile->GetNativePath(path);
}

Просмотреть файл

@ -474,8 +474,8 @@ class NS_COM_OBSOLETE nsFileSpec
//--------------------------------------------------
// For security reasons, these create the file.
void MakeUnique();
void MakeUnique(const char* inSuggestedLeafName);
void MakeUnique(PRBool inCreateFile = PR_TRUE);
void MakeUnique(const char* inSuggestedLeafName, PRBool inCreateFile = PR_TRUE);
// Called for the spec of an alias. Modifies the spec to
// point to the original. Sets mError.

Просмотреть файл

@ -314,6 +314,22 @@ NS_IMETHODIMP nsFileSpecImpl::MakeUniqueWithSuggestedName(const char *suggestedN
return mFileSpec.Error();
}
//----------------------------------------------------------------------------------------
NS_IMETHODIMP nsFileSpecImpl::MakeUniqueDir()
//----------------------------------------------------------------------------------------
{
mFileSpec.MakeUnique(PR_FALSE);
return mFileSpec.Error();
}
//----------------------------------------------------------------------------------------
NS_IMETHODIMP nsFileSpecImpl::MakeUniqueDirWithSuggestedName(const char *suggestedName)
//----------------------------------------------------------------------------------------
{
mFileSpec.MakeUnique(suggestedName, PR_FALSE);
return mFileSpec.Error();
}
//----------------------------------------------------------------------------------------
NS_IMETHODIMP nsFileSpecImpl::GetModDate(PRUint32 *aModDate)
//----------------------------------------------------------------------------------------

Просмотреть файл

@ -75,7 +75,7 @@ interface nsIInputStream;
[ref] native nsFileSpecRef(nsFileSpec);
[ptr] native nsFileSpecPtr(nsFileSpec);
[scriptable, uuid(d8c0a080-0868-11d3-915f-d9d889d48e3c)]
[scriptable, uuid(37ef2e71-edef-46c7-acd9-f0b6e0b15083)]
interface nsIFileSpec : nsISupports
{
void fromFileSpec([const] in nsIFileSpec original);
@ -106,6 +106,9 @@ interface nsIFileSpec : nsISupports
void makeUnique();
void makeUniqueWithSuggestedName(in string suggestedName);
void makeUniqueDir();
void makeUniqueDirWithSuggestedName(in string suggestedName);
readonly attribute unsigned long modDate;
boolean modDateChanged(in unsigned long oldStamp);