From 10c079470d9461d63f94278bba9e591b27c41057 Mon Sep 17 00:00:00 2001 From: "dougt%netscape.com" Date: Thu, 15 Apr 1999 19:39:23 +0000 Subject: [PATCH] Now using PL_* functions in nsprPath() ifdef'ing the deallocation of nsprPath() --- base/public/nsFileSpec.h | 7 +++++-- base/src/nsFileSpec.cpp | 8 +++++--- xpcom/io/nsFileSpec.cpp | 8 +++++--- xpcom/io/nsFileSpec.h | 7 +++++-- 4 files changed, 20 insertions(+), 10 deletions(-) diff --git a/base/public/nsFileSpec.h b/base/public/nsFileSpec.h index 8a28930cd21..5478c560fb5 100644 --- a/base/public/nsFileSpec.h +++ b/base/public/nsFileSpec.h @@ -282,10 +282,11 @@ class NS_BASE nsFileSpec { public: nsFileSpec(); - + + // These two meathods take *native* file paths. NS_EXPLICIT nsFileSpec(const char* inString, PRBool inCreateDirs = PR_FALSE); NS_EXPLICIT nsFileSpec(const nsString& inString, PRBool inCreateDirs = PR_FALSE); - // These above two meathods take *native* file paths. + NS_EXPLICIT nsFileSpec(const nsFilePath& inPath); NS_EXPLICIT nsFileSpec(const nsFileURL& inURL); @@ -293,12 +294,14 @@ class NS_BASE nsFileSpec nsFileSpec(const nsFileSpec& inPath); virtual ~nsFileSpec(); + // These two operands take *native* file paths. void operator = (const char* inPath); void operator = (const nsString& inPath) { const nsAutoCString path(inPath); *this = path; } + void operator = (const nsFilePath& inPath); void operator = (const nsFileURL& inURL); void operator = (const nsFileSpec& inOther); diff --git a/base/src/nsFileSpec.cpp b/base/src/nsFileSpec.cpp index cef764bd443..fb20d6b068d 100644 --- a/base/src/nsFileSpec.cpp +++ b/base/src/nsFileSpec.cpp @@ -1159,7 +1159,7 @@ nsprPath::operator const char*() if (modifiedNSPRPath != nsnull) delete [] modifiedNSPRPath; - modifiedNSPRPath = strdup( mFilePath ); + modifiedNSPRPath = PL_strdup( mFilePath ); char* resultPath = modifiedNSPRPath; /* strip the leading seperator */ @@ -1171,8 +1171,8 @@ nsprPath::operator const char*() resultPath[1] = ':'; /* Remove the ending seperator */ - if(resultPath[strlen(resultPath) - 1 ] == '/') - resultPath[strlen(resultPath) - 1 ] = '\0'; + if(resultPath[PL_strlen(resultPath) - 1 ] == '/') + resultPath[PL_strlen(resultPath) - 1 ] = '\0'; return resultPath; @@ -1185,6 +1185,8 @@ nsprPath::operator const char*() nsprPath::~nsprPath() //---------------------------------------------------------------------------------------- { +#ifdef XP_PC if (modifiedNSPRPath != nsnull) delete [] modifiedNSPRPath; +#endif } diff --git a/xpcom/io/nsFileSpec.cpp b/xpcom/io/nsFileSpec.cpp index cef764bd443..fb20d6b068d 100644 --- a/xpcom/io/nsFileSpec.cpp +++ b/xpcom/io/nsFileSpec.cpp @@ -1159,7 +1159,7 @@ nsprPath::operator const char*() if (modifiedNSPRPath != nsnull) delete [] modifiedNSPRPath; - modifiedNSPRPath = strdup( mFilePath ); + modifiedNSPRPath = PL_strdup( mFilePath ); char* resultPath = modifiedNSPRPath; /* strip the leading seperator */ @@ -1171,8 +1171,8 @@ nsprPath::operator const char*() resultPath[1] = ':'; /* Remove the ending seperator */ - if(resultPath[strlen(resultPath) - 1 ] == '/') - resultPath[strlen(resultPath) - 1 ] = '\0'; + if(resultPath[PL_strlen(resultPath) - 1 ] == '/') + resultPath[PL_strlen(resultPath) - 1 ] = '\0'; return resultPath; @@ -1185,6 +1185,8 @@ nsprPath::operator const char*() nsprPath::~nsprPath() //---------------------------------------------------------------------------------------- { +#ifdef XP_PC if (modifiedNSPRPath != nsnull) delete [] modifiedNSPRPath; +#endif } diff --git a/xpcom/io/nsFileSpec.h b/xpcom/io/nsFileSpec.h index 8a28930cd21..5478c560fb5 100644 --- a/xpcom/io/nsFileSpec.h +++ b/xpcom/io/nsFileSpec.h @@ -282,10 +282,11 @@ class NS_BASE nsFileSpec { public: nsFileSpec(); - + + // These two meathods take *native* file paths. NS_EXPLICIT nsFileSpec(const char* inString, PRBool inCreateDirs = PR_FALSE); NS_EXPLICIT nsFileSpec(const nsString& inString, PRBool inCreateDirs = PR_FALSE); - // These above two meathods take *native* file paths. + NS_EXPLICIT nsFileSpec(const nsFilePath& inPath); NS_EXPLICIT nsFileSpec(const nsFileURL& inURL); @@ -293,12 +294,14 @@ class NS_BASE nsFileSpec nsFileSpec(const nsFileSpec& inPath); virtual ~nsFileSpec(); + // These two operands take *native* file paths. void operator = (const char* inPath); void operator = (const nsString& inPath) { const nsAutoCString path(inPath); *this = path; } + void operator = (const nsFilePath& inPath); void operator = (const nsFileURL& inURL); void operator = (const nsFileSpec& inOther);