Browse Source

Fix some plString/plFileSystem issues for *nix.

Darryl Pogue 12 years ago
parent
commit
43ca24e167
  1. 15
      Sources/Plasma/CoreLib/HeadSpin.h
  2. 11
      Sources/Plasma/CoreLib/plFileSystem.cpp
  3. 20
      Sources/Plasma/CoreLib/plString.h

15
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);

11
Sources/Plasma/CoreLib/plFileSystem.cpp

@ -380,15 +380,16 @@ std::vector<plFileName> 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<plFileName> 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));
}
}

20
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 <stdint.h>
#include <vector>
#include <cstdint>
#include <cstddef>
#include <cstdarg>
#include <cstring>
/** 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

Loading…
Cancel
Save