diff --git a/network/cache/nu/macbuild/nuCache.mcp b/network/cache/nu/macbuild/nuCache.mcp index 2ebc76773096..930f6674e2e4 100644 Binary files a/network/cache/nu/macbuild/nuCache.mcp and b/network/cache/nu/macbuild/nuCache.mcp differ diff --git a/network/cache/nu/src/nsCacheObject.cpp b/network/cache/nu/src/nsCacheObject.cpp index 11969d2e6f46..b3e7d50c3be0 100644 --- a/network/cache/nu/src/nsCacheObject.cpp +++ b/network/cache/nu/src/nsCacheObject.cpp @@ -15,7 +15,13 @@ * Copyright (C) 1998 Netscape Communications Corporation. All Rights * Reserved. */ -#include + +#ifndef XP_MAC +#include "memory.h" +#else +#include "cstring" +#endif + #include "prmem.h" #include "prprf.h" #include "plstr.h" diff --git a/network/cache/nu/src/nsCachePref.cpp b/network/cache/nu/src/nsCachePref.cpp index ffc0b7d7c820..1db6d9b4e354 100644 --- a/network/cache/nu/src/nsCachePref.cpp +++ b/network/cache/nu/src/nsCachePref.cpp @@ -25,6 +25,11 @@ #include "nsCacheManager.h" #include "plstr.h" +#ifdef XP_MAC +#include "uprefd.h" +#endif + + static const PRUint32 MEM_CACHE_SIZE_DEFAULT = 1024*1024; static const PRUint32 DISK_CACHE_SIZE_DEFAULT = 5*MEM_CACHE_SIZE_DEFAULT; static const PRUint32 BKG_THREAD_SLEEP = 60;//TODO- Testing 15*60; /*in seconds, 15 minutes */ @@ -105,7 +110,36 @@ nsCachePref::SetupPrefs(const char* i_Pref) if (bSetupAll || !PL_strcmp(i_Pref,CACHE_DIR_PREF)) { - if (PREF_OK == PREF_CopyCharPref(CACHE_DIR_PREF,&tempPref)) +#ifdef XP_MAC + tempPref = CPrefs::GetCachePath(); + if (tempPref) + { + if (m_DiskCacheFolder) + delete m_DiskCacheFolder; + m_DiskCacheFolder = new char[PL_strlen(tempPref)+2]; + + if (!m_DiskCacheFolder) + { + if (tempPref) + PR_Free(tempPref); + return; + } + /* Changing the mac path to unix because nspr converts + it the other way round and cant deal with it being a mac path */ + m_DiskCacheFolder[0]='/'; + m_DiskCacheFolder[1]='\0'; + PL_strcat(m_DiskCacheFolder, tempPref); + char *tempPref2 = m_DiskCacheFolder+1; + while (*tempPref2) + { + if (*tempPref2 == ':') + *tempPref2 = '/'; + tempPref2++; + } + + } +#else + if (PREF_OK == PREF_CopyCharPref(CACHE_DIR_PREF,&tempPref)) { PR_ASSERT(tempPref); if (m_DiskCacheFolder) @@ -119,6 +153,7 @@ nsCachePref::SetupPrefs(const char* i_Pref) } PL_strcpy(m_DiskCacheFolder, tempPref); } +#endif else //TODO set to temp folder { m_DiskCacheFolder = new char [1]; @@ -172,3 +207,4 @@ nsresult nsCachePref::QueryInterface(const nsIID& aIID, } */ + diff --git a/network/cache/nu/src/nsDiskModule.cpp b/network/cache/nu/src/nsDiskModule.cpp index 6359fb3d0b2f..aa246b564c2f 100644 --- a/network/cache/nu/src/nsDiskModule.cpp +++ b/network/cache/nu/src/nsDiskModule.cpp @@ -147,7 +147,8 @@ PRBool nsDiskModule::AddObject(nsCacheObject* io_pObject) //Close the corresponding file PR_ASSERT(io_pObject->Stream()); - PR_Close(((nsFileStream*)io_pObject->Stream())->FileDesc()); + if (io_pObject->Stream()) + PR_Close(((nsFileStream*)io_pObject->Stream())->FileDesc()); key->data = (void*)io_pObject->Address(); /* Later on change this to include post data- io_pObject->KeyData() */ @@ -514,8 +515,10 @@ char* FullFilename(const char* i_Filename) PL_strcpy(g_FullFilename, nsCachePref::GetInstance()->DiskCacheFolder()); if (0==cacheFolderLength) cacheFolderLength = PL_strlen(nsCachePref::GetInstance()->DiskCacheFolder()); +#ifndef XP_MAC g_FullFilename[cacheFolderLength] = PR_GetDirectorySepartor(); //spelling check later as nspr fixes it. g_FullFilename[cacheFolderLength+1] = '\0'; +#endif PL_strcat(g_FullFilename, i_Filename); return g_FullFilename; } diff --git a/network/cache/nu/src/nsFileStream.cpp b/network/cache/nu/src/nsFileStream.cpp index bb5e7dffba66..8ed4edf07df6 100644 --- a/network/cache/nu/src/nsFileStream.cpp +++ b/network/cache/nu/src/nsFileStream.cpp @@ -65,6 +65,7 @@ PRInt32 nsFileStream::Read(void* o_Buffer, PRUint32 i_Len) void nsFileStream::Reset() { + return; if (m_pFile) PR_Close(m_pFile); } diff --git a/network/cache/nu/src/nsMemStream.cpp b/network/cache/nu/src/nsMemStream.cpp index 39e73902586d..195361d582fc 100644 --- a/network/cache/nu/src/nsMemStream.cpp +++ b/network/cache/nu/src/nsMemStream.cpp @@ -20,7 +20,12 @@ #include "nsMemStream.h" #include "prmem.h" #include "prlog.h" /* Assert */ + +#ifndef XP_MAC #include "memory.h" +#else +#include "cstring" +#endif static const PRUint32 kPageSize = 1024;//4096; nsMemStream::nsMemStream():m_AllocSize(0),m_Size(0),m_pStart(0),m_ReadOffset(0),m_WriteOffset(0)