mirror of
https://foundry.openuru.org/gitblit/r/CWE-ou-minkata.git
synced 2025-07-14 02:27:40 -04:00
Finish deprecation of pnUtPath
This commit is contained in:
@ -49,75 +49,46 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
#include "HeadSpin.h"
|
||||
#include "hsExceptions.h"
|
||||
|
||||
#ifdef HS_BUILD_FOR_WIN32
|
||||
|
||||
#include "hsWindows.h"
|
||||
#include <sstream>
|
||||
|
||||
|
||||
//// ParseDirectory //////////////////////////////////////////////////////////
|
||||
|
||||
bool pfConsoleDirSrc::ParseDirectory(const plFileName& path, const plString& mask /* = L"*.*" */)
|
||||
bool pfConsoleDirSrc::ParseDirectory(const plFileName& path, const char* mask /* = L"*.*" */)
|
||||
{
|
||||
WIN32_FIND_DATAW findInfo;
|
||||
HANDLE handle;
|
||||
|
||||
hsAssert( fEngine != nil, "Cannot do a dir execute without an engine!" );
|
||||
|
||||
handle = FindFirstFileW(plFileName::Join(path, mask).AsString().ToWchar(), &findInfo);
|
||||
if (handle == INVALID_HANDLE_VALUE)
|
||||
return false;
|
||||
|
||||
do
|
||||
std::vector<plFileName> files = plFileSystem::ListDir(path, mask);
|
||||
for (auto iter = files.begin(); iter != files.end(); ++iter)
|
||||
{
|
||||
if (!( findInfo.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY))
|
||||
plFileName name = iter->GetFileName();
|
||||
if (AlreadyProcessedFile(path, name))
|
||||
continue;
|
||||
AddProcessedFile(path, name);
|
||||
if (!fEngine->ExecuteFile(*iter))
|
||||
{
|
||||
plFileName name = plString::FromWchar(findInfo.cFileName);
|
||||
plFileName fileAndPath = plFileName::Join(path, name);
|
||||
if (AlreadyProcessedFile(path, name))
|
||||
continue;
|
||||
AddProcessedFile(path, name);
|
||||
if (!fEngine->ExecuteFile(fileAndPath))
|
||||
{
|
||||
// Change the following line once we have a better way of reporting
|
||||
// errors in the parsing
|
||||
std::wstringstream error;
|
||||
std::wstringstream caption;
|
||||
wchar_t* errorMsg = hsStringToWString(fEngine->GetErrorMsg());
|
||||
wchar_t* errorLine = hsStringToWString(fEngine->GetLastErrorLine());
|
||||
// Change the following line once we have a better way of reporting
|
||||
// errors in the parsing
|
||||
plStringStream error, caption;
|
||||
|
||||
caption << L"Error parsing " << findInfo.cFileName;
|
||||
error << errorMsg << L":\n\nCommand: '" << errorLine << L"'\n\nPress OK to continue parsing files.";
|
||||
caption << "Error parsing " << name.AsString();
|
||||
error << fEngine->GetErrorMsg() << ":\n\nCommand: '" << fEngine->GetLastErrorLine()
|
||||
<< "'\n\nPress OK to continue parsing files.";
|
||||
|
||||
hsMessageBox(error.str().c_str(), caption.str().c_str(), hsMessageBoxNormal);
|
||||
hsMessageBox(error.GetString().c_str(), caption.GetString().c_str(), hsMessageBoxNormal);
|
||||
|
||||
delete [] errorMsg;
|
||||
delete [] errorLine;
|
||||
|
||||
FindClose(handle);
|
||||
SetCheckProcessedFiles(true);
|
||||
return false;
|
||||
}
|
||||
SetCheckProcessedFiles(true);
|
||||
return false;
|
||||
}
|
||||
} while (FindNextFileW(handle, &findInfo) != 0);
|
||||
}
|
||||
|
||||
FindClose(handle);
|
||||
SetCheckProcessedFiles(true);
|
||||
return true;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
#error This needs to be implemented for this platform!!!!
|
||||
|
||||
#endif
|
||||
|
||||
void pfConsoleDirSrc::ResetProcessedFiles()
|
||||
{
|
||||
int i;
|
||||
for(i=0;i<fProcessedFiles.size(); i++)
|
||||
delete fProcessedFiles[i];
|
||||
fProcessedFiles.clear();
|
||||
fProcessedFiles.clear();
|
||||
}
|
||||
|
||||
//
|
||||
|
@ -71,14 +71,14 @@ class pfConsoleDirSrc
|
||||
{
|
||||
plFileName fPath;
|
||||
plFileName fFile;
|
||||
FileName() : fPath(""), fFile("") {}
|
||||
FileName() {}
|
||||
FileName(const plFileName& p, const plFileName& f) : fPath(p), fFile(f) {}
|
||||
};
|
||||
std::vector<FileName*> fProcessedFiles; // list of init files we've already executed
|
||||
bool fCheckProcessedFiles; // set to check and skip files init files we've already executed
|
||||
public:
|
||||
pfConsoleDirSrc(pfConsoleEngine *engine) : fCheckProcessedFiles(false) { fEngine = engine; }
|
||||
pfConsoleDirSrc(pfConsoleEngine *engine, const plFileName& path, const plString& mask = "*.ini")
|
||||
pfConsoleDirSrc(pfConsoleEngine *engine, const plFileName& path, const char* mask = "*.ini")
|
||||
: fCheckProcessedFiles(false)
|
||||
{
|
||||
fEngine = engine;
|
||||
@ -88,7 +88,7 @@ class pfConsoleDirSrc
|
||||
~pfConsoleDirSrc() { ResetProcessedFiles(); }
|
||||
|
||||
// Steps through the given directory and executes all files with the console engine
|
||||
bool ParseDirectory(const plFileName& path, const plString& mask = "*.*");
|
||||
bool ParseDirectory(const plFileName& path, const char* mask = "*.*");
|
||||
|
||||
void ResetProcessedFiles();
|
||||
bool AlreadyProcessedFile(const plFileName& path, const plFileName& file);
|
||||
|
@ -305,7 +305,7 @@ static bool DumpSpecificMsgInfo(plMessage* msg, plString& info)
|
||||
|
||||
case plClientMsg::kLoadAgeKeys:
|
||||
case plClientMsg::kReleaseAgeKeys:
|
||||
info += plString::Format(" - Age: %s", clientMsg->GetAgeName());
|
||||
info += plString::Format(" - Age: %s", clientMsg->GetAgeName().c_str());
|
||||
break;
|
||||
}
|
||||
return true;
|
||||
|
Reference in New Issue
Block a user