put cache in ~/Library/Caches/Camino and delete the one in the profile dir

at startup
This commit is contained in:
pinkerton%aol.net 2005-05-06 03:46:06 +00:00
Родитель b87b21e11c
Коммит 77b42d1ab0
4 изменённых файлов: 37 добавлений и 10 удалений

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

@ -93,6 +93,10 @@ AppDirServiceProvider::GetFile(const char *prop, PRBool *persistant, nsIFile **_
{
rv = GetProductDirectory(getter_AddRefs(localFile));
}
else if (strcmp(prop, NS_APP_CACHE_PARENT_DIR) == 0)
{
rv = GetCacheDirectory(getter_AddRefs(localFile));
}
if (localFile && NS_SUCCEEDED(rv))
return localFile->QueryInterface(NS_GET_IID(nsIFile), (void**)_retval);
@ -105,15 +109,27 @@ AppDirServiceProvider::GetFile(const char *prop, PRBool *persistant, nsIFile **_
//*****************************************************************************
NS_METHOD
AppDirServiceProvider::GetProductDirectory(nsILocalFile **aLocalFile)
AppDirServiceProvider::GetProductDirectory(nsILocalFile **outLocalFile)
{
NS_ENSURE_ARG_POINTER(aLocalFile);
*aLocalFile = nsnull;
return EnsureFolder(kApplicationSupportFolderType, outLocalFile);
}
nsresult
AppDirServiceProvider::GetCacheDirectory(nsILocalFile** outCacheFolder)
{
return EnsureFolder(kCachedDataFolderType, outCacheFolder);
}
nsresult
AppDirServiceProvider::EnsureFolder(OSType inFolderType, nsILocalFile** outFolder)
{
NS_ENSURE_ARG_POINTER(outFolder);
*outFolder = nsnull;
nsresult rv;
FSRef foundRef;
OSErr err = ::FSFindFolder(kUserDomain, kApplicationSupportFolderType, kCreateFolder, &foundRef);
OSErr err = ::FSFindFolder(kUserDomain, inFolderType, kCreateFolder, &foundRef);
if (err != noErr)
return NS_ERROR_FAILURE;
nsCOMPtr<nsILocalFileMac> localDir(do_CreateInstance(NS_LOCAL_FILE_CONTRACTID));
@ -133,9 +149,8 @@ AppDirServiceProvider::GetProductDirectory(nsILocalFile **aLocalFile)
if (NS_FAILED(rv))
return rv;
*aLocalFile = localDir;
NS_ADDREF(*aLocalFile);
*outFolder = localDir;
NS_ADDREF(*outFolder);
return rv;
}
}

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

@ -43,6 +43,8 @@
#include "nsILocalFile.h"
#include "nsString.h"
#include <Carbon/Carbon.h>
class nsIFile;
//*****************************************************************************
@ -61,8 +63,9 @@ protected:
virtual ~AppDirServiceProvider();
NS_METHOD GetProductDirectory(nsILocalFile **aLocalFile);
NS_METHOD GetDefaultUserProfileRoot(nsILocalFile **aLocalFile);
nsresult GetCacheDirectory(nsILocalFile** outCacheFolder);
nsresult EnsureFolder(OSType inFolderType, nsILocalFile** outFolder);
nsCString mProductDirName;
};

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

@ -249,6 +249,12 @@ const int kReuseWindowOnAE = 2;
// order, we need to set a user default to return to the old behavior.
[[NSUserDefaults standardUserDefaults] setBool:NO forKey:@"NSViewSetAncestorsWindowFirst"];
// previous versions would keep the cache in the profile folder. If we find it there, remove it so
// that backup apps can more easily back up our profile. This will mean if anyone goes back to
// 0.8.x, they'll lose their favicons and cache, but that's ok.
NSString* cacheDir = [[pm newProfilePath] stringByAppendingPathComponent:@"Cache"];
[[NSFileManager defaultManager] removeFileAtPath:cacheDir handler:nil];
// register for window layering changes, so that we can update the bookmarks menu
NSNotificationCenter* notificationCenter = [NSNotificationCenter defaultCenter];
[notificationCenter addObserver:self selector:@selector(windowLayeringDidChange:) name:NSWindowDidBecomeKeyNotification object:nil];

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

@ -74,4 +74,7 @@ class nsIPref;
- (void)setPref:(const char*)prefName toInt:(int)value;
- (void)setPref:(const char*)prefName toBoolean:(BOOL)value;
// the path to the user profile's root folder, used by camino 0.8+
- (NSString*) newProfilePath;
@end