From 43ca24e167fc77e392b0ac19e829fa7c731645b0 Mon Sep 17 00:00:00 2001 From: Darryl Pogue Date: Mon, 28 Jan 2013 23:15:11 -0800 Subject: [PATCH] Fix some plString/plFileSystem issues for *nix. --- Sources/Plasma/CoreLib/HeadSpin.h | 15 --------------- Sources/Plasma/CoreLib/plFileSystem.cpp | 11 ++++++----- Sources/Plasma/CoreLib/plString.h | 20 +++++++++++++++++++- 3 files changed, 25 insertions(+), 21 deletions(-) diff --git a/Sources/Plasma/CoreLib/HeadSpin.h b/Sources/Plasma/CoreLib/HeadSpin.h index d6817cb8..2560bd72 100644 --- a/Sources/Plasma/CoreLib/HeadSpin.h +++ b/Sources/Plasma/CoreLib/HeadSpin.h @@ -341,21 +341,6 @@ void hsStrLower(char *s); char * hsFormatStr(const char * fmt, ...); // You are responsible for returned memory. char * hsFormatStrV(const char * fmt, va_list args); // You are responsible for returned memory. -// Use "correct" stricmp based on the selected compiler / library -#if _MSC_VER -# define stricmp _stricmp -# define strnicmp _strnicmp -# define wcsicmp _wcsicmp -# define wcsnicmp _wcsnicmp -# define strlwr _strlwr -#else -# define stricmp strcasecmp -# define strnicmp strncasecmp -# define wcsicmp wcscasecmp -# define wcsnicmp wcsncasecmp -# define strlwr hsStrLower -#endif - inline char* hsStrcpy(const char src[]) { return hsStrcpy(nil, src); diff --git a/Sources/Plasma/CoreLib/plFileSystem.cpp b/Sources/Plasma/CoreLib/plFileSystem.cpp index 9c1ac1ff..d791f959 100644 --- a/Sources/Plasma/CoreLib/plFileSystem.cpp +++ b/Sources/Plasma/CoreLib/plFileSystem.cpp @@ -380,15 +380,16 @@ std::vector plFileSystem::ListDir(const plFileName &path, const char struct dirent *de; while (de = readdir(dir)) { - if (plFileInfo(de->d_name).IsDirectory()) { + plFileName dir_name = plFileName::Join(path, de->d_name); + if (plFileInfo(dir_name).IsDirectory()) { // Should also handle . and .. continue; } - if (pattern && pattern[0] && fnmatch(pattern, de->d_name)) - contents.push_back(plFileName::Join(path, de->d_name)); + if (pattern && pattern[0] && fnmatch(pattern, de->d_name, 0)) + contents.push_back(dir_name); else if (!pattern || !pattern[0]) - contents.push_back(plFileName::Join(path, de->d_name)); + contents.push_back(dir_name); } closedir(dir); @@ -428,7 +429,7 @@ std::vector plFileSystem::ListSubdirs(const plFileName &path) if (plFileInfo(de->d_name).IsDirectory()) { plFileName name = de->d_name; if (name != "." && name != "..") - contents.push_back(plFileName::Join(path, name); + contents.push_back(plFileName::Join(path, name)); } } diff --git a/Sources/Plasma/CoreLib/plString.h b/Sources/Plasma/CoreLib/plString.h index acdeb0ed..d5e39e4f 100644 --- a/Sources/Plasma/CoreLib/plString.h +++ b/Sources/Plasma/CoreLib/plString.h @@ -43,8 +43,11 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com #ifndef plString_Defined #define plString_Defined -#include #include +#include +#include +#include +#include /** Single Unicode character code unit */ typedef unsigned int UniChar; @@ -53,6 +56,21 @@ typedef unsigned int UniChar; #define STRING_STACK_SIZE (256) #define WHITESPACE_CHARS " \t\n\r" +// Use "correct" stricmp based on the selected compiler / library +#if _MSC_VER +# define stricmp _stricmp +# define strnicmp _strnicmp +# define wcsicmp _wcsicmp +# define wcsnicmp _wcsnicmp +# define strlwr _strlwr +#else +# define stricmp strcasecmp +# define strnicmp strncasecmp +# define wcsicmp wcscasecmp +# define wcsnicmp wcsncasecmp +# define strlwr hsStrLower +#endif + /** Ref-counted string data buffer. * This is used to store actual string data in any (unchecked) encoding format, * including both the internal UTF-8 data of plString itself as well as the