Browse Source

Kill as much of pnUtPath as possible.

Darryl Pogue 13 years ago
parent
commit
205795e037
  1. 8
      Sources/Plasma/Apps/plUruLauncher/Main.cpp
  2. 2
      Sources/Plasma/Apps/plUruLauncher/SelfPatcher.cpp
  3. 311
      Sources/Plasma/NucleusLib/pnUtils/Win32/pnUtW32Path.cpp
  4. 80
      Sources/Plasma/NucleusLib/pnUtils/pnUtPath.cpp
  5. 107
      Sources/Plasma/NucleusLib/pnUtils/pnUtPath.h
  6. 159
      Sources/Plasma/NucleusLib/pnUtils/pnUtStr.cpp
  7. 24
      Sources/Plasma/NucleusLib/pnUtils/pnUtStr.h

8
Sources/Plasma/Apps/plUruLauncher/Main.cpp

@ -834,7 +834,7 @@ int __stdcall WinMain (
// Wait for the other process to exit
Sleep(1000);
if (!PathDeleteFile(newPatcherFile)) {
if (!plFileUtils::RemoveFile(newPatcherFile)) {
wchar_t error[256];
DWORD errorCode = GetLastError();
wchar_t *msg = TranslateErrorCode(errorCode);
@ -844,7 +844,7 @@ int __stdcall WinMain (
LocalFree(msg);
break;
}
if (!PathMoveFile(curPatcherFile, newPatcherFile)) {
if (!plFileUtils::FileMove(curPatcherFile, newPatcherFile)) {
wchar_t error[256];
DWORD errorCode = GetLastError();
wchar_t *msg = TranslateErrorCode(errorCode);
@ -852,7 +852,7 @@ int __stdcall WinMain (
StrPrintf(error, arrsize(error), L"Failed to replace old patcher executable. %s", msg);
MessageBoxW(GetTopWindow(nil), error, L"Error", MB_OK);
// attempt to clean up this tmp file
PathDeleteFile(curPatcherFile);
plFileUtils::RemoveFile(curPatcherFile);
LocalFree(msg);
break;
}
@ -896,7 +896,7 @@ int __stdcall WinMain (
PathAddFilename(fileSpec, fileSpec, L"*.tmp", arrsize(fileSpec));
PathFindFiles(&paths, fileSpec, kPathFlagFile);
for (PathFind * path = paths.Ptr(); path != paths.Term(); ++path)
PathDeleteFile(path->name);
plFileUtils::RemoveFile(path->name);
SetConsoleCtrlHandler(CtrlHandler, TRUE);
InitAsyncCore(); // must do this before self patch, since it needs to connect to the file server

2
Sources/Plasma/Apps/plUruLauncher/SelfPatcher.cpp

@ -232,7 +232,7 @@ static void FileSrvIpAddressCallback (
PathGetProgramDirectory(s_newPatcherFile, arrsize(s_newPatcherFile));
GetTempFileNameW(s_newPatcherFile, kPatcherExeFilename, 0, s_newPatcherFile);
PathDeleteFile(s_newPatcherFile);
plFileUtils::RemoveFile(s_newPatcherFile);
NetCliFileManifestRequest(ManifestCallback, nil, s_manifest);
}

311
Sources/Plasma/NucleusLib/pnUtils/Win32/pnUtW32Path.cpp

@ -112,47 +112,21 @@ static wchar_t * PathSkipOverSeparator (wchar_t * path) {
}
//===========================================================================
static unsigned CommonPrefixLength (
const wchar_t src1[],
const wchar_t src2[]
const wchar_t * PathFindFilename (
const wchar_t path[]
) {
ASSERT(src1);
ASSERT(src2);
wchar_t const * const base = src1;
const wchar_t * common = nil;
for (;;) {
// Are the next components equal in length?
const wchar_t * next1 = PathSkipOverSeparator(const_cast<wchar_t *>(src1));
const wchar_t * next2 = PathSkipOverSeparator(const_cast<wchar_t *>(src2));
const int componentLen = next1 - src1;
if (componentLen != (next2 - src2))
break;
// Are the next components equal in value?
if (!StrCmpI(src1, src2, componentLen))
common = next1;
else
break;
ASSERT(path);
if (!*next1)
break;
src1 = next1 + 1;
if (IsUncPath(path))
path = SkipUncDrive(path);
if (!*next2)
break;
src2 = next2 + 1;
const wchar_t * last_slash = path;
for (const wchar_t * p = path; *p; p++) {
if ((*p == L'/') || (*p == L'\\') || (*p == L':'))
last_slash = p + 1;
}
if (!common)
return 0;
// Compute length of common subchunk;
// if it is "C:" convert it to "C:\"
unsigned commonLen = common - base;
if ((commonLen == 2) && (base[1] == L':'))
++commonLen;
return commonLen;
return last_slash;
}
//===========================================================================
@ -170,6 +144,16 @@ static void GetProgramName (
}
}
//============================================================================
bool PathDoesDirectoryExist (const wchar_t directory[]) {
uint32_t attributes = GetFileAttributesW(directory);
if (attributes == (uint32_t) -1)
return false;
if (attributes & FILE_ATTRIBUTE_DIRECTORY)
return true;
return false;
}
/****************************************************************************
*
@ -177,14 +161,6 @@ static void GetProgramName (
*
***/
//===========================================================================
void PathGetModuleName (
wchar_t * dst,
unsigned dstChars
) {
GetProgramName(ModuleGetInstance(), dst, dstChars);
}
//===========================================================================
void PathGetProgramName (
wchar_t * dst,
@ -226,32 +202,6 @@ bool PathFromString (
return false;
}
//===========================================================================
bool PathFromString (
wchar_t * dst, // ASSERT(dst);
const wchar_t src[], // ASSERT(src);
unsigned dstChars, // ASSERT(dstChars);
const wchar_t baseDir[] // ASSERT(baseDir);
) {
ASSERT(baseDir);
ASSERT(dstChars);
// Save current directory
wchar_t curr[MAX_PATH];
PathGetCurrentDirectory(curr, arrsize(curr));
// Perform string conversion from specified directory
bool result;
if (0 != (result = PathSetCurrentDirectory(baseDir)))
result = PathFromString(dst, src, dstChars);
else
*dst = 0;
// Restore directory
PathSetCurrentDirectory(curr);
return result;
}
//===========================================================================
// this function was originally derived from _tsplitpath in the MSVCRT library,
// but has been updated to support UNC paths and to avoid blasting off the end
@ -399,140 +349,6 @@ void PathMakePath (
}
//===========================================================================
bool PathMakeRelative (
wchar_t *dst,
unsigned fromFlags, // 0 or kPathFlagDirectory
const wchar_t from[],
unsigned toFlags, // 0 or kPathFlagDirectory
const wchar_t to[],
unsigned dstChars
) {
ASSERT(dst);
ASSERT(from);
ASSERT(to);
ASSERT(dstChars);
*dst = 0;
unsigned prefixLength = CommonPrefixLength(from, to);
if (!prefixLength)
return false;
wchar_t fromBuf[MAX_PATH];
if (fromFlags & kPathFlagDirectory)
StrCopy(fromBuf, from, arrsize(fromBuf));
else
PathRemoveFilename(fromBuf, from, arrsize(fromBuf));
wchar_t toBuf[MAX_PATH];
if (toFlags & kPathFlagDirectory)
StrCopy(toBuf, to, arrsize(toBuf));
else
PathRemoveFilename(toBuf, to, arrsize(toBuf));
const wchar_t * curr = fromBuf + prefixLength;
if (*curr) {
// build ..\.. part of the path
if (IsSlash(*curr))
curr++; // skip slash
while (*curr) {
curr = PathSkipOverSeparator(const_cast<wchar_t *>(curr));
StrPack(dst, *curr ? L"..\\" : L"..", dstChars);
}
}
else {
StrCopy(dst, L".", dstChars);
}
if (to[prefixLength]) {
// deal with root case
if (!IsSlash(to[prefixLength]))
--prefixLength;
ASSERT(IsSlash(to[prefixLength]));
StrPack(dst, to + prefixLength, dstChars);
}
return true;
}
//===========================================================================
bool PathIsRelative (
const wchar_t src[]
) {
ASSERT(src);
if (!src[0])
return true;
if (IsSlash(src[0]))
return false;
if (src[1] == L':')
return false;
return true;
}
//===========================================================================
const wchar_t * PathFindFilename (
const wchar_t path[]
) {
ASSERT(path);
if (IsUncPath(path))
path = SkipUncDrive(path);
const wchar_t * last_slash = path;
for (const wchar_t * p = path; *p; p++) {
if ((*p == L'/') || (*p == L'\\') || (*p == L':'))
last_slash = p + 1;
}
return last_slash;
}
//===========================================================================
const wchar_t * PathFindExtension (
const wchar_t path[]
) {
ASSERT(path);
const wchar_t * last_dot = 0;
const wchar_t * p = PathFindFilename(path);
for ( ; *p; p++) {
if (*p == L'.')
last_dot = p;
}
return last_dot ? last_dot : p;
}
//===========================================================================
void PathGetCurrentDirectory (
wchar_t * dst,
unsigned dstChars
) {
ASSERT(dst);
ASSERT(dstChars);
DWORD result = GetCurrentDirectoryW(dstChars, dst);
if (!result || (result >= dstChars)) {
ErrorAssert(__LINE__, __FILE__, "GetDir failed");
*dst = 0;
}
}
//===========================================================================
void PathGetTempDirectory (
wchar_t * dst,
unsigned dstChars
) {
ASSERT(dst);
ASSERT(dstChars);
DWORD result = GetTempPathW(dstChars, dst);
if (!result || (result >= dstChars))
StrCopy(dst, L"C:\\temp\\", dstChars);
}
//============================================================================
void PathGetUserDirectory (
wchar_t * dst,
unsigned dstChars
@ -578,21 +394,6 @@ void PathGetInitDirectory (
PathCreateDirectory(dst, kPathCreateDirFlagEntireTree);
}
//===========================================================================
bool PathSetCurrentDirectory (
const wchar_t path[]
) {
ASSERT(path);
return SetCurrentDirectoryW(path) != 0;
}
//===========================================================================
void PathSetProgramDirectory () {
wchar_t dir[MAX_PATH];
PathGetProgramDirectory(dir, arrsize(dir));
PathSetCurrentDirectory(dir);
}
//===========================================================================
void PathFindFiles (
ARRAY(PathFind) * paths,
@ -772,46 +573,6 @@ EPathCreateDirError PathCreateDirectory (const wchar_t path[], unsigned flags) {
}
}
//===========================================================================
void PathDeleteDirectory (const wchar_t path[], unsigned flags) {
ASSERT(path);
// convert from relative path to full path
wchar_t dir[MAX_PATH];
if (!PathFromString(dir, path, arrsize(dir)))
return;
for (;;) {
// Important: in order to ensure that we don't delete NTFS
// partition links, we must ensure that this is a directory!
uint32_t attributes = GetFileAttributesW(dir);
if (attributes == (uint32_t) -1)
break;
if ((attributes & FILE_ATTRIBUTE_DIRECTORY) == 0)
break;
if (attributes & FILE_ATTRIBUTE_REPARSE_POINT)
break;
if (!RemoveDirectoryW(dir))
break;
if ((flags & kPathCreateDirFlagEntireTree) == 0)
break;
wchar_t * filename = PathFindFilename(dir);
if (!filename)
break;
// Move up one level in the directory hierarchy
unsigned oldLength = StrLen(dir);
while ((filename > dir) && IsSlash(filename[-1]))
--filename;
*filename = 0;
if (oldLength == StrLen(dir))
break;
}
}
//===========================================================================
bool PathDoesFileExist (const wchar_t fileName[]) {
uint32_t attributes = GetFileAttributesW(fileName);
@ -822,35 +583,3 @@ bool PathDoesFileExist (const wchar_t fileName[]) {
return true;
}
//============================================================================
bool PathDoesDirectoryExist (const wchar_t directory[]) {
uint32_t attributes = GetFileAttributesW(directory);
if (attributes == (uint32_t) -1)
return false;
if (attributes & FILE_ATTRIBUTE_DIRECTORY)
return true;
return false;
}
//===========================================================================
bool PathDeleteFile (
const wchar_t file[]
) {
return DeleteFileW(file) != 0;
}
//===========================================================================
bool PathMoveFile (
const wchar_t src[],
const wchar_t dst[]
) {
return MoveFileW(src, dst) != 0;
}
//===========================================================================
bool PathCopyFile (
const wchar_t src[],
const wchar_t dst[]
) {
return CopyFileW(src, dst, FALSE) != 0;
}

80
Sources/Plasma/NucleusLib/pnUtils/pnUtPath.cpp

@ -106,86 +106,6 @@ void PathRemoveFilename (
PathMakePath(dst, dstChars, drive, dir, 0, 0);
}
//===========================================================================
void PathRemoveExtension (
wchar_t *dst,
const wchar_t src[],
unsigned dstChars
) {
ASSERT(dst);
ASSERT(src);
ASSERT(dstChars);
wchar_t drive[MAX_DRIVE];
wchar_t dir[MAX_DIR];
wchar_t fname[MAX_FNAME];
PathSplitPath(src, drive, dir, fname, 0);
PathMakePath(dst, dstChars, drive, dir, fname, 0);
}
//===========================================================================
void PathSetExtension (
wchar_t *dst,
const wchar_t src[],
const wchar_t ext[],
unsigned dstChars
) {
ASSERT(dst);
ASSERT(src);
ASSERT(dst != ext);
ASSERT(dstChars);
wchar_t drive[MAX_DRIVE];
wchar_t dir[MAX_DIR];
wchar_t fname[MAX_FNAME];
PathSplitPath(src, drive, dir, fname, 0);
PathMakePath(dst, dstChars, drive, dir, fname, ext);
}
//===========================================================================
void PathAddExtension (
wchar_t *dst,
const wchar_t src[],
const wchar_t ext[],
unsigned dstChars
) {
ASSERT(dst);
ASSERT(src);
ASSERT(dst != ext);
ASSERT(dstChars);
wchar_t drive[MAX_DRIVE];
wchar_t dir[MAX_DIR];
wchar_t fname[MAX_FNAME];
wchar_t oldext[MAX_EXT];
PathSplitPath(src, drive, dir, fname, oldext);
PathMakePath(
dst,
dstChars,
drive,
dir,
fname,
oldext[0] ? oldext : ext
);
}
//===========================================================================
void PathRemoveDirectory (
wchar_t *dst,
const wchar_t src[],
unsigned dstChars
) {
ASSERT(dst);
ASSERT(src);
ASSERT(dstChars);
wchar_t fname[MAX_FNAME];
wchar_t ext[MAX_EXT];
PathSplitPath(src, 0, 0, fname, ext);
PathMakePath(dst, dstChars, 0, 0, fname, ext);
}
/*****************************************************************************
*
* Email formatting functions

107
Sources/Plasma/NucleusLib/pnUtils/pnUtPath.h

@ -97,43 +97,10 @@ void PathGetProgramName (
wchar_t * dst,
unsigned dstChars
);
void PathGetModuleName (
wchar_t * dst,
unsigned dstChars
);
// this function will use the current directory if <src> is a relative path
// (see PathSetCurrentDirectory/PathGetCurrentDirectory)
bool PathFromString (
wchar_t * dst,
const wchar_t src[],
unsigned dstChars
);
bool PathFromString (
wchar_t * dst,
const wchar_t src[],
unsigned dstChars,
const wchar_t baseDir[]
);
bool PathDoesFileExist (
const wchar_t fileName[]
);
bool PathDoesDirectoryExist (
const wchar_t directory[]
);
bool PathDeleteFile (
const wchar_t file[]
);
bool PathMoveFile (
const wchar_t src[],
const wchar_t dst[]
);
bool PathCopyFile (
const wchar_t src[],
const wchar_t dst[]
);
/*****************************************************************************
@ -174,64 +141,6 @@ void PathRemoveFilename (
unsigned dstChars
);
// c:\file.txt => c:\dir1\dir2\file
void PathRemoveExtension (
wchar_t * dst,
const wchar_t src[],
unsigned dstChars
);
// c:\file + .out => c:\file.out
// c:\file. + .out => c:\file.out
// c:\file.txt + .out => c:\file.out
void PathSetExtension (
wchar_t * dst,
const wchar_t src[],
const wchar_t ext[],
unsigned dstChars
);
// c:\file + .out => c:\file.out
// c:\file. + .out => c:\file.
// c:\file.txt + .out => c:\file.txt
void PathAddExtension (
wchar_t * dst,
const wchar_t src[],
const wchar_t ext[],
unsigned dstChars
);
// c:\dir1\dir2\file.txt => file.txt
void PathRemoveDirectory (
wchar_t * dst,
const wchar_t src[],
unsigned dstChars
);
// c:\dir1\dir2\file.txt - c:\dir1 => .\dir2\file.txt
// c:\dir1\dir2\file1.txt - c:\dir1\dir4\file2.txt => ..\dir4\file2.txt
bool PathMakeRelative (
wchar_t * dst,
unsigned fromFlags,
const wchar_t from[],
unsigned toFlags,
const wchar_t to[],
unsigned dstChars
);
bool PathIsRelative (
const wchar_t src[]
);
const wchar_t * PathFindFilename (const wchar_t path[]);
inline wchar_t * PathFindFilename (wchar_t * path) {
return const_cast<wchar_t *>(PathFindFilename(const_cast<const wchar_t *>(path)));
}
const wchar_t * PathFindExtension (const wchar_t path[]);
inline wchar_t * PathFindExtension (wchar_t * path) {
return const_cast<wchar_t *>(PathFindExtension(const_cast<const wchar_t *>(path)));
}
/*****************************************************************************
*
@ -263,15 +172,7 @@ EPathCreateDirError PathCreateDirectory (
const wchar_t path[],
unsigned flags
);
void PathDeleteDirectory (
const wchar_t path[],
unsigned flags
);
// Set directory
bool PathSetCurrentDirectory (const wchar_t path[]);
void PathSetProgramDirectory ();
// Get directory
@ -279,14 +180,6 @@ void PathGetProgramDirectory (
wchar_t * dst,
unsigned dstChars
);
void PathGetCurrentDirectory (
wchar_t * dst,
unsigned dstChars
);
void PathGetTempDirectory (
wchar_t * dst,
unsigned dstChars
);
// Product and user-specific common directory locations

159
Sources/Plasma/NucleusLib/pnUtils/pnUtStr.cpp

@ -120,18 +120,6 @@ static chartype * IStrChr (chartype * str, findchartype ch, unsigned chars) {
return nil;
}
//===========================================================================
template<class chartype, class findchartype>
static chartype * IStrChrR (chartype * str, findchartype ch) {
chartype * start = str;
for (; *str; ++str)
NULL_STMT;
while (str-- > start)
if (*str == ch)
return str;
return NULL;
}
//===========================================================================
static inline bool ICharUnicodeToUtf8 (char ** dest, const wchar_t * source[], unsigned destChars) {
unsigned ch = *(*source)++;
@ -226,20 +214,6 @@ static int IStrCmpI (const chartype str1[], const chartype str2[], unsigned char
return 0;
}
//===========================================================================
// returns StrLen(dest)
template<class chartype>
static unsigned IStrCopyLen (chartype * dest, const chartype source[], unsigned chars) {
chartype * const start = dest;
while ((chars > 1) && ((*dest = *source++) != 0)) {
--chars;
++dest;
}
if (chars)
*dest = 0;
return dest - start;
}
//===========================================================================
template<class chartype>
static void IStrPack (chartype * dest, const chartype source[], unsigned chars) {
@ -273,46 +247,6 @@ static chartype * IStrStr (chartype source[], const chartype match[]) {
return nil;
}
//===========================================================================
template<class chartype>
static chartype * IStrStrI (chartype source[], const chartype match[]) {
if (!*match)
return source;
for (chartype * curr = source; *curr; ++curr) {
chartype * s1 = curr;
const chartype * s2 = match;
while (*s1 && *s2 && (CharLowerFast(*s1) == CharLowerFast(*s2)))
s1++, s2++;
if (!*s2)
return curr;
}
return nil;
}
//===========================================================================
template<class chartype>
static void IStrLower (chartype * dest, unsigned chars) {
while ((chars > 1) && ((*dest = CharLowerFast(*dest)) != 0)) {
--chars;
++dest;
}
}
//===========================================================================
template<class chartype>
static void IStrLower (chartype * dest, const chartype source[], unsigned chars) {
while ((chars > 1) && ((*dest = CharLowerFast(*source)) != 0)) {
--chars;
++dest;
++source;
}
if (chars)
*dest = 0;
}
//===========================================================================
template<class chartype>
static uint32_t IStrHash (const chartype str[], unsigned chars) {
@ -496,26 +430,6 @@ const wchar_t * StrChr (const wchar_t str[], wchar_t ch, unsigned chars) {
return IStrChr(str, ch, chars);
}
//===========================================================================
char * StrChrR (char * str, char ch) {
return IStrChrR(str, ch);
}
//===========================================================================
wchar_t * StrChrR (wchar_t * str, wchar_t ch) {
return IStrChrR(str, ch);
}
//===========================================================================
const char * StrChrR (const char str[], char ch) {
return IStrChrR(str, ch);
}
//===========================================================================
const wchar_t * StrChrR (const wchar_t str[], wchar_t ch) {
return IStrChrR(str, ch);
}
//===========================================================================
unsigned StrPrintf (char * dest, unsigned count, const char format[], ...) {
va_list argList;
@ -576,16 +490,6 @@ void StrCopy (wchar_t * dest, const wchar_t source[], unsigned chars) {
IStrCopy(dest, source, chars);
}
//===========================================================================
unsigned StrCopyLen (char * dest, const char source[], unsigned chars) {
return IStrCopyLen(dest, source, chars);
}
//===========================================================================
unsigned StrCopyLen (wchar_t * dest, const wchar_t source[], unsigned chars) {
return IStrCopyLen(dest, source, chars);
}
//===========================================================================
void StrPack (char * dest, const char source[], unsigned chars) {
IStrPack(dest, source, chars);
@ -616,26 +520,6 @@ const wchar_t * StrStr (const wchar_t source[], const wchar_t match[]) {
return IStrStr<const wchar_t>(source, match);
}
//===========================================================================
char * StrStrI (char * source, const char match[]) {
return IStrStrI(source, match);
}
//===========================================================================
const char * StrStrI (const char source[], const char match[]) {
return IStrStrI<const char>(source, match);
}
//===========================================================================
wchar_t * StrStrI (wchar_t * source, const wchar_t match[]) {
return IStrStrI(source, match);
}
//===========================================================================
const wchar_t * StrStrI (const wchar_t source[], const wchar_t match[]) {
return IStrStrI<const wchar_t>(source, match);
}
//===========================================================================
unsigned StrLen (const char str[]) {
return IStrLen(str);
@ -647,29 +531,6 @@ unsigned StrLen (const wchar_t str[]) {
}
//===========================================================================
unsigned StrUnicodeToUtf8 (char * dest, const wchar_t source[], unsigned destChars) {
char * destCurr = dest;
char * destTerm = dest + destChars;
while (*source && (destCurr + 1 < destTerm))
if (!ICharUnicodeToUtf8(&destCurr, &source, destTerm - destCurr - 1))
break;
if (destCurr < destTerm)
*destCurr = 0;
return destCurr - dest; // dest chars not including null terminator
}
//===========================================================================
unsigned StrUtf8ToUnicode (wchar_t * dest, const char source[], unsigned destChars) {
wchar_t * destCurr = dest;
wchar_t * destTerm = dest + destChars;
while (*source && (destCurr + 1 < destTerm))
ICharUtf8ToUnicode(&destCurr, &source);
if (destCurr < destTerm)
*destCurr = 0;
return destCurr - dest; // dest chars not including null terminator
}
//============================================================================
float StrToFloat (const char source[], const char ** endptr) {
return (float) strtod(source, const_cast<char **>(endptr));
}
@ -710,26 +571,6 @@ unsigned StrToUnsigned (const wchar_t source[], const wchar_t ** endptr, int rad
}
//===========================================================================
void StrLower (char * dest, unsigned chars) {
IStrLower(dest, chars);
}
//===========================================================================
void StrLower (wchar_t * dest, unsigned chars) {
IStrLower(dest, chars);
}
//===========================================================================
void StrLower (char * dest, const char source[], unsigned chars) {
IStrLower(dest, source, chars);
}
//===========================================================================
void StrLower (wchar_t * dest, const wchar_t source[], unsigned chars) {
IStrLower(dest, source, chars);
}
//============================================================================
uint32_t StrHash (const char str[], unsigned chars) {
return IStrHash(str, chars);
}

24
Sources/Plasma/NucleusLib/pnUtils/pnUtStr.h

@ -61,9 +61,6 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
inline char CharLowerFast (char ch) { return ((ch >= 'A') && (ch <= 'Z')) ? (char )(ch + 'a' - 'A') : ch; }
inline wchar_t CharLowerFast (wchar_t ch) { return ((ch >= L'A') && (ch <= L'Z')) ? (wchar_t)(ch + L'a' - L'A') : ch; }
inline char CharUpperFast (char ch) { return ((ch >= 'a') && (ch <= 'z')) ? (char )(ch + 'A' - 'a') : ch; }
inline wchar_t CharUpperFast (wchar_t ch) { return ((ch >= L'a') && (ch <= L'z')) ? (wchar_t)(ch + L'A' - L'a') : ch; }
unsigned StrBytes (const char str[]); // includes space for terminator
unsigned StrBytes (const wchar_t str[]); // includes space for terminator
@ -101,22 +98,9 @@ const char * StrStr (const char source[], const char match[]);
wchar_t * StrStr (wchar_t * source, const wchar_t match[]);
const wchar_t * StrStr (const wchar_t source[], const wchar_t match[]);
char * StrStrI (char * source, const char match[]);
const char * StrStrI (const char source[], const char match[]);
wchar_t * StrStrI (wchar_t * source, const wchar_t match[]);
const wchar_t * StrStrI (const wchar_t source[], const wchar_t match[]);
char * StrChrR (char * str, char ch);
wchar_t * StrChrR (wchar_t * str, wchar_t ch);
const char * StrChrR (const char str[], char ch);
const wchar_t * StrChrR (const wchar_t str[], wchar_t ch);
void StrCopy (char * dest, const char source[], unsigned chars);
void StrCopy (wchar_t * dest, const wchar_t source[], unsigned chars);
unsigned StrCopyLen (char * dest, const char source[], unsigned chars);
unsigned StrCopyLen (wchar_t * dest, const wchar_t source[], unsigned chars);
void StrPack (char * dest, const char source[], unsigned chars);
void StrPack (wchar_t * dest, const wchar_t source[], unsigned chars);
@ -126,9 +110,6 @@ unsigned StrToAnsi (char * dest, const wchar_t source[], unsigned destChars, uns
unsigned StrToUnicode (wchar_t * dest, const char source[], unsigned destChars);
unsigned StrToUnicode (wchar_t * dest, const char source[], unsigned destChars, unsigned codePage);
unsigned StrUnicodeToUtf8 (char * dest, const wchar_t source[], unsigned destChars);
unsigned StrUtf8ToUnicode (wchar_t * dest, const char source[], unsigned destChars);
float StrToFloat (const char source[], const char ** endptr);
float StrToFloat (const wchar_t source[], const wchar_t ** endptr);
@ -140,11 +121,6 @@ unsigned StrToUnsigned (wchar_t source[], wchar_t ** endptr, int radix);
unsigned StrToUnsigned (const char source[], const char ** endptr, int radix);
unsigned StrToUnsigned (const wchar_t source[], const wchar_t ** endptr, int radix);
void StrLower (char * dest, unsigned chars = (unsigned) -1);
void StrLower (wchar_t * dest, unsigned chars = (unsigned) -1);
void StrLower (char * dest, const char source[], unsigned chars);
void StrLower (wchar_t * dest, const wchar_t source[], unsigned chars);
uint32_t StrHash (const char str[], unsigned chars = (unsigned)-1);
uint32_t StrHash (const wchar_t str[], unsigned chars = (unsigned)-1);

Loading…
Cancel
Save