From cee7486dc6debae73c6abe4494012b9285253fda Mon Sep 17 00:00:00 2001 From: "valeski%netscape.com" Date: Wed, 23 Sep 1998 23:29:25 +0000 Subject: [PATCH] NGLayout only. Setting the default dirs for NS_NET_FILE to be rooted in the current working directory rather than hardcoded. git-svn-id: svn://10.0.0.236/trunk@10855 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/network/module/nsINetFile.h | 13 ++++------- mozilla/network/module/nsNetFile.cpp | 4 ++++ mozilla/network/module/nsNetStubs.cpp | 32 +++++++++++++++++++++++++++ 3 files changed, 40 insertions(+), 9 deletions(-) diff --git a/mozilla/network/module/nsINetFile.h b/mozilla/network/module/nsINetFile.h index af912f233c0..6da585af590 100644 --- a/mozilla/network/module/nsINetFile.h +++ b/mozilla/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/mozilla/network/module/nsNetFile.cpp b/mozilla/network/module/nsNetFile.cpp index c5678dfdeb7..25cb425454c 100644 --- a/mozilla/network/module/nsNetFile.cpp +++ b/mozilla/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/mozilla/network/module/nsNetStubs.cpp b/mozilla/network/module/nsNetStubs.cpp index 0b154a1209d..ce65e3c6a14 100644 --- a/mozilla/network/module/nsNetStubs.cpp +++ b/mozilla/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) {