[not part of build] create the cache directory if it doesn't exist already.

This commit is contained in:
beard%netscape.com 2001-03-06 02:10:18 +00:00
Родитель a413a0dc6e
Коммит 86cd82e240
1 изменённых файлов: 12 добавлений и 0 удалений

12
netwerk/cache/src/nsDiskCacheDevice.cpp поставляемый
Просмотреть файл

@ -86,6 +86,7 @@ static nsresult installPrefListeners(nsDiskCacheDevice* device)
rv = cacheDirectory->Append("Cache");
if (NS_FAILED(rv))
return rv;
rv = prefs->SetFileXPref(CACHE_DIR_PREF, cacheDirectory);
if (NS_FAILED(rv))
return rv;
@ -93,6 +94,11 @@ static nsresult installPrefListeners(nsDiskCacheDevice* device)
return rv;
#endif
} else {
// be a good citizen in the current Cache directory.
rv = cacheDirectory->Append("NewCache");
if (NS_FAILED(rv))
return rv;
// cause the preference to be set up initially.
device->setCacheDirectory(cacheDirectory);
}
@ -344,6 +350,12 @@ nsDiskCacheDevice::OnDataSizeChange(nsCacheEntry * entry, PRInt32 deltaSize)
void nsDiskCacheDevice::setCacheDirectory(nsILocalFile* cacheDirectory)
{
mCacheDirectory = cacheDirectory;
// make sure the Cache directory exists.
PRBool exists;
nsresult rv = cacheDirectory->Exists(&exists);
if (NS_SUCCEEDED(rv) && !exists)
cacheDirectory->Create(nsIFile::DIRECTORY_TYPE, 0777);
}
nsresult nsDiskCacheDevice::getFileForKey(const char* key, PRBool meta, nsIFile ** result)