From 3ddd9b8a4c72025e763f476dadabb3fbf2d2b8e4 Mon Sep 17 00:00:00 2001 From: RichardRanft Date: Wed, 6 May 2015 15:39:02 -0700 Subject: [PATCH 1/3] Add static String::isEmpty(const char*) method and use it to verify path for Forest::saveDataFile() is not empty. --- Engine/source/core/util/str.cpp | 5 +++++ Engine/source/core/util/str.h | 1 + Engine/source/forest/forest.cpp | 2 +- 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/Engine/source/core/util/str.cpp b/Engine/source/core/util/str.cpp index d9d3c3ec7..013be3477 100644 --- a/Engine/source/core/util/str.cpp +++ b/Engine/source/core/util/str.cpp @@ -657,6 +657,11 @@ bool String::isEmpty() const return ( _string == StringData::Empty() ); } +bool String::isEmpty(const char* str) +{ + return (dStrlen(str) == 0); +} + bool String::isShared() const { return _string->isShared(); diff --git a/Engine/source/core/util/str.h b/Engine/source/core/util/str.h index 009484451..517f0be81 100644 --- a/Engine/source/core/util/str.h +++ b/Engine/source/core/util/str.h @@ -74,6 +74,7 @@ public: SizeType size() const; ///< Returns the length of the string in bytes including the NULL terminator. SizeType numChars() const; ///< Returns the length of the string in characters. bool isEmpty() const; ///< Is this an empty string [""]? + static bool isEmpty(const char*); // is the input empty? bool isNotEmpty() const { return !isEmpty(); } ///< Is this not an empty string [""]? /// Erases all characters in a string. diff --git a/Engine/source/forest/forest.cpp b/Engine/source/forest/forest.cpp index 037278e36..7e8938d82 100644 --- a/Engine/source/forest/forest.cpp +++ b/Engine/source/forest/forest.cpp @@ -354,7 +354,7 @@ void Forest::createNewFile() void Forest::saveDataFile( const char *path ) { - if ( path ) + if ( path && !String::isEmpty(path)) mDataFileName = StringTable->insert( path ); if ( mData ) From 38413be5137dfafa3c47cb5dbbe12392121796a2 Mon Sep 17 00:00:00 2001 From: RichardRanft Date: Sun, 24 May 2015 22:43:27 -0700 Subject: [PATCH 2/3] Update str.cpp Effectively copied dStrIsEmtpy() into String::isEmpty(). --- Engine/source/core/util/str.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Engine/source/core/util/str.cpp b/Engine/source/core/util/str.cpp index 013be3477..b9f2ff14a 100644 --- a/Engine/source/core/util/str.cpp +++ b/Engine/source/core/util/str.cpp @@ -659,7 +659,7 @@ bool String::isEmpty() const bool String::isEmpty(const char* str) { - return (dStrlen(str) == 0); + return src == 0 || src[0] == '\0'; } bool String::isShared() const From 6c9cff4c6842c5fa928fac32aa1c94eff059b607 Mon Sep 17 00:00:00 2001 From: RichardRanft Date: Sun, 31 May 2015 20:42:05 -0700 Subject: [PATCH 3/3] Update str.cpp Fixed copy/paste error - now actually checks the parameter passed in.... --- Engine/source/core/util/str.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Engine/source/core/util/str.cpp b/Engine/source/core/util/str.cpp index b9f2ff14a..51a230e73 100644 --- a/Engine/source/core/util/str.cpp +++ b/Engine/source/core/util/str.cpp @@ -659,7 +659,7 @@ bool String::isEmpty() const bool String::isEmpty(const char* str) { - return src == 0 || src[0] == '\0'; + return str == 0 || str[0] == '\0'; } bool String::isShared() const