mirror of
https://foundry.openuru.org/gitblit/r/CWE-ou-minkata.git
synced 2025-07-18 03:09:13 +00:00
Deprecate plFileUtils and parts of pnUtPath
This commit is contained in:
@ -42,10 +42,10 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
#include "plClientMsg.h"
|
||||
#include "HeadSpin.h"
|
||||
|
||||
void plClientMsg::IReset()
|
||||
void plClientMsg::IReset()
|
||||
{
|
||||
fMsgFlag = 0;
|
||||
fAgeName = nil;
|
||||
fMsgFlag = 0;
|
||||
fAgeName = "";
|
||||
}
|
||||
|
||||
void plClientMsg::AddRoomLoc(plLocation loc)
|
||||
|
@ -56,7 +56,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
class plClientMsg : public plMessage
|
||||
{
|
||||
int fMsgFlag;
|
||||
char* fAgeName;
|
||||
plString fAgeName;
|
||||
std::vector<plLocation> fRoomLocs;
|
||||
|
||||
void IReset();
|
||||
@ -105,7 +105,6 @@ public:
|
||||
plClientMsg(const plKey &s) { IReset();}
|
||||
plClientMsg(int i) { IReset(); fMsgFlag = i; }
|
||||
plClientMsg(const plKey &s, const plKey &r, const double* t) { IReset(); }
|
||||
~plClientMsg() { delete [] fAgeName; }
|
||||
|
||||
CLASSNAME_REGISTER(plClientMsg);
|
||||
GETINTERFACE_ANY(plClientMsg, plMessage);
|
||||
@ -115,8 +114,8 @@ public:
|
||||
void AddRoomLoc(plLocation loc);
|
||||
|
||||
// Used for kLoadAgeKeys, kLetGoOfAgeKeys only
|
||||
const char* GetAgeName() const { return fAgeName; }
|
||||
void SetAgeName(const char* age) { delete [] fAgeName; fAgeName = hsStrcpy(age); }
|
||||
plString GetAgeName() const { return fAgeName; }
|
||||
void SetAgeName(const plString& age) { fAgeName = age; }
|
||||
|
||||
int GetNumRoomLocs() { return fRoomLocs.size(); }
|
||||
const plLocation& GetRoomLoc(int i) const { return fRoomLocs[i]; }
|
||||
|
@ -151,8 +151,8 @@ struct Cli2File_ManifestEntryAck : Cli2File_MsgHeader {
|
||||
|
||||
// FileDownloadRequest
|
||||
struct Cli2File_FileDownloadRequest : Cli2File_MsgHeader {
|
||||
uint32_t transId;
|
||||
wchar_t filename[MAX_PATH];
|
||||
uint32_t transId;
|
||||
wchar_t filename[MAX_PATH];
|
||||
unsigned buildId; // 0 = newest
|
||||
};
|
||||
struct Cli2File_FileDownloadChunkAck : Cli2File_MsgHeader {
|
||||
|
@ -101,16 +101,6 @@ static const wchar_t * SkipUncDrive (const wchar_t path[]) {
|
||||
}
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
static wchar_t * PathSkipOverSeparator (wchar_t * path) {
|
||||
for (; *path; ++path) {
|
||||
if (IsSlash(*path))
|
||||
return path + 1;
|
||||
}
|
||||
|
||||
return path;
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
const wchar_t * PathFindFilename (
|
||||
const wchar_t path[]
|
||||
@ -144,16 +134,6 @@ 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;
|
||||
}
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
*
|
||||
@ -169,39 +149,6 @@ void PathGetProgramName (
|
||||
GetProgramName(nil, dst, dstChars);
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
bool PathFromString (
|
||||
wchar_t * dst,
|
||||
const wchar_t src[],
|
||||
unsigned dstChars
|
||||
) {
|
||||
ASSERT(dst);
|
||||
ASSERT(src);
|
||||
ASSERT(dstChars);
|
||||
|
||||
for (;;) {
|
||||
// enable src and dst to be the same buffer
|
||||
wchar_t temp[MAX_PATH];
|
||||
if (dst == src) {
|
||||
StrCopy(temp, src, arrsize(temp));
|
||||
src = temp;
|
||||
}
|
||||
|
||||
DWORD const result = GetFullPathNameW(src, dstChars, dst, 0);
|
||||
if (!result)
|
||||
break;
|
||||
if (dstChars < result)
|
||||
break;
|
||||
if (!dst[0])
|
||||
break;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
*dst = 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
// 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
|
||||
@ -348,52 +295,6 @@ void PathMakePath (
|
||||
*path = L'\0';
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
void PathGetUserDirectory (
|
||||
wchar_t * dst,
|
||||
unsigned dstChars
|
||||
) {
|
||||
ASSERT(dst);
|
||||
ASSERT(dstChars);
|
||||
|
||||
wchar_t temp[MAX_PATH]; // GetSpecialFolder path requires a buffer of MAX_PATH size or larger
|
||||
if (SHGetSpecialFolderPathW(NULL, temp, CSIDL_LOCAL_APPDATA, TRUE) == FALSE)
|
||||
StrCopy(temp, L"C:\\", arrsize(temp));
|
||||
|
||||
// append the product name
|
||||
PathAddFilename(dst, temp, plProduct::LongName().ToWchar(), dstChars);
|
||||
|
||||
// ensure it exists
|
||||
if (!PathDoesDirectoryExist(dst))
|
||||
PathCreateDirectory(dst, kPathCreateDirFlagEntireTree);
|
||||
}
|
||||
|
||||
//============================================================================
|
||||
void PathGetLogDirectory (
|
||||
wchar_t * dst,
|
||||
unsigned dstChars
|
||||
) {
|
||||
ASSERT(dst);
|
||||
ASSERT(dstChars);
|
||||
PathGetUserDirectory(dst, dstChars);
|
||||
PathAddFilename(dst, dst, L"Log", dstChars);
|
||||
if (!PathDoesDirectoryExist(dst))
|
||||
PathCreateDirectory(dst, kPathCreateDirFlagEntireTree);
|
||||
}
|
||||
|
||||
//============================================================================
|
||||
void PathGetInitDirectory (
|
||||
wchar_t * dst,
|
||||
unsigned dstChars
|
||||
) {
|
||||
ASSERT(dst);
|
||||
ASSERT(dstChars);
|
||||
PathGetUserDirectory(dst, dstChars);
|
||||
PathAddFilename(dst, dst, L"Init", dstChars);
|
||||
if (!PathDoesDirectoryExist(dst))
|
||||
PathCreateDirectory(dst, kPathCreateDirFlagEntireTree);
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
void PathFindFiles (
|
||||
ARRAY(PathFind) * paths,
|
||||
@ -504,82 +405,3 @@ void PathFindFiles (
|
||||
} while (FindNextFileW(find, &fd));
|
||||
FindClose(find);
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
EPathCreateDirError PathCreateDirectory (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 kPathCreateDirErrInvalidPath;
|
||||
}
|
||||
|
||||
// are we going to build the entire directory tree?
|
||||
wchar_t * dirEnd;
|
||||
if (flags & kPathCreateDirFlagEntireTree) {
|
||||
dirEnd = dir;
|
||||
|
||||
// skip over leading slashes in UNC paths
|
||||
while (IsSlash(*dirEnd))
|
||||
++dirEnd;
|
||||
|
||||
// skip forward to first directory
|
||||
dirEnd = PathSkipOverSeparator(dirEnd);
|
||||
}
|
||||
// we're only creating the very last entry in the path
|
||||
else {
|
||||
dirEnd = dir + StrLen(dir);
|
||||
}
|
||||
|
||||
bool result = true;
|
||||
for (wchar_t saveChar = L' '; saveChar; *dirEnd++ = saveChar) {
|
||||
// find the end of the current directory string and terminate it
|
||||
dirEnd = PathSkipOverSeparator(dirEnd);
|
||||
saveChar = *dirEnd;
|
||||
*dirEnd = 0;
|
||||
|
||||
// create the directory and track the result from the last call
|
||||
result = CreateDirectoryW(dir, (LPSECURITY_ATTRIBUTES) nil);
|
||||
}
|
||||
|
||||
// if we successfully created the directory then we're done
|
||||
if (result) {
|
||||
// Avoid check for kPathCreateDirFlagOsError
|
||||
static_assert(kPathCreateDirSuccess == NO_ERROR, "Path creation success and NO_ERROR constants differ");
|
||||
return kPathCreateDirSuccess;
|
||||
}
|
||||
|
||||
unsigned error = GetLastError();
|
||||
switch (error) {
|
||||
case ERROR_ACCESS_DENIED:
|
||||
return kPathCreateDirErrAccessDenied;
|
||||
|
||||
case ERROR_ALREADY_EXISTS: {
|
||||
DWORD attrib;
|
||||
if (0xffffffff == (attrib = GetFileAttributesW(dir)))
|
||||
return kPathCreateDirErrInvalidPath;
|
||||
|
||||
if (! (attrib & FILE_ATTRIBUTE_DIRECTORY))
|
||||
return kPathCreateDirErrFileWithSameName;
|
||||
|
||||
if (flags & kPathCreateDirFlagCreateNew)
|
||||
return kPathCreateDirErrDirExists;
|
||||
}
|
||||
return kPathCreateDirSuccess;
|
||||
|
||||
default:
|
||||
return kPathCreateDirErrInvalidPath;
|
||||
}
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
bool PathDoesFileExist (const wchar_t fileName[]) {
|
||||
uint32_t attributes = GetFileAttributesW(fileName);
|
||||
if (attributes == (uint32_t) -1)
|
||||
return false;
|
||||
if (attributes & FILE_ATTRIBUTE_DIRECTORY)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -76,9 +76,9 @@ const unsigned kPathFlagRecurse = 1<<4; // also set if "**" used in filesp
|
||||
|
||||
struct PathFind {
|
||||
unsigned flags;
|
||||
uint64_t fileLength;
|
||||
uint64_t lastWriteTime;
|
||||
wchar_t name[MAX_PATH];
|
||||
uint64_t fileLength;
|
||||
uint64_t lastWriteTime;
|
||||
wchar_t name[MAX_PATH];
|
||||
};
|
||||
|
||||
|
||||
@ -90,18 +90,14 @@ struct PathFind {
|
||||
|
||||
void PathFindFiles (
|
||||
ARRAY(PathFind) * paths,
|
||||
const wchar_t fileSpec[],
|
||||
const wchar_t fileSpec[],
|
||||
unsigned pathFlags
|
||||
);
|
||||
void PathGetProgramName (
|
||||
wchar_t * dst,
|
||||
wchar_t * dst,
|
||||
unsigned dstChars
|
||||
);
|
||||
|
||||
bool PathDoesFileExist (
|
||||
const wchar_t fileName[]
|
||||
);
|
||||
|
||||
|
||||
/*****************************************************************************
|
||||
*
|
||||
@ -110,20 +106,20 @@ bool PathDoesFileExist (
|
||||
***/
|
||||
|
||||
void PathSplitPath (
|
||||
const wchar_t path[],
|
||||
wchar_t * drive,
|
||||
wchar_t * dir,
|
||||
wchar_t * fname,
|
||||
wchar_t * ext
|
||||
const wchar_t path[],
|
||||
wchar_t * drive,
|
||||
wchar_t * dir,
|
||||
wchar_t * fname,
|
||||
wchar_t * ext
|
||||
);
|
||||
|
||||
void PathMakePath (
|
||||
wchar_t * path,
|
||||
wchar_t * path,
|
||||
unsigned chars,
|
||||
const wchar_t drive[],
|
||||
const wchar_t dir[],
|
||||
const wchar_t fname[],
|
||||
const wchar_t ext[]
|
||||
const wchar_t drive[],
|
||||
const wchar_t dir[],
|
||||
const wchar_t fname[],
|
||||
const wchar_t ext[]
|
||||
);
|
||||
|
||||
// c:\dir1 + dir2\file.txt => c:\dir1\dir2\file.txt
|
||||
@ -148,51 +144,9 @@ void PathRemoveFilename (
|
||||
*
|
||||
***/
|
||||
|
||||
// Create directory
|
||||
enum EPathCreateDirError {
|
||||
kPathCreateDirSuccess,
|
||||
kPathCreateDirErrInvalidPath,
|
||||
kPathCreateDirErrAccessDenied,
|
||||
kPathCreateDirErrFileWithSameName,
|
||||
kPathCreateDirErrDirExists, // Directory exists and kPathCreateDirFlagCreateNew was specified
|
||||
};
|
||||
|
||||
// Setting this flag causes the function to create the entire directory
|
||||
// tree from top to bottom. Clearing this flag causes the function to
|
||||
// create only the last entry in the path.
|
||||
const unsigned kPathCreateDirFlagEntireTree = 1<<0;
|
||||
|
||||
// Setting this flag causes the function to create the last entry in the path
|
||||
// ONLY if it doesn't already exist. If it does exist the function will return
|
||||
// kPathCreateDirErrDirExistes.
|
||||
const unsigned kPathCreateDirFlagCreateNew = 1<<1;
|
||||
|
||||
|
||||
EPathCreateDirError PathCreateDirectory (
|
||||
const wchar_t path[],
|
||||
unsigned flags
|
||||
);
|
||||
|
||||
|
||||
|
||||
// Get directory
|
||||
void PathGetProgramDirectory (
|
||||
wchar_t * dst,
|
||||
unsigned dstChars
|
||||
);
|
||||
|
||||
|
||||
// Product and user-specific common directory locations
|
||||
void PathGetUserDirectory (
|
||||
wchar_t * dst,
|
||||
unsigned dstChars
|
||||
);
|
||||
void PathGetLogDirectory (
|
||||
wchar_t * dst,
|
||||
unsigned dstChars
|
||||
);
|
||||
void PathGetInitDirectory (
|
||||
wchar_t * dst,
|
||||
wchar_t * dst,
|
||||
unsigned dstChars
|
||||
);
|
||||
|
||||
@ -206,13 +160,13 @@ void PathGetInitDirectory (
|
||||
// you may send nil for any fields you don't care about
|
||||
void PathSplitEmail (
|
||||
const wchar_t emailAddr[],
|
||||
wchar_t * user,
|
||||
wchar_t * user,
|
||||
unsigned userChars,
|
||||
wchar_t * domain,
|
||||
wchar_t * domain,
|
||||
unsigned domainChars,
|
||||
wchar_t * tld,
|
||||
wchar_t * tld,
|
||||
unsigned tldChars,
|
||||
wchar_t * subDomains, // (wchar_t *)&subs --> wchar_t subs[16][256];
|
||||
wchar_t * subDomains, // (wchar_t *)&subs --> wchar_t subs[16][256];
|
||||
unsigned subDomainChars, // arrsize(subs[0]) --> 256
|
||||
unsigned subDomainCount // arrsize(subs) --> 16
|
||||
);
|
||||
|
Reference in New Issue
Block a user