diff --git a/network/module/nsINetFile.h b/network/module/nsINetFile.h index af912f233c07..6da585af5906 100644 --- a/network/module/nsINetFile.h +++ b/network/module/nsINetFile.h @@ -23,23 +23,18 @@ // These defines are for temporary use until we get a real dir manager. #define USER_DIR_TOK "%USER%" -#define USER_DIR "e:\\projects\\ng" #define CACHE_DIR_TOK "%CACHE_D%" -#define CACHE_DIR "e:\\projects\\ng\\cache" +#define DEF_DIR_TOK "%DEF_D%" + #define COOKIE_FILE_TOK "%COOKIE_F%" - -#define CACHE_DB_F_TOK "%CACHE_DB_F%" -#define CACHE_DB_FILE "fat.db" - #ifdef XP_PC #define COOKIE_FILE "cookies.txt" #else #define COOKIE_FILE "cookies" #endif -#define DEF_DIR_TOK "%DEF_D%" -#define DEF_DIR "e:\\projects\\ng" - +#define CACHE_DB_F_TOK "%CACHE_DB_F%" +#define CACHE_DB_FILE "fat.db" // {9E04ADC2-2B1D-11d2-B6EB-00805F8A2676} #define NS_INETFILE_IID \ diff --git a/network/module/nsNetFile.cpp b/network/module/nsNetFile.cpp index c5678dfdeb78..25cb425454c9 100644 --- a/network/module/nsNetFile.cpp +++ b/network/module/nsNetFile.cpp @@ -6,6 +6,10 @@ #include "direct.h" #include +char USER_DIR[_MAX_PATH]; +char CACHE_DIR[_MAX_PATH]; +char DEF_DIR[_MAX_PATH]; + static NS_DEFINE_IID(kINetFileIID, NS_INETFILE_IID); NS_IMPL_ISUPPORTS(nsNetFile, kINetFileIID); diff --git a/network/module/nsNetStubs.cpp b/network/module/nsNetStubs.cpp index 0b154a1209d0..ce65e3c6a145 100644 --- a/network/module/nsNetStubs.cpp +++ b/network/module/nsNetStubs.cpp @@ -31,9 +31,14 @@ #ifdef NS_NET_FILE +extern char *USER_DIR; +extern char *CACHE_DIR; +extern char *DEF_DIR; + // For xp to ns file translation #include "nsINetFile.h" #include "nsVoidArray.h" +#include "direct.h" // The nsINetfile static nsINetFile *fileMgr = nsnull; @@ -1000,6 +1005,33 @@ NET_I_XP_FileSeek(XP_File fp, long offset, int origin) { // Directories and files are platform specific. PUBLIC PRBool NET_InitFilesAndDirs(void) { + PRFileInfo dir; + PRStatus status; + char tmpBuf[_MAX_PATH]; +#ifdef XP_PC + char *mDirDel = "\\"; +#elif XP_MAC + char *mDirDel = ":"; +#else + char *mDirDel = "/"; +#endif + + // Setup directories, step 1. + USER_DIR = _getcwd(USER_DIR, _MAX_PATH); + CACHE_DIR = _getcwd(CACHE_DIR, _MAX_PATH); + DEF_DIR = _getcwd(DEF_DIR, _MAX_PATH); + + // setup the cache dir. + PL_strcpy(tmpBuf, CACHE_DIR); + sprintf(CACHE_DIR,"%s%s%s%s", tmpBuf, mDirDel, "cache", mDirDel); + status = PR_GetFileInfo(CACHE_DIR, &dir); + if (status == PR_FAILURE) { + // Create the dir. + status = PR_MkDir(CACHE_DIR, 0600); + if (status != PR_SUCCESS) { + ; // bummer! + } + } if (!fileMgr) { if (NS_NewINetFile(&fileMgr, nsnull) != NS_OK) {