Fix badness when nsFilePath is initialized with a nil or empty string.

This commit is contained in:
mcmullen%netscape.com 1999-05-12 22:56:24 +00:00
parent ee19d4ead5
commit bb815af574
2 changed files with 18 additions and 2 deletions

View File

@ -615,6 +615,9 @@ nsFilePath::nsFilePath(const char* inString, PRBool inCreateDirs)
//----------------------------------------------------------------------------------------
: mPath(inString)
{
if (mPath.IsEmpty())
return;
NS_ASSERTION(strstr(inString, kFileURLPrefix) != inString, "URL passed as path");
#ifdef XP_PC
@ -635,8 +638,10 @@ nsFilePath::nsFilePath(const nsString& inString, PRBool inCreateDirs)
//----------------------------------------------------------------------------------------
: mPath(inString)
{
NS_ASSERTION(strstr((const char*)mPath, kFileURLPrefix) != (const char*)mPath, "URL passed as path");
if (mPath.IsEmpty())
return;
NS_ASSERTION(strstr((const char*)mPath, kFileURLPrefix) != (const char*)mPath, "URL passed as path");
#ifdef XP_PC
nsFileSpecHelpers::UnixToNative(mPath);
#endif
@ -688,8 +693,11 @@ void nsFilePath::operator = (const nsFileSpec& inOther)
void nsFilePath::operator = (const char* inString)
//----------------------------------------------------------------------------------------
{
NS_ASSERTION(strstr(inString, kFileURLPrefix) != inString, "URL passed as path");
mPath = inString;
if (mPath.IsEmpty())
return;
#ifdef XP_PC
nsFileSpecHelpers::UnixToNative(mPath);
#endif

View File

@ -615,6 +615,9 @@ nsFilePath::nsFilePath(const char* inString, PRBool inCreateDirs)
//----------------------------------------------------------------------------------------
: mPath(inString)
{
if (mPath.IsEmpty())
return;
NS_ASSERTION(strstr(inString, kFileURLPrefix) != inString, "URL passed as path");
#ifdef XP_PC
@ -635,8 +638,10 @@ nsFilePath::nsFilePath(const nsString& inString, PRBool inCreateDirs)
//----------------------------------------------------------------------------------------
: mPath(inString)
{
NS_ASSERTION(strstr((const char*)mPath, kFileURLPrefix) != (const char*)mPath, "URL passed as path");
if (mPath.IsEmpty())
return;
NS_ASSERTION(strstr((const char*)mPath, kFileURLPrefix) != (const char*)mPath, "URL passed as path");
#ifdef XP_PC
nsFileSpecHelpers::UnixToNative(mPath);
#endif
@ -688,8 +693,11 @@ void nsFilePath::operator = (const nsFileSpec& inOther)
void nsFilePath::operator = (const char* inString)
//----------------------------------------------------------------------------------------
{
NS_ASSERTION(strstr(inString, kFileURLPrefix) != inString, "URL passed as path");
mPath = inString;
if (mPath.IsEmpty())
return;
#ifdef XP_PC
nsFileSpecHelpers::UnixToNative(mPath);
#endif