Browse Source

Remove hsFiles in favor of plFilesystem stuff

Michael Hansen 12 years ago
parent
commit
2c028c4b07
  1. 13
      Sources/Plasma/Apps/plClient/plClient.cpp
  2. 47
      Sources/Plasma/Apps/plFileEncrypt/main.cpp
  3. 56
      Sources/Plasma/Apps/plFileSecure/main.cpp
  4. 1
      Sources/Plasma/Apps/plPageInfo/plPageInfo.cpp
  5. 33
      Sources/Plasma/Apps/plPythonPack/PythonInterface.cpp
  6. 8
      Sources/Plasma/Apps/plPythonPack/PythonInterface.h
  7. 166
      Sources/Plasma/Apps/plPythonPack/main.cpp
  8. 1
      Sources/Plasma/Apps/plUruLauncher/Main.cpp
  9. 43
      Sources/Plasma/CoreLib/plFileSystem.cpp
  10. 5
      Sources/Plasma/CoreLib/plFileSystem.h
  11. 27
      Sources/Plasma/FeatureLib/pfConsole/pfConsoleCommands.cpp
  12. 2
      Sources/Plasma/FeatureLib/pfConsole/pfConsoleCommandsNet.cpp
  13. 14
      Sources/Plasma/FeatureLib/pfLocalizationMgr/pfLocalizationDataMgr.cpp
  14. 1
      Sources/Plasma/FeatureLib/pfPython/plPythonPack.cpp
  15. 1
      Sources/Plasma/PubUtilLib/plAgeDescription/plAgeDescription.cpp
  16. 1
      Sources/Plasma/PubUtilLib/plAgeDescription/plAgeManifest.cpp
  17. 1
      Sources/Plasma/PubUtilLib/plAudio/plWin32StreamingSound.cpp
  18. 1
      Sources/Plasma/PubUtilLib/plAudioCore/plAudioFileReader.cpp
  19. 1
      Sources/Plasma/PubUtilLib/plAudioCore/plSoundBuffer.cpp
  20. 10
      Sources/Plasma/PubUtilLib/plFile/CMakeLists.txt
  21. 182
      Sources/Plasma/PubUtilLib/plFile/hsFiles.cpp
  22. 141
      Sources/Plasma/PubUtilLib/plFile/hsFiles.h
  23. 145
      Sources/Plasma/PubUtilLib/plFile/hsFiles_Unix.cpp
  24. 320
      Sources/Plasma/PubUtilLib/plFile/hsFiles_Win.cpp
  25. 16
      Sources/Plasma/PubUtilLib/plFile/plStreamSource.cpp
  26. 2
      Sources/Plasma/PubUtilLib/plGImage/plFont.cpp
  27. 2
      Sources/Plasma/PubUtilLib/plGImage/plFont.h
  28. 35
      Sources/Plasma/PubUtilLib/plGImage/plFontCache.cpp
  29. 7
      Sources/Plasma/PubUtilLib/plGImage/plFontCache.h
  30. 27
      Sources/Plasma/PubUtilLib/plGImage/plWinFontCache.cpp
  31. 5
      Sources/Plasma/PubUtilLib/plGImage/plWinFontCache.h
  32. 12
      Sources/Plasma/PubUtilLib/plNetClient/plNetLinkingMgr.cpp
  33. 2
      Sources/Plasma/PubUtilLib/plNetClient/plNetLinkingMgr.h
  34. 1
      Sources/Plasma/PubUtilLib/plNetClientRecorder/plNetClientRecorder.cpp
  35. 1
      Sources/Plasma/PubUtilLib/plResMgr/plRegistryNode.cpp
  36. 10
      Sources/Plasma/PubUtilLib/plResMgr/plResManager.cpp
  37. 1
      Sources/Plasma/PubUtilLib/plSDL/plSDLParser.cpp
  38. 28
      Sources/Plasma/PubUtilLib/plStatusLog/plStatusLog.cpp
  39. 1
      Sources/Tools/MaxComponent/Pch.h
  40. 15
      Sources/Tools/MaxComponent/plGUIComponents.cpp
  41. 13
      Sources/Tools/MaxComponent/plMiscComponents.cpp
  42. 29
      Sources/Tools/MaxComponent/plResponderLink.cpp
  43. 54
      Sources/Tools/MaxExport/plExportDlg.cpp
  44. 1
      Sources/Tools/MaxMain/Pch.h
  45. 1
      Sources/Tools/MaxMain/main.cpp
  46. 46
      Sources/Tools/MaxMain/plAgeDescInterface.cpp
  47. 2
      Sources/Tools/MaxMain/plAgeDescInterface.h
  48. 18
      Sources/Tools/MaxMain/plPythonMgr.cpp
  49. 2
      Sources/Tools/MaxMain/plPythonMgr.h
  50. 2
      Sources/Tools/MaxSceneViewer/SceneSync.cpp
  51. 23
      Sources/Tools/plResBrowser/plResBrowserWndProc.cpp

13
Sources/Plasma/Apps/plClient/plClient.cpp

@ -83,7 +83,6 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "pfConsole/pfConsoleDirSrc.h" #include "pfConsole/pfConsoleDirSrc.h"
#include "plScene/plPageTreeMgr.h" #include "plScene/plPageTreeMgr.h"
#include "plScene/plVisMgr.h" #include "plScene/plVisMgr.h"
#include "plFile/hsFiles.h"
#include "pfKI/pfKI.h" #include "pfKI/pfKI.h"
@ -1635,19 +1634,17 @@ void plClient::IPatchGlobalAgeFiles( void )
void plClient::InitDLLs() void plClient::InitDLLs()
{ {
hsStatusMessage("Init dlls client\n"); hsStatusMessage("Init dlls client\n");
char str[255];
typedef void (*PInitGlobalsFunc) (hsResMgr *, plFactory *, plTimerCallbackManager *, plTimerShare*, typedef void (*PInitGlobalsFunc) (hsResMgr *, plFactory *, plTimerCallbackManager *, plTimerShare*,
plNetClientApp*); plNetClientApp*);
hsFolderIterator modDllFolder("ModDLL\\"); std::vector<plFileName> dlls = plFileSystem::ListDir("ModDLL", "*.dll");
while (modDllFolder.NextFileSuffix(".dll")) for (auto iter = dlls.begin(); iter != dlls.end(); ++iter)
{ {
modDllFolder.GetPathAndName(str); HMODULE hMod = LoadLibraryW(iter->AsString().ToWchar());
HMODULE hMod = LoadLibrary(str);
if (hMod) if (hMod)
{ {
PInitGlobalsFunc initGlobals = (PInitGlobalsFunc)GetProcAddress(hMod, "InitGlobals"); PInitGlobalsFunc initGlobals = (PInitGlobalsFunc)GetProcAddress(hMod, "InitGlobals");
initGlobals(hsgResMgr::ResMgr(), plFactory::GetTheFactory(), plgTimerCallbackMgr::Mgr(), (*initGlobals)(hsgResMgr::ResMgr(), plFactory::GetTheFactory(), plgTimerCallbackMgr::Mgr(),
hsTimer::GetTheTimer(), plNetClientApp::GetInstance()); hsTimer::GetTheTimer(), plNetClientApp::GetInstance());
fLoadedDLLs.Append(hMod); fLoadedDLLs.Append(hMod);
} }
@ -2495,7 +2492,7 @@ void plClient::IOnAsyncInitComplete () {
// run fni in the Aux Init dir // run fni in the Aux Init dir
if (fpAuxInitDir) if (fpAuxInitDir)
{ {
dirSrc.ParseDirectory(fpAuxInitDir, "net*.fni"); // connect to net first dirSrc.ParseDirectory(fpAuxInitDir, "net*.fni"); // connect to net first
dirSrc.ParseDirectory(fpAuxInitDir, "*.fni"); dirSrc.ParseDirectory(fpAuxInitDir, "*.fni");
} }

47
Sources/Plasma/Apps/plFileEncrypt/main.cpp

@ -39,25 +39,25 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
Mead, WA 99021 Mead, WA 99021
*==LICENSE==*/ *==LICENSE==*/
#include "plFile/hsFiles.h"
#include "plFile/plEncryptedStream.h" #include "plFile/plEncryptedStream.h"
#include "plProduct.h" #include "plProduct.h"
void EncryptFiles(const char* dir, const char* ext, bool encrypt); void EncryptFiles(const plFileName& dir, const char* ext, bool encrypt);
void print_version() { void print_version() {
printf("%s\n\n", plProduct::ProductString().c_str()); puts(plProduct::ProductString().c_str());
puts("");
} }
void print_help() { void print_help() {
printf("plFileEncrypt - Encrypts and Decrypts Uru Files.\n\n"); puts("plFileEncrypt - Encrypts and Decrypts Uru Files.\n");
print_version(); print_version();
printf("Usage: plFileEncrypt \t[(encrypt|-e)|(decrypt|-d|)|(--help|-h|-?|/h)|(-v)]\n"); puts("Usage: plFileEncrypt \t[(encrypt|-e)|(decrypt|-d|)|(--help|-h|-?|/h)|(-v)]");
printf("\tencrypt|-e\t - Encrypts All .age, .fni, .ini, .csv, and .sdl files in the current folder.\n"); puts("\tencrypt|-e\t - Encrypts All .age, .fni, .ini, .csv, and .sdl files in the current folder.");
printf("\tdecrypt|-d\t - Decrypts All .age, .fni, .ini, .csv, and .sdl files in the current folder.\n"); puts("\tdecrypt|-d\t - Decrypts All .age, .fni, .ini, .csv, and .sdl files in the current folder.");
printf("\t--help|-h|-?|/h\t - Prints Help. This Screen.\n"); puts("\t--help|-h|-?|/h\t - Prints Help. This Screen.");
printf("\t-v|--version\t - Prints build version information\n"); puts("\t-v|--version\t - Prints build version information");
} }
int main(int argc, char *argv[]) int main(int argc, char *argv[])
@ -87,37 +87,34 @@ int main(int argc, char *argv[])
} }
else if (ARGCMP("-v") || ARGCMP("--version")) else if (ARGCMP("-v") || ARGCMP("--version"))
{ {
print_version(); print_version();
return 0; return 0;
} }
} }
#undef ARGCMP #undef ARGCMP
EncryptFiles(dir, ".age", encrypt); EncryptFiles(dir, "*.age", encrypt);
EncryptFiles(dir, ".fni", encrypt); EncryptFiles(dir, "*.fni", encrypt);
EncryptFiles(dir, ".ini", encrypt); EncryptFiles(dir, "*.ini", encrypt);
EncryptFiles(dir, ".sdl", encrypt); EncryptFiles(dir, "*.sdl", encrypt);
EncryptFiles(dir, ".csv", encrypt); EncryptFiles(dir, "*.csv", encrypt);
return 0; return 0;
} }
void EncryptFiles(const char* dir, const char* ext, bool encrypt) void EncryptFiles(const plFileName& dir, const char* ext, bool encrypt)
{ {
char filePath[256]; std::vector<plFileName> files = plFileSystem::ListDir(dir, ext);
for (auto iter = files.begin(); iter != files.end(); ++iter)
hsFolderIterator folder(dir);
while (folder.NextFileSuffix(ext))
{ {
folder.GetPathAndName(filePath);
if (encrypt) if (encrypt)
{ {
printf("encrypting: %s\n", folder.GetFileName()); printf("encrypting: %s\n", iter->GetFileName().c_str());
plEncryptedStream::FileEncrypt(filePath); plEncryptedStream::FileEncrypt(*iter);
} }
else else
{ {
printf("decrypting: %s\n", folder.GetFileName()); printf("decrypting: %s\n", iter->GetFileName().c_str());
plEncryptedStream::FileDecrypt(filePath); plEncryptedStream::FileDecrypt(*iter);
} }
} }
} }

56
Sources/Plasma/Apps/plFileSecure/main.cpp

@ -39,7 +39,6 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
Mead, WA 99021 Mead, WA 99021
*==LICENSE==*/ *==LICENSE==*/
#include "plFile/hsFiles.h"
#include "plFile/plSecureStream.h" #include "plFile/plSecureStream.h"
#include "plProduct.h" #include "plProduct.h"
@ -48,26 +47,27 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include <string> #include <string>
void print_version() { void print_version() {
printf("%s\n\n", plProduct::ProductString().c_str()); puts(plProduct::ProductString().c_str());
puts("");
} }
void print_help() { void print_help() {
printf("plFileSecure - Secures Uru files and generates encryption.key files.\n\n"); puts ("plFileSecure - Secures Uru files and generates encryption.key files.\n");
print_version(); print_version();
printf("Usage:\n"); puts ("Usage:");
printf("\tplFileSecure (<directory> <ext>)|[/generate /default]\n"); puts ("\tplFileSecure (<directory> <ext>)|[/generate /default]");
printf("\n"); puts ("");
printf("<directory> <ext> : The directory and extension of files to secure. Cannot\n"); puts ("<directory> <ext> : The directory and extension of files to secure. Cannot");
printf(" be used with /generate. Uses the %s file in\n", plSecureStream::kKeyFilename); printf(" be used with /generate. Uses the %s file in\n", plSecureStream::kKeyFilename);
printf(" the current directory (or default key if no file exists)\n"); puts (" the current directory (or default key if no file exists)");
printf("/generate : Generates a random key and writes it to a %s\n", plSecureStream::kKeyFilename); printf("/generate : Generates a random key and writes it to a %s\n", plSecureStream::kKeyFilename);
printf(" file in the current directory. Cannot be used with\n"); puts (" file in the current directory. Cannot be used with");
printf(" <directory> <ext>\n"); puts (" <directory> <ext>");
printf("/default : If used with /generate, creates a %s file\n", plSecureStream::kKeyFilename); printf("/default : If used with /generate, creates a %s file\n", plSecureStream::kKeyFilename);
printf(" with the default key. If used with <directory> <ext>, it\n"); puts (" with the default key. If used with <directory> <ext>, it");
printf(" secures with the default key instead of the\n"); puts (" secures with the default key instead of the");
printf(" %s file's key\n", plSecureStream::kKeyFilename); printf(" %s file's key\n", plSecureStream::kKeyFilename);
printf("\n"); puts ("");
} }
void GenerateKey(bool useDefault) void GenerateKey(bool useDefault)
@ -105,16 +105,13 @@ void GenerateKey(bool useDefault)
out.Close(); out.Close();
} }
void SecureFiles(std::string dir, std::string ext, uint32_t* key) void SecureFiles(const plFileName& dir, const plString& ext, uint32_t* key)
{ {
char filePath[256]; std::vector<plFileName> files = plFileSystem::ListDir(dir, ext.c_str());
for (auto iter = files.begin(); iter != files.end(); ++iter)
hsFolderIterator folder(dir.c_str());
while (folder.NextFileSuffix(ext.c_str()))
{ {
folder.GetPathAndName(filePath); printf("securing: %s\n", iter->GetFileName());
printf("securing: %s\n", folder.GetFileName()); plSecureStream::FileEncrypt(*iter, key);
plSecureStream::FileEncrypt(filePath, key);
} }
} }
@ -122,8 +119,8 @@ int main(int argc, char *argv[])
{ {
bool generatingKey = false; bool generatingKey = false;
bool useDefault = false; bool useDefault = false;
std::string directory; plFileName directory;
std::string ext; plString ext;
if (argc > 1) if (argc > 1)
{ {
@ -163,9 +160,9 @@ int main(int argc, char *argv[])
else else
{ {
// else it is a directory or extension // else it is a directory or extension
if (directory == "") if (!directory.IsValid())
directory = argv[i]; directory = argv[i];
else if (ext == "") else if (ext.IsEmpty())
ext = argv[i]; ext = argv[i];
else else
{ {
@ -175,7 +172,7 @@ int main(int argc, char *argv[])
} }
} }
if (generatingKey && ((directory != "") || (ext != ""))) if (generatingKey && ((directory.IsValid()) || (!ext.IsEmpty())))
{ {
print_help(); print_help();
return 0; return 0;
@ -193,8 +190,11 @@ int main(int argc, char *argv[])
return 0; return 0;
} }
if (ext[0] != '.') // Make sure ext is a real pattern, or we won't find anything
ext = "." + ext; // tack on the dot if necessary if (ext.CharAt(0) == '.')
ext = "*" + ext;
else if (ext.CharAt(0) != '*')
ext = "*." + ext;
if (useDefault) if (useDefault)
SecureFiles(directory, ext, nil); SecureFiles(directory, ext, nil);

1
Sources/Plasma/Apps/plPageInfo/plPageInfo.cpp

@ -41,7 +41,6 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
*==LICENSE==*/ *==LICENSE==*/
#include "hsTimer.h" #include "hsTimer.h"
#include "plFile/hsFiles.h"
#include "plResMgr/plResManager.h" #include "plResMgr/plResManager.h"
#include "plResMgr/plResMgrSettings.h" #include "plResMgr/plResMgrSettings.h"

33
Sources/Plasma/Apps/plPythonPack/PythonInterface.cpp

@ -45,10 +45,11 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "eval.h" #include "eval.h"
#include "marshal.h" #include "marshal.h"
#include "cStringIO.h" #include "cStringIO.h"
#include "plFileSystem.h"
static PyObject* stdFile; // python object of the stdout and err file static PyObject* stdFile; // python object of the stdout and err file
void PythonInterface::initPython(std::string rootDir) void PythonInterface::initPython(const plFileName& rootDir)
{ {
// if haven't been initialized then do it // if haven't been initialized then do it
if ( Py_IsInitialized() == 0 ) if ( Py_IsInitialized() == 0 )
@ -77,27 +78,27 @@ void PythonInterface::initPython(std::string rootDir)
PyObject* sys_dict = PyModule_GetDict(sysmod); PyObject* sys_dict = PyModule_GetDict(sysmod);
if (stdFile != nil) if (stdFile != nil)
{ {
PyDict_SetItemString(sys_dict,"stdout", stdFile); PyDict_SetItemString(sys_dict, "stdout", stdFile);
PyDict_SetItemString(sys_dict,"stderr", stdFile); PyDict_SetItemString(sys_dict, "stderr", stdFile);
} }
// NOTE: we will reset the path to not include paths // NOTE: we will reset the path to not include paths
// ...that Python may have found in the registery // ...that Python may have found in the registery
PyObject* path_list = PyList_New(0); PyObject* path_list = PyList_New(0);
printf("Setting up include dirs:\n"); printf("Setting up include dirs:\n");
printf("%s\n",rootDir.c_str()); printf("%s\n", rootDir.AsString().c_str());
PyObject* more_path = PyString_FromString(rootDir.c_str()); PyObject* more_path = PyString_FromString(rootDir.AsString().c_str());
PyList_Append(path_list, more_path); PyList_Append(path_list, more_path);
// make sure that our plasma libraries are gotten before the system ones // make sure that our plasma libraries are gotten before the system ones
std::string temp = rootDir + "plasma"; plFileName temp = plFileName::Join(rootDir, "plasma");
printf("%s\n",temp.c_str()); printf("%s\n", temp.AsString().c_str());
PyObject* more_path3 = PyString_FromString(temp.c_str()); PyObject* more_path3 = PyString_FromString(temp.AsString().c_str());
PyList_Append(path_list, more_path3); PyList_Append(path_list, more_path3);
temp = rootDir + "system"; temp = plFileName::Join(rootDir, "system");
printf("%s\n\n",temp.c_str()); printf("%s\n\n", temp.AsString().c_str());
PyObject* more_path2 = PyString_FromString("system"); PyObject* more_path2 = PyString_FromString("system");
PyList_Append(path_list, more_path2); PyList_Append(path_list, more_path2);
// set the path to be this one // set the path to be this one
PyDict_SetItemString(sys_dict,"path",path_list); PyDict_SetItemString(sys_dict, "path", path_list);
Py_DECREF(sysmod); Py_DECREF(sysmod);
@ -106,7 +107,7 @@ void PythonInterface::initPython(std::string rootDir)
// initialized++; // initialized++;
} }
void PythonInterface::addPythonPath(std::string path) void PythonInterface::addPythonPath(const plFileName& path)
{ {
PyObject* sysmod = PyImport_ImportModule("sys"); PyObject* sysmod = PyImport_ImportModule("sys");
if (sysmod != NULL) if (sysmod != NULL)
@ -114,8 +115,8 @@ void PythonInterface::addPythonPath(std::string path)
PyObject* sys_dict = PyModule_GetDict(sysmod); PyObject* sys_dict = PyModule_GetDict(sysmod);
PyObject* path_list = PyDict_GetItemString(sys_dict, "path"); PyObject* path_list = PyDict_GetItemString(sys_dict, "path");
printf("Adding path %s\n", path.c_str()); printf("Adding path %s\n", path.AsString().c_str());
PyObject* more_path = PyString_FromString(path.c_str()); PyObject* more_path = PyString_FromString(path.AsString().c_str());
PyList_Append(path_list, more_path); PyList_Append(path_list, more_path);
Py_DECREF(sysmod); Py_DECREF(sysmod);
@ -138,9 +139,9 @@ void PythonInterface::finiPython()
// //
// PURPOSE : run a python string in a specific module name // PURPOSE : run a python string in a specific module name
// //
PyObject* PythonInterface::CompileString(const char *command, const char* filename) PyObject* PythonInterface::CompileString(const char *command, const plFileName& filename)
{ {
PyObject* pycode = Py_CompileString(command, filename, Py_file_input); PyObject* pycode = Py_CompileString(command, filename.AsString().c_str(), Py_file_input);
return pycode; return pycode;
} }

8
Sources/Plasma/Apps/plPythonPack/PythonInterface.h

@ -44,14 +44,16 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include <string> #include <string>
class plFileName;
namespace PythonInterface namespace PythonInterface
{ {
void initPython(std::string rootDir); void initPython(const plFileName& rootDir);
void finiPython(); void finiPython();
// So the Python packer can add extra paths // So the Python packer can add extra paths
void addPythonPath(std::string dir); void addPythonPath(const plFileName& dir);
PyObject* CompileString(const char *command, const char* filename); PyObject* CompileString(const char *command, const plFileName& filename);
bool DumpObject(PyObject* pyobj, char** pickle, int32_t* size); bool DumpObject(PyObject* pyobj, char** pickle, int32_t* size);
int getOutputAndReset(char** line=nil); int getOutputAndReset(char** line=nil);
PyObject* CreateModule(const char* module); PyObject* CreateModule(const char* module);

166
Sources/Plasma/Apps/plPythonPack/main.cpp

@ -42,7 +42,6 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "PythonInterface.h" #include "PythonInterface.h"
#include "hsStream.h" #include "hsStream.h"
#include "plFile/hsFiles.h"
#include <vector> #include <vector>
#include <string> #include <string>
@ -71,25 +70,24 @@ static const char* kPackFileName = "python.pak";
#endif #endif
static char* glueFile = (char*)kGlueFile; static char* glueFile = (char*)kGlueFile;
void WritePythonFile(std::string fileName, std::string path, hsStream *s) void WritePythonFile(const plFileName &fileName, const plFileName &path, hsStream *s)
{ {
hsUNIXStream pyStream, glueStream; hsUNIXStream pyStream, glueStream;
std::string filePath; plFileName filePath;
size_t filestart = fileName.find_last_of('.'); size_t filestart = fileName.AsString().FindLast('.');
if(filestart != std::string::npos) if (filestart >= 0)
filePath = fileName.substr(filestart+1, std::string::npos); filePath = fileName.AsString().Substr(filestart+1);
else else
filePath = fileName; filePath = fileName;
filePath += ".py"; filePath = plFileName::Join(path, filePath + ".py");
filePath = path + filePath;
if (!pyStream.Open(filePath.c_str()) || !glueStream.Open(glueFile)) if (!pyStream.Open(filePath) || !glueStream.Open(glueFile))
{ {
printf("Unable to open path %s, ",filePath.c_str()); printf("Unable to open path %s, ", filePath.AsString().c_str());
return; return;
} }
printf("==Packing %s, ",fileName.c_str()); printf("==Packing %s, ", fileName.AsString().c_str());
pyStream.FastFwd(); pyStream.FastFwd();
uint32_t pyFileSize = pyStream.GetPosition(); uint32_t pyFileSize = pyStream.GetPosition();
@ -124,20 +122,20 @@ void WritePythonFile(std::string fileName, std::string path, hsStream *s)
} }
// import the module first, to make packages work correctly // import the module first, to make packages work correctly
PyImport_ImportModule(fileName.c_str()); PyImport_ImportModule(fileName.AsString().c_str());
PyObject* pythonCode = PythonInterface::CompileString(code, fileName.c_str()); PyObject* pythonCode = PythonInterface::CompileString(code, fileName);
if (pythonCode) if (pythonCode)
{ {
// we need to find out if this is PythonFile module // we need to find out if this is PythonFile module
// create a module name... with the '.' as an X // create a module name... with the '.' as an X
// and create a python file name that is without the ".py" // and create a python file name that is without the ".py"
PyObject* fModule = PythonInterface::CreateModule(fileName.c_str()); PyObject* fModule = PythonInterface::CreateModule(fileName.AsString().c_str());
// run the code // run the code
if (PythonInterface::RunPYC(pythonCode, fModule) ) if (PythonInterface::RunPYC(pythonCode, fModule) )
{ {
// set the name of the file (in the global dictionary of the module) // set the name of the file (in the global dictionary of the module)
PyObject* dict = PyModule_GetDict(fModule); PyObject* dict = PyModule_GetDict(fModule);
PyObject* pfilename = PyString_FromString(fileName.c_str()); PyObject* pfilename = PyString_FromString(fileName.AsString().c_str());
PyDict_SetItemString(dict, "glue_name", pfilename); PyDict_SetItemString(dict, "glue_name", pfilename);
// next we need to: // next we need to:
// - create instance of class // - create instance of class
@ -167,7 +165,7 @@ void WritePythonFile(std::string fileName, std::string path, hsStream *s)
// else // else
// skip the CRs // skip the CRs
} }
pythonCode = PythonInterface::CompileString(code, fileName.c_str()); pythonCode = PythonInterface::CompileString(code, fileName);
hsAssert(pythonCode,"Not sure why this didn't compile the second time???"); hsAssert(pythonCode,"Not sure why this didn't compile the second time???");
printf("an import file "); printf("an import file ");
} }
@ -227,23 +225,15 @@ void WritePythonFile(std::string fileName, std::string path, hsStream *s)
glueStream.Close(); glueStream.Close();
} }
void FindFiles(std::vector<std::string> &filenames, std::vector<std::string> &pathnames, const char* path) void FindFiles(std::vector<plFileName> &filenames, std::vector<plFileName> &pathnames, const plFileName& path)
{ {
// Get the names of all the python files // Get the names of all the python files
hsFolderIterator folder; std::vector<plFileName> pys = plFileSystem::ListDir(path, "*.py");
// if there is a path... set it for (auto iter = pys.begin(); iter != pys.end(); ++iter)
if ( path )
folder.SetPath(path);
while (folder.NextFileSuffix(".py"))
{ {
const char *fileName = folder.GetFileName(); filenames.push_back(iter->GetFileName());
filenames.push_back(fileName); pathnames.push_back(path);
if ( path )
pathnames.push_back(path);
else
pathnames.push_back("");
} }
} }
@ -260,22 +250,13 @@ std::string ToLowerCase(std::string str)
return retVal; return retVal;
} }
void FindSubDirs(std::vector<std::string> &dirnames, const char *path) void FindSubDirs(std::vector<plFileName> &dirnames, const plFileName &path)
{ {
hsFolderIterator folder; std::vector<plFileName> subdirs = plFileSystem::ListSubdirs(path);
if (path) for (auto iter = subdirs.begin(); iter != subdirs.end(); ++iter) {
folder.SetPath(path); plString name = iter->GetFileName();
if (name.CompareI("system") != 0 && name.CompareI("plasma") != 0)
while (folder.NextFile()) dirnames.push_back(name);
{
if (folder.IsDirectory())
{
std::string dirName = folder.GetFileName();
if ((dirName != ".")&&(dirName != "..")&&(ToLowerCase(dirName) != "system") && (ToLowerCase(dirName) != "plasma"))
{
dirnames.push_back(dirName);
}
}
} }
} }
@ -343,66 +324,62 @@ std::string ConcatDirs(std::string fullPath, std::string partialPath)
return retVal; return retVal;
} }
void FindPackages(std::vector<std::string>& fileNames, std::vector<std::string>& pathNames, const char* path, std::string parent_package="") void FindPackages(std::vector<plFileName>& fileNames, std::vector<plFileName>& pathNames, const plFileName& path, const plString& parent_package="")
{ {
std::vector<std::string> packages; std::vector<plFileName> packages;
FindSubDirs(packages, path); FindSubDirs(packages, path);
for (int i = 0; i < packages.size(); i++) for (int i = 0; i < packages.size(); i++)
{ {
std::string packageName; plString packageName;
if(!parent_package.empty()) if (!parent_package.IsEmpty())
packageName = parent_package + "."; packageName = parent_package + ".";
packageName += packages[i]; packageName += packages[i].AsString();
std::vector<std::string> packageFileNames; std::vector<plFileName> packageFileNames;
std::vector<std::string> packagePathNames; std::vector<plFileName> packagePathNames;
std::string packagePath = path; plFileName packagePath = plFileName::Join(path, packages[i]);
packagePath += "/" + packages[i]; FindFiles(packageFileNames, packagePathNames, packagePath);
FindFiles(packageFileNames, packagePathNames, packagePath.c_str());
for (int j = 0; j < packageFileNames.size(); j++) { for (int j = 0; j < packageFileNames.size(); j++) {
fileNames.push_back(packageName+"."+packageFileNames[j]); fileNames.push_back(packageName+"."+packageFileNames[j].AsString());
pathNames.push_back(packagePathNames[j]+"/"); pathNames.push_back(packagePathNames[j]);
} }
FindPackages(fileNames, pathNames, packagePath.c_str(), packageName); FindPackages(fileNames, pathNames, packagePath, packageName);
} }
} }
void PackDirectory(std::string dir, std::string rootPath, std::string pakName, std::vector<std::string>& extraDirs, bool packSysAndPlasma = false) void PackDirectory(const plFileName& dir, const plFileName& rootPath, const plFileName& pakName, std::vector<plFileName>& extraDirs, bool packSysAndPlasma = false)
{ {
// make sure the dir ends in a slash printf("\nCreating %s using the contents of %s\n", pakName.AsString().c_str(), dir.AsString().c_str());
dir = AdjustEndingSlash(dir,true); printf("Changing working directory to %s\n", rootPath.AsString().c_str());
if (!plFileSystem::SetCWD(rootPath))
printf("\nCreating %s using the contents of %s\n",pakName.c_str(),dir.c_str());
printf("Changing working directory to %s\n",rootPath.c_str());
if (chdir(rootPath.c_str()))
{ {
printf("ERROR: Directory change to %s failed for some reason\n",rootPath.c_str()); printf("ERROR: Directory change to %s failed for some reason\n", rootPath.AsString().c_str());
printf("Unable to continue with the packing of this directory, aborting...\n"); printf("Unable to continue with the packing of this directory, aborting...\n");
return; return;
} }
else else
printf("Directory changed to %s\n",rootPath.c_str()); printf("Directory changed to %s\n", rootPath.AsString().c_str());
std::vector<std::string> fileNames; std::vector<plFileName> fileNames;
std::vector<std::string> pathNames; std::vector<plFileName> pathNames;
FindFiles(fileNames,pathNames,dir.c_str()); FindFiles(fileNames, pathNames, dir);
FindPackages(fileNames,pathNames,dir.c_str()); FindPackages(fileNames, pathNames, dir);
if (packSysAndPlasma) if (packSysAndPlasma)
{ {
printf("Adding the system and plasma directories to this pack file\n"); printf("Adding the system and plasma directories to this pack file\n");
std::string tempPath; plFileName tempPath;
tempPath = dir + "system/"; tempPath = plFileName::Join(dir, "system");
FindFiles(fileNames,pathNames,tempPath.c_str()); FindFiles(fileNames, pathNames, tempPath);
FindPackages(fileNames,pathNames,tempPath.c_str()); FindPackages(fileNames, pathNames, tempPath);
tempPath = dir + "plasma/"; tempPath = plFileName::Join(dir, "plasma");
FindFiles(fileNames,pathNames,tempPath.c_str()); FindFiles(fileNames, pathNames, tempPath);
FindPackages(fileNames,pathNames,tempPath.c_str()); FindPackages(fileNames, pathNames, tempPath);
} }
// ok, we know how many files we're gonna pack, so make a fake index (we'll fill in later) // ok, we know how many files we're gonna pack, so make a fake index (we'll fill in later)
hsUNIXStream s; hsUNIXStream s;
if (!s.Open(pakName.c_str(), "wb")) if (!s.Open(pakName, "wb"))
return; return;
s.WriteLE32(fileNames.size()); s.WriteLE32(fileNames.size());
@ -410,13 +387,13 @@ void PackDirectory(std::string dir, std::string rootPath, std::string pakName, s
int i; int i;
for (i = 0; i < fileNames.size(); i++) for (i = 0; i < fileNames.size(); i++)
{ {
s.WriteSafeString(fileNames[i].c_str()); s.WriteSafeString(fileNames[i].AsString());
s.WriteLE32(0); s.WriteLE32(0);
} }
PythonInterface::initPython(rootPath); PythonInterface::initPython(rootPath);
for (i = 0; i < extraDirs.size(); i++) for (i = 0; i < extraDirs.size(); i++)
PythonInterface::addPythonPath(rootPath + extraDirs[i]); PythonInterface::addPythonPath(plFileName::Join(rootPath, extraDirs[i]));
// set to maximum optimization (includes removing __doc__ strings) // set to maximum optimization (includes removing __doc__ strings)
Py_OptimizeFlag = 2; Py_OptimizeFlag = 2;
@ -427,7 +404,7 @@ void PackDirectory(std::string dir, std::string rootPath, std::string pakName, s
for (i = 0; i < fileNames.size(); i++) for (i = 0; i < fileNames.size(); i++)
{ {
// strip '.py' from the file name // strip '.py' from the file name
std::string properFileName = fileNames[i].substr(0, fileNames[i].size()-3); plFileName properFileName = fileNames[i].StripFileExt();
uint32_t initialPos = s.GetPosition(); uint32_t initialPos = s.GetPosition();
WritePythonFile(properFileName, pathNames[i], &s); WritePythonFile(properFileName, pathNames[i], &s);
uint32_t endPos = s.GetPosition(); uint32_t endPos = s.GetPosition();
@ -438,7 +415,7 @@ void PackDirectory(std::string dir, std::string rootPath, std::string pakName, s
s.SetPosition(sizeof(uint32_t)); s.SetPosition(sizeof(uint32_t));
for (i = 0; i < fileNames.size(); i++) for (i = 0; i < fileNames.size(); i++)
{ {
s.WriteSafeString(fileNames[i].c_str()); s.WriteSafeString(fileNames[i].AsString());
s.WriteLE32(filePositions[i]); s.WriteLE32(filePositions[i]);
} }
@ -459,9 +436,7 @@ int main(int argc, char *argv[])
{ {
printf("The Python Pack Utility\n"); printf("The Python Pack Utility\n");
char buffer[MAXPATHLEN]; plFileName baseWorkingDir = plFileSystem::GetCWD();
getcwd(buffer, MAXPATHLEN);
std::string baseWorkingDir = buffer;
// are they asking for usage? // are they asking for usage?
if (argc == 2) if (argc == 2)
@ -482,26 +457,25 @@ int main(int argc, char *argv[])
return -1; return -1;
} }
std::vector<std::string> dirNames; std::vector<plFileName> dirNames;
std::string rootPath; plFileName rootPath;
if (argc == 1) if (argc == 1)
{ {
FindSubDirs(dirNames,nil); FindSubDirs(dirNames, "");
rootPath = AdjustEndingSlash(baseWorkingDir,true); rootPath = baseWorkingDir;
} }
else else
{ {
std::string path = argv[1]; plFileName path = argv[1];
FindSubDirs(dirNames,argv[1]); FindSubDirs(dirNames, argv[1]);
rootPath = ConcatDirs(baseWorkingDir,path); rootPath = plFileName::Join(baseWorkingDir, path);
rootPath = AdjustEndingSlash(rootPath,true);
} }
PackDirectory(rootPath,rootPath,rootPath+kPackFileName,dirNames,true); PackDirectory(rootPath, rootPath, plFileName::Join(rootPath, kPackFileName), dirNames, true);
for (int i=0; i<dirNames.size(); i++) for (int i=0; i<dirNames.size(); i++)
{ {
PackDirectory(dirNames[i],rootPath,rootPath+dirNames[i]+".pak",dirNames); PackDirectory(dirNames[i], rootPath, plFileName::Join(rootPath, dirNames[i]+".pak"), dirNames);
} }
return 0; return 0;

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

@ -47,7 +47,6 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "Pch.h" #include "Pch.h"
#include "hsThread.h" #include "hsThread.h"
#include "plFile/hsFiles.h"
#include <algorithm> #include <algorithm>
#pragma hdrstop #pragma hdrstop

43
Sources/Plasma/CoreLib/plFileSystem.cpp

@ -297,7 +297,8 @@ bool plFileSystem::Unlink(const plFileName &filename)
bool plFileSystem::Move(const plFileName &from, const plFileName &to) bool plFileSystem::Move(const plFileName &from, const plFileName &to)
{ {
#if HS_BUILD_FOR_WIN32 #if HS_BUILD_FOR_WIN32
return MoveFileW(from.AsString().ToWchar(), to.AsString().ToWchar()); return MoveFileExW(from.AsString().ToWchar(), to.AsString().ToWchar(),
MOVEFILE_REPLACE_EXISTING);
#else #else
if (!Copy(from, to)) if (!Copy(from, to))
return false; return false;
@ -396,6 +397,46 @@ std::vector<plFileName> plFileSystem::ListDir(const plFileName &path, const char
return contents; return contents;
} }
std::vector<plFileName> plFileSystem::ListSubdirs(const plFileName &path)
{
std::vector<plFileName> contents;
#if HS_BUILD_FOR_WIN32
plFileName searchPattern = plFileName::Join(path, "*");
WIN32_FIND_DATAW findData;
HANDLE hFind = FindFirstFileW(searchPattern.AsString().ToWchar(), &findData);
if (hFind == INVALID_HANDLE_VALUE)
return contents;
do {
if (findData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) {
plFileName name = plString::FromWchar(findData.cFileName);
if (name != "." && name != "..")
contents.push_back(plFileName::Join(path, name));
}
} while (FindNextFileW(hFind, &findData));
FindClose(hFind);
#else
DIR *dir = opendir(path.AsString().c_str());
if (!dir)
return contents;
struct dirent *de;
while (de = readdir(dir)) {
if (plFileInfo(de->d_name).IsDirectory()) {
plFileName name = de->d_name;
if (name != "." && name != "..")
contents.push_back(plFileName::Join(path, name);
}
}
closedir(dir);
#endif
return contents;
}
plFileName plFileSystem::GetUserDataPath() plFileName plFileSystem::GetUserDataPath()
{ {

5
Sources/Plasma/CoreLib/plFileSystem.h

@ -312,6 +312,11 @@ namespace plFileSystem
std::vector<plFileName> ListDir(const plFileName &path, std::vector<plFileName> ListDir(const plFileName &path,
const char *pattern = nullptr); const char *pattern = nullptr);
/** Fetch a list of subdirectories in the specified \a path.
* The returned list does not include the "." or ".." entries.
*/
std::vector<plFileName> ListSubdirs(const plFileName &path);
/** Get the User's data directory. If it doesn't exist, this will /** Get the User's data directory. If it doesn't exist, this will
* create it. * create it.
*/ */

27
Sources/Plasma/FeatureLib/pfConsole/pfConsoleCommands.cpp

@ -155,7 +155,6 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "plUnifiedTime/plUnifiedTime.h" #include "plUnifiedTime/plUnifiedTime.h"
//end for agedefn test //end for agedefn test
#include "plFile/hsFiles.h"
#include "pnSceneObject/plAudioInterface.h" #include "pnSceneObject/plAudioInterface.h"
#include "plStatusLog/plStatusLog.h" #include "plStatusLog/plStatusLog.h"
@ -3932,32 +3931,6 @@ PF_CONSOLE_CMD( Nav, PageInNode, // Group name, Function name
plgDispatch::MsgSend(pMsg1); plgDispatch::MsgSend(pMsg1);
} }
PF_CONSOLE_CMD( Nav, PageInNodeList, // Group name, Function name
"string roomNameBase", // Params
"Pages in all scene nodes that start with name." ) // Help string
{
/* This is really old and hasn't worked since 2002 anyways. */
#if HS_BUILD_FOR_WIN32
plSynchEnabler ps(false); // disable dirty tracking while paging in
std::string pageInNodesStr;
pageInNodesStr += "dat\\";
pageInNodesStr += (char*)params[0];
pageInNodesStr += "*.prx";
hsFolderIterator pageInNodesIter(pageInNodesStr.data(), true);
plClientMsg* pMsg1 = new plClientMsg(plClientMsg::kLoadRoom);
while (pageInNodesIter.NextFile())
{
char nodeName[255];
_splitpath(pageInNodesIter.GetFileName(), NULL, NULL, nodeName, NULL);
pMsg1->AddRoomLoc(plKeyFinder::Instance().FindLocation("", nodeName));
}
pMsg1->AddReceiver( plClient::GetInstance()->GetKey() );
plgDispatch::MsgSend(pMsg1);
#endif
}
#ifndef LIMIT_CONSOLE_COMMANDS #ifndef LIMIT_CONSOLE_COMMANDS

2
Sources/Plasma/FeatureLib/pfConsole/pfConsoleCommandsNet.cpp

@ -84,8 +84,6 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "plUnifiedTime/plUnifiedTime.h" #include "plUnifiedTime/plUnifiedTime.h"
//end for agedefn test //end for agedefn test
#include "plFile/hsFiles.h"
#include "plStatusLog/plStatusLog.h" #include "plStatusLog/plStatusLog.h"
#include "hsTemplates.h" #include "hsTemplates.h"

14
Sources/Plasma/FeatureLib/pfLocalizationMgr/pfLocalizationDataMgr.cpp

@ -51,7 +51,6 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "plResMgr/plLocalization.h" #include "plResMgr/plLocalization.h"
#include "plFile/hsFiles.h"
#include "plFile/plEncryptedStream.h" #include "plFile/plEncryptedStream.h"
#include "plStatusLog/plStatusLog.h" #include "plStatusLog/plStatusLog.h"
@ -645,19 +644,16 @@ void LocalizationDatabase::Parse(const plFileName & directory)
fDirectory = directory; fDirectory = directory;
fFiles.clear(); fFiles.clear();
char filename[255]; std::vector<plFileName> locFiles = plFileSystem::ListDir(directory, "*.loc");
hsFolderIterator xmlFolder(directory.AsString().c_str()); for (auto iter = locFiles.begin(); iter != locFiles.end(); ++iter)
while (xmlFolder.NextFileSuffix(".loc"))
{ {
xmlFolder.GetPathAndName(filename);
LocalizationXMLFile newFile; LocalizationXMLFile newFile;
bool retVal = newFile.Parse(filename); bool retVal = newFile.Parse(*iter);
if (!retVal) if (!retVal)
pfLocalizationDataMgr::GetLog()->AddLineF("WARNING: Errors in file %s", filename); pfLocalizationDataMgr::GetLog()->AddLineF("WARNING: Errors in file %s", iter->GetFileName().c_str());
fFiles.push_back(newFile); fFiles.push_back(newFile);
pfLocalizationDataMgr::GetLog()->AddLineF("File %s parsed and added to database", filename); pfLocalizationDataMgr::GetLog()->AddLineF("File %s parsed and added to database", iter->GetFileName().c_str());
} }
IMergeData(); IMergeData();

1
Sources/Plasma/FeatureLib/pfPython/plPythonPack.cpp

@ -51,7 +51,6 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "plPythonPack.h" #include "plPythonPack.h"
#include "plFile/hsFiles.h"
#include "plFile/plSecureStream.h" #include "plFile/plSecureStream.h"
#include "plFile/plStreamSource.h" #include "plFile/plStreamSource.h"

1
Sources/Plasma/PubUtilLib/plAgeDescription/plAgeDescription.cpp

@ -43,7 +43,6 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "hsStream.h" #include "hsStream.h"
#include "plAgeDescription.h" #include "plAgeDescription.h"
#include "plFile/hsFiles.h"
#include "plFile/plInitFileReader.h" #include "plFile/plInitFileReader.h"
#include "plFile/plEncryptedStream.h" #include "plFile/plEncryptedStream.h"
#include "hsStringTokenizer.h" #include "hsStringTokenizer.h"

1
Sources/Plasma/PubUtilLib/plAgeDescription/plAgeManifest.cpp

@ -51,7 +51,6 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "plAgeManifest.h" #include "plAgeManifest.h"
#include "plFile/hsFiles.h"
#include "plFile/plInitFileReader.h" #include "plFile/plInitFileReader.h"
#include "hsStringTokenizer.h" #include "hsStringTokenizer.h"

1
Sources/Plasma/PubUtilLib/plAudio/plWin32StreamingSound.cpp

@ -44,7 +44,6 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "hsGeometry3.h" #include "hsGeometry3.h"
#include "plgDispatch.h" #include "plgDispatch.h"
#include "plProfile.h" #include "plProfile.h"
#include "plFile/hsFiles.h"
#include "plWin32Sound.h" #include "plWin32Sound.h"
#include "plWin32StreamingSound.h" #include "plWin32StreamingSound.h"

1
Sources/Plasma/PubUtilLib/plAudioCore/plAudioFileReader.cpp

@ -55,7 +55,6 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "plAudioCore.h" #include "plAudioCore.h"
//#include "hsTimer.h" //#include "hsTimer.h"
#include "plFile/hsFiles.h"
#include "plUnifiedTime/plUnifiedTime.h" #include "plUnifiedTime/plUnifiedTime.h"
#include "plBufferedFileReader.h" #include "plBufferedFileReader.h"
#include "plCachedFileReader.h" #include "plCachedFileReader.h"

1
Sources/Plasma/PubUtilLib/plAudioCore/plSoundBuffer.cpp

@ -49,7 +49,6 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "plgDispatch.h" #include "plgDispatch.h"
#include "hsResMgr.h" #include "hsResMgr.h"
#include "pnMessage/plRefMsg.h" #include "pnMessage/plRefMsg.h"
#include "plFile/hsFiles.h"
#include "plUnifiedTime/plUnifiedTime.h" #include "plUnifiedTime/plUnifiedTime.h"
#include "plStatusLog/plStatusLog.h" #include "plStatusLog/plStatusLog.h"
#include "hsTimer.h" #include "hsTimer.h"

10
Sources/Plasma/PubUtilLib/plFile/CMakeLists.txt

@ -5,7 +5,6 @@ include_directories("../../PubUtilLib")
include_directories(${ZLIB_INCLUDE_DIR}) include_directories(${ZLIB_INCLUDE_DIR})
set(plFile_SOURCES set(plFile_SOURCES
hsFiles.cpp
plBrowseFolder.cpp plBrowseFolder.cpp
plEncryptedStream.cpp plEncryptedStream.cpp
plInitFileReader.cpp plInitFileReader.cpp
@ -13,16 +12,7 @@ set(plFile_SOURCES
plStreamSource.cpp plStreamSource.cpp
) )
if(WIN32 AND NOT CYGWIN)
set(plFile_SOURCES ${plFile_SOURCES} hsFiles_Win.cpp)
endif(WIN32 AND NOT CYGWIN)
if(UNIX)
set(plFile_SOURCES ${plFile_SOURCES} hsFiles_Unix.cpp)
endif(UNIX)
set(plFile_HEADERS set(plFile_HEADERS
hsFiles.h
plBrowseFolder.h plBrowseFolder.h
plEncryptedStream.h plEncryptedStream.h
plInitFileReader.h plInitFileReader.h

182
Sources/Plasma/PubUtilLib/plFile/hsFiles.cpp

@ -1,182 +0,0 @@
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Additional permissions under GNU GPL version 3 section 7
If you modify this Program, or any covered work, by linking or
combining it with any of RAD Game Tools Bink SDK, Autodesk 3ds Max SDK,
NVIDIA PhysX SDK, Microsoft DirectX SDK, OpenSSL library, Independent
JPEG Group JPEG library, Microsoft Windows Media SDK, or Apple QuickTime SDK
(or a modified version of those libraries),
containing parts covered by the terms of the Bink SDK EULA, 3ds Max EULA,
PhysX SDK EULA, DirectX SDK EULA, OpenSSL and SSLeay licenses, IJG
JPEG Library README, Windows Media SDK EULA, or QuickTime SDK EULA, the
licensors of this Program grant you additional
permission to convey the resulting work. Corresponding Source for a
non-source form of such a combination shall include the source code for
the parts of OpenSSL and IJG JPEG Library used as well as that of the covered
work.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
#include "hsFiles.h"
#include <string.h>
#include "hsExceptions.h"
#if HS_BUILD_FOR_WIN32
#define kDirChar '\\'
#else
#define kDirChar '/'
#endif
static const char* FindNameInPath(const char path[])
{
const char* name = ::strrchr(path, kDirChar);
if (name == nil)
name = path;
return name;
}
///////////////////////////////////////////////////////////////////////
hsFile::hsFile() : fPathAndName(nil), fFILE(nil)
{
}
hsFile::hsFile(const char pathAndName[]) : fPathAndName(nil), fFILE(nil)
{
if (pathAndName)
fPathAndName = hsStrcpy(pathAndName);
}
hsFile::~hsFile()
{
this->SetPathAndName(nil);
}
const char* hsFile::GetPathAndName()
{
return fPathAndName;
}
void hsFile::SetPathAndName(const char pathAndName[])
{
this->Close();
if (fPathAndName)
{ delete[] fPathAndName;
fPathAndName = nil;
}
if (pathAndName)
fPathAndName = hsStrcpy(pathAndName);
}
const char* hsFile::GetName()
{
return FindNameInPath(this->GetPathAndName());
}
FILE* hsFile::OpenFILE(const char mode[], bool throwIfFailure)
{
this->Close();
// We call the virtual method here rather than using
// fPathAndName directly, allowing a subclass to construct
// the name if necessary
//
const char* name = this->GetPathAndName();
if (name)
fFILE = ::fopen(name, mode);
hsThrowIfTrue(throwIfFailure && fFILE == nil);
return fFILE;
}
hsStream* hsFile::OpenStream(const char mode[], bool throwIfFailure)
{
FILE* file = this->OpenFILE(mode, throwIfFailure);
if (file)
{ hsUNIXStream* stream = new hsUNIXStream;
stream->SetFILE(file);
return stream;
}
return nil;
}
void hsFile::Close()
{
if (fFILE)
{ int err = ::fflush(fFILE);
hsIfDebugMessage(err != 0, "fflush failed", err);
err = ::fclose(fFILE);
hsIfDebugMessage(err != 0, "fclose failed", err);
fFILE = nil;
}
}
///////////////////////////////////////////////////////////////////////
bool hsFolderIterator::NextFileSuffix(const char suffix[])
{
while (this->NextFile())
{ const char* fileSuffix = ::strrchr(this->GetFileName(), '.');
if (fileSuffix != nil && stricmp(fileSuffix, suffix) == 0)
return true;
}
return false;
}
int hsFolderIterator::GetPathAndName(char pathandname[])
{
hsAssert(pathandname, "NULL path string");
const char* name = this->GetFileName();
int pathLen = strlen(fPath);
// add 1 for null terminator
int totalLen = pathLen + sizeof(kDirChar) + strlen(name) + 1;
hsAssert(totalLen <= kFolderIterator_MaxPath, "Overrun kFolderIterator_MaxPath");
if (pathandname)
{
strcpy(pathandname, fPath);
if (pathLen > 0 && pathandname[pathLen - 1] != kDirChar)
pathandname[pathLen++] = kDirChar;
strcpy(pathandname + pathLen, name);
}
return totalLen;
}
FILE* hsFolderIterator::OpenFILE(const char mode[])
{
char fileName[kFolderIterator_MaxPath];
(void)this->GetPathAndName(fileName);
return ::fopen(fileName, mode);
}

141
Sources/Plasma/PubUtilLib/plFile/hsFiles.h

@ -1,141 +0,0 @@
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Additional permissions under GNU GPL version 3 section 7
If you modify this Program, or any covered work, by linking or
combining it with any of RAD Game Tools Bink SDK, Autodesk 3ds Max SDK,
NVIDIA PhysX SDK, Microsoft DirectX SDK, OpenSSL library, Independent
JPEG Group JPEG library, Microsoft Windows Media SDK, or Apple QuickTime SDK
(or a modified version of those libraries),
containing parts covered by the terms of the Bink SDK EULA, 3ds Max EULA,
PhysX SDK EULA, DirectX SDK EULA, OpenSSL and SSLeay licenses, IJG
JPEG Library README, Windows Media SDK EULA, or QuickTime SDK EULA, the
licensors of this Program grant you additional
permission to convey the resulting work. Corresponding Source for a
non-source form of such a combination shall include the source code for
the parts of OpenSSL and IJG JPEG Library used as well as that of the covered
work.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
#ifndef hsFiles_Defined
#define hsFiles_Defined
#include "hsStream.h"
#include <stdio.h>
#if HS_BUILD_FOR_UNIX
#include <limits.h>
#define kFolderIterator_MaxPath PATH_MAX
#define SetCurrentDirectory chdir
#else
#define kFolderIterator_MaxPath _MAX_PATH
#endif
///////////////////////////////////////////////////////////////////////
class hsFile {
hsFile& operator=(const hsFile&); // disallow assignment
protected:
char* fPathAndName;
FILE* fFILE;
public:
hsFile();
hsFile(const char pathAndName[]);
virtual ~hsFile();
const char* GetName();
virtual const char* GetPathAndName();
virtual void SetPathAndName(const char pathAndName[]);
virtual FILE* OpenFILE(const char mode[], bool throwIfFailure = false);
virtual hsStream* OpenStream(const char mode[], bool throwIfFailure = false);
virtual void Close(); // called automatically in the destructor
};
typedef hsFile hsUnixFile; // for compatibility
typedef hsFile hsOSFile;
///////////////////////////////////////////////////////////////////////
class hsFolderIterator {
char fPath[kFolderIterator_MaxPath];
struct hsFolderIterator_Data* fData;
bool fCustomFilter;
public:
#ifdef HS_BUILD_FOR_WIN32
hsFolderIterator(const char path[] = nil, bool useCustomFilter=false);
#else
hsFolderIterator(const char path[] = nil, bool unused=true);
hsFolderIterator(const struct FSSpec* spec); // Alt constructor
#endif
virtual ~hsFolderIterator();
const char* GetPath() const { return fPath; }
void SetPath(const char path[]);
void Reset();
bool NextFile();
bool NextFileSuffix(const char suffix[]);
const char* GetFileName() const;
int GetPathAndName(char pathandname[] = nil);
bool IsDirectory( void ) const;
FILE* OpenFILE(const char mode[]);
#if HS_BUILD_FOR_WIN32
void SetWinSystemDir(const char subdir[]); // e.g. "Fonts"
void SetFileFilterStr(const char filterStr[]); // e.g. "*.*"
#endif
};
#ifdef HS_BUILD_FOR_WIN32
// only implemented on Win32 for now
class hsWFolderIterator {
wchar_t fPath[kFolderIterator_MaxPath];
struct hsWFolderIterator_Data* fData;
bool fCustomFilter;
public:
hsWFolderIterator(const wchar_t path[] = nil, bool useCustomFilter=false);
virtual ~hsWFolderIterator();
const wchar_t* GetPath() const { return fPath; }
void SetPath(const wchar_t path[]);
void Reset();
bool NextFile();
bool NextFileSuffix(const wchar_t suffix[]);
const wchar_t* GetFileName() const;
int GetPathAndName(wchar_t pathandname[] = nil);
bool IsDirectory( void ) const;
FILE* OpenFILE(const wchar_t mode[]);
void SetWinSystemDir(const wchar_t subdir[]); // e.g. "Fonts"
void SetFileFilterStr(const wchar_t filterStr[]); // e.g. "*.*"
};
#endif
#endif

145
Sources/Plasma/PubUtilLib/plFile/hsFiles_Unix.cpp

@ -1,145 +0,0 @@
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Additional permissions under GNU GPL version 3 section 7
If you modify this Program, or any covered work, by linking or
combining it with any of RAD Game Tools Bink SDK, Autodesk 3ds Max SDK,
NVIDIA PhysX SDK, Microsoft DirectX SDK, OpenSSL library, Independent
JPEG Group JPEG library, Microsoft Windows Media SDK, or Apple QuickTime SDK
(or a modified version of those libraries),
containing parts covered by the terms of the Bink SDK EULA, 3ds Max EULA,
PhysX SDK EULA, DirectX SDK EULA, OpenSSL and SSLeay licenses, IJG
JPEG Library README, Windows Media SDK EULA, or QuickTime SDK EULA, the
licensors of this Program grant you additional
permission to convey the resulting work. Corresponding Source for a
non-source form of such a combination shall include the source code for
the parts of OpenSSL and IJG JPEG Library used as well as that of the covered
work.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
#include "hsFiles.h"
#if HS_BUILD_FOR_UNIX
#include <errno.h>
#include <dirent.h>
#include <limits.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
#include <glob.h>
#include <string>
#include "hsTemplates.h"
struct hsFolderIterator_Data {
glob_t fGlobBuf;
bool fInited;
int fCnt;
hsFolderIterator_Data() : fInited(false), fCnt(0) {}
// ~hsFolderIterator_Data() { fInited=false; globfree(&fData->fGlobBuf); }
};
hsFolderIterator::hsFolderIterator(const char path[], bool)
{
fData = new hsFolderIterator_Data;
this->SetPath(path);
}
hsFolderIterator::~hsFolderIterator()
{
this->Reset();
delete fData;
}
void hsFolderIterator::SetPath(const char path[])
{
fPath[0] = 0;
if (path)
{
::strcpy(fPath, path);
}
this->Reset();
}
void hsFolderIterator::Reset()
{
if (fData->fInited)
{
globfree(&fData->fGlobBuf);
fData->fCnt = 0;
fData->fInited=false;
}
}
bool hsFolderIterator::NextFile()
{
if (fData->fInited == false)
{
std::string path=fPath;
if(!(strchr(fPath,'*') || strchr(fPath,'?') || strchr(fPath,'[')))
{
if (fPath[strlen(fPath)-1] != PATH_SEPARATOR)
path = path + PATH_SEPARATOR_STR + "*";
else
path = path + "*";
}
if(glob(path.c_str(), 0, NULL, &fData->fGlobBuf) != 0 ) {
return false;
}
fData->fInited=true;
fData->fCnt = 0;
}
return fData->fCnt++ < fData->fGlobBuf.gl_pathc;
}
const char* hsFolderIterator::GetFileName() const
{
if (!fData->fInited || fData->fCnt > fData->fGlobBuf.gl_pathc)
throw "end of folder";
plFileName fn = fData->fGlobBuf.gl_pathv[fData->fCnt-1];
return fn.GetFileName().c_str();
}
bool hsFolderIterator::IsDirectory( void ) const
{
// rob, please forgive me, this is my best attempt...
if(fData->fCnt > fData->fGlobBuf.gl_pathc )
return false;
struct stat info;
const char* fn=fData->fGlobBuf.gl_pathv[fData->fCnt-1];
if( stat( fn, &info ) )
{
printf("Error calling stat(): %s errno=%d\n", strerror(errno), errno);
return false;
}
return ( info.st_mode & S_IFDIR ) ? true : false;
}
#endif

320
Sources/Plasma/PubUtilLib/plFile/hsFiles_Win.cpp

@ -1,320 +0,0 @@
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Additional permissions under GNU GPL version 3 section 7
If you modify this Program, or any covered work, by linking or
combining it with any of RAD Game Tools Bink SDK, Autodesk 3ds Max SDK,
NVIDIA PhysX SDK, Microsoft DirectX SDK, OpenSSL library, Independent
JPEG Group JPEG library, Microsoft Windows Media SDK, or Apple QuickTime SDK
(or a modified version of those libraries),
containing parts covered by the terms of the Bink SDK EULA, 3ds Max EULA,
PhysX SDK EULA, DirectX SDK EULA, OpenSSL and SSLeay licenses, IJG
JPEG Library README, Windows Media SDK EULA, or QuickTime SDK EULA, the
licensors of this Program grant you additional
permission to convey the resulting work. Corresponding Source for a
non-source form of such a combination shall include the source code for
the parts of OpenSSL and IJG JPEG Library used as well as that of the covered
work.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
#include "hsFiles.h"
#include "HeadSpin.h"
#include "hsWindows.h"
#if HS_BUILD_FOR_WIN32
#include "hsExceptions.h"
struct hsFolderIterator_Data {
HANDLE fSearchHandle;
WIN32_FIND_DATA fFindData;
bool fValid;
};
hsFolderIterator::hsFolderIterator(const char path[], bool useCustomFilter)
{
fCustomFilter = useCustomFilter;
fData = new hsFolderIterator_Data;
fData->fSearchHandle = nil;
fData->fValid = true;
if(useCustomFilter)
{
this->SetFileFilterStr(path);
}
else
{
this->SetPath(path);
}
}
hsFolderIterator::~hsFolderIterator()
{
delete fData;
}
void hsFolderIterator::SetPath(const char path[])
{
fCustomFilter = false;
fPath[0] = 0;
if (path)
{
::strcpy(fPath, path);
// Make sure the dir ends with a slash
char lastchar = fPath[strlen(fPath)-1];
if (lastchar != '\\' && lastchar != '/')
strcat(fPath, "\\");
}
this->Reset();
}
void hsFolderIterator::SetWinSystemDir(const char subdir[])
{
int ret = GetWindowsDirectory(fPath, _MAX_PATH);
hsAssert(ret != 0, "Error getting windows directory in UseWindowsFontsPath");
if (subdir)
{ ::strcat(fPath, "\\");
::strcat(fPath, subdir);
::strcat(fPath, "\\");
}
this->Reset();
}
void hsFolderIterator::SetFileFilterStr(const char filterStr[])
{
fPath[0] = 0;
if (filterStr)
{
fCustomFilter = true;
::strcpy(fPath, filterStr);
}
this->Reset();
}
///////////////////////////////////////////////////////////////////////////////
void hsFolderIterator::Reset()
{
if (fData->fSearchHandle)
{ FindClose(fData->fSearchHandle);
fData->fSearchHandle = nil;
}
fData->fValid = true;
}
bool hsFolderIterator::NextFile()
{
if (fData->fValid == false)
return false;
if (fData->fSearchHandle == nil)
{ int len = ::strlen(fPath);
if(fCustomFilter == false)
{
fPath[len] = '*';
fPath[len+1] = 0;
}
fData->fSearchHandle = FindFirstFile(fPath, &fData->fFindData);
fPath[len] = 0;
if (fData->fSearchHandle == INVALID_HANDLE_VALUE)
{ fData->fSearchHandle = nil;
fData->fValid = false;
return false;
}
}
else
{ if (FindNextFile(fData->fSearchHandle, &fData->fFindData) == false)
{ FindClose(fData->fSearchHandle);
fData->fSearchHandle = nil;
fData->fValid = false;
return false;
}
}
return true;
}
bool hsFolderIterator::IsDirectory( void ) const
{
if( fData->fValid && ( fData->fFindData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY ) )
return true;
return false;
}
const char* hsFolderIterator::GetFileName() const
{
if (fData->fValid == false)
hsThrow( "end of folder");
return fData->fFindData.cFileName;
}
///////////////////////////////////////////////////////////////////////////////
struct hsWFolderIterator_Data {
HANDLE fSearchHandle;
WIN32_FIND_DATAW fFindData;
bool fValid;
};
hsWFolderIterator::hsWFolderIterator(const wchar_t path[], bool useCustomFilter)
{
fCustomFilter = useCustomFilter;
fData = new hsWFolderIterator_Data;
fData->fSearchHandle = nil;
fData->fValid = true;
if(useCustomFilter)
SetFileFilterStr(path);
else
SetPath(path);
}
hsWFolderIterator::~hsWFolderIterator()
{
delete fData;
}
void hsWFolderIterator::SetPath(const wchar_t path[])
{
fCustomFilter = false;
fPath[0] = 0;
if (path)
{
wcscpy(fPath, path);
// Make sure the dir ends with a slash
wchar_t lastchar = fPath[wcslen(fPath)-1];
if (lastchar != L'\\' && lastchar != L'/')
wcscat(fPath, L"\\");
}
Reset();
}
void hsWFolderIterator::SetWinSystemDir(const wchar_t subdir[])
{
int ret = GetWindowsDirectoryW(fPath, _MAX_PATH);
hsAssert(ret != 0, "Error getting windows directory in UseWindowsFontsPath");
if (subdir)
{
wcscat(fPath, L"\\");
wcscat(fPath, subdir);
wcscat(fPath, L"\\");
}
Reset();
}
void hsWFolderIterator::SetFileFilterStr(const wchar_t filterStr[])
{
fPath[0] = 0;
if (filterStr)
{
fCustomFilter = true;
wcscpy(fPath, filterStr);
}
Reset();
}
///////////////////////////////////////////////////////////////////////////////
void hsWFolderIterator::Reset()
{
if (fData->fSearchHandle)
{
FindClose(fData->fSearchHandle);
fData->fSearchHandle = nil;
}
fData->fValid = true;
}
bool hsWFolderIterator::NextFile()
{
if (fData->fValid == false)
return false;
if (fData->fSearchHandle == nil)
{
int len = wcslen(fPath);
if(fCustomFilter == false)
{
fPath[len] = L'*';
fPath[len+1] = L'\0';
}
fData->fSearchHandle = FindFirstFileW(fPath, &fData->fFindData);
fPath[len] = 0;
if (fData->fSearchHandle == INVALID_HANDLE_VALUE)
{
fData->fSearchHandle = nil;
fData->fValid = false;
return false;
}
}
else
{
if (FindNextFileW(fData->fSearchHandle, &fData->fFindData) == false)
{
FindClose(fData->fSearchHandle);
fData->fSearchHandle = nil;
fData->fValid = false;
return false;
}
}
return true;
}
bool hsWFolderIterator::IsDirectory( void ) const
{
if( fData->fValid && ( fData->fFindData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY ) )
return true;
return false;
}
const wchar_t* hsWFolderIterator::GetFileName() const
{
if (fData->fValid == false)
hsThrow( "end of folder");
return fData->fFindData.cFileName;
}
#endif // HS_BUILD_FOR_WIN32

16
Sources/Plasma/PubUtilLib/plFile/plStreamSource.cpp

@ -41,7 +41,6 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
*==LICENSE==*/ *==LICENSE==*/
#include <string> #include <string>
#include "hsFiles.h"
#include "plStreamSource.h" #include "plStreamSource.h"
#include "plSecureStream.h" #include "plSecureStream.h"
#include "plEncryptedStream.h" #include "plEncryptedStream.h"
@ -106,8 +105,7 @@ std::vector<plFileName> plStreamSource::GetListOfNames(const plFileName& dir, co
// loop through all the file data records, and create the list // loop through all the file data records, and create the list
std::vector<plFileName> retVal; std::vector<plFileName> retVal;
decltype(fFileData.begin()) curData; for (auto curData = fFileData.begin(); curData != fFileData.end(); curData++)
for (curData = fFileData.begin(); curData != fFileData.end(); curData++)
{ {
if ((curData->second.fDir == sDir) && (curData->second.fExt == ext)) if ((curData->second.fDir == sDir) && (curData->second.fExt == ext))
retVal.push_back(curData->second.fFilename); retVal.push_back(curData->second.fFilename);
@ -116,15 +114,11 @@ std::vector<plFileName> plStreamSource::GetListOfNames(const plFileName& dir, co
#ifndef PLASMA_EXTERNAL_RELEASE #ifndef PLASMA_EXTERNAL_RELEASE
// in internal releases, we can use on-disk files if they exist // in internal releases, we can use on-disk files if they exist
// Build the search string as "dir/*.ext" // Build the search string as "dir/*.ext"
plString searchStr = plFileName::Join(sDir, "*." + ext).AsString(); std::vector<plFileName> files = plFileSystem::ListDir(sDir, ("*." + ext).c_str());
for (auto iter = files.begin(); iter != files.end(); ++iter)
hsFolderIterator folderIter(searchStr.c_str(), true);
while (folderIter.NextFile())
{ {
plFileName filename = plFileName::Join(sDir, folderIter.GetFileName()); if (fFileData.find(*iter) == fFileData.end()) // we haven't added it yet
retVal.push_back(*iter);
if (fFileData.find(filename) == fFileData.end()) // we haven't added it yet
retVal.push_back(filename);
} }
#endif // PLASMA_EXTERNAL_RELEASE #endif // PLASMA_EXTERNAL_RELEASE

2
Sources/Plasma/PubUtilLib/plGImage/plFont.cpp

@ -1063,7 +1063,7 @@ uint8_t *plFont::IGetFreeCharData( uint32_t &newOffset )
//// LoadFromP2FFile ////////////////////////////////////////////////////////// //// LoadFromP2FFile //////////////////////////////////////////////////////////
// Handy quick wrapper // Handy quick wrapper
bool plFont::LoadFromP2FFile( const char *path ) bool plFont::LoadFromP2FFile( const plFileName &path )
{ {
hsUNIXStream stream; hsUNIXStream stream;
if( stream.Open( path, "rb" ) ) if( stream.Open( path, "rb" ) )

2
Sources/Plasma/PubUtilLib/plGImage/plFont.h

@ -289,7 +289,7 @@ class plFont : public hsKeyedObject
bool LoadFromBDF( const char *path, plBDFConvertCallback *callback ); bool LoadFromBDF( const char *path, plBDFConvertCallback *callback );
bool LoadFromBDFStream( hsStream *stream, plBDFConvertCallback *callback ); bool LoadFromBDFStream( hsStream *stream, plBDFConvertCallback *callback );
bool LoadFromP2FFile( const char *path ); bool LoadFromP2FFile( const plFileName &path );
bool ReadRaw( hsStream *stream ); bool ReadRaw( hsStream *stream );
bool WriteRaw( hsStream *stream ); bool WriteRaw( hsStream *stream );

35
Sources/Plasma/PubUtilLib/plGImage/plFontCache.cpp

@ -57,7 +57,6 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "plFont.h" #include "plFont.h"
#include "plStatusLog/plStatusLog.h" #include "plStatusLog/plStatusLog.h"
#include "plFile/hsFiles.h"
#include "pnMessage/plRefMsg.h" #include "pnMessage/plRefMsg.h"
#include "hsResMgr.h" #include "hsResMgr.h"
@ -71,7 +70,6 @@ plFontCache *plFontCache::fInstance = nil;
plFontCache::plFontCache() plFontCache::plFontCache()
{ {
fCustFontDir = nil;
RegisterAs( kFontCache_KEY ); RegisterAs( kFontCache_KEY );
fInstance = this; fInstance = this;
} }
@ -79,7 +77,6 @@ plFontCache::plFontCache()
plFontCache::~plFontCache() plFontCache::~plFontCache()
{ {
Clear(); Clear();
delete [] fCustFontDir;
fInstance = nil; fInstance = nil;
} }
@ -151,46 +148,38 @@ plFont *plFontCache::GetFont( const char *face, uint8_t size, uint32_t fontFlag
return nil; return nil;
} }
void plFontCache::LoadCustomFonts( const char *dir ) void plFontCache::LoadCustomFonts( const plFileName &dir )
{ {
delete [] fCustFontDir; fCustFontDir = dir;
fCustFontDir = ( dir != nil ) ? hsStrcpy( dir ) : nil;
ILoadCustomFonts(); ILoadCustomFonts();
} }
void plFontCache::ILoadCustomFonts( void ) void plFontCache::ILoadCustomFonts( void )
{ {
if( fCustFontDir == nil ) if (!fCustFontDir.IsValid())
return; return;
// Iterate through all the custom fonts in our dir // Iterate through all the custom fonts in our dir
hsFolderIterator iter( fCustFontDir ); std::vector<plFileName> fonts = plFileSystem::ListDir(fCustFontDir, "*.p2f");
char fileName[ kFolderIterator_MaxPath ]; for (auto iter = fonts.begin(); iter != fonts.end(); ++iter)
hsFolderIterator iter2( fCustFontDir );
while( iter2.NextFileSuffix( ".p2f" ) )
{ {
iter2.GetPathAndName( fileName );
plFont *font = new plFont; plFont *font = new plFont;
if( !font->LoadFromP2FFile( fileName ) ) if (!font->LoadFromP2FFile(*iter))
delete font; delete font;
else else
{ {
plString keyName; plString keyName;
if( font->GetKey() == nil ) if (font->GetKey() == nil)
{ {
keyName = plString::Format( "%s-%d", font->GetFace(), font->GetSize() ); keyName = plString::Format( "%s-%d", font->GetFace(), font->GetSize() );
hsgResMgr::ResMgr()->NewKey( keyName, font, plLocation::kGlobalFixedLoc ); hsgResMgr::ResMgr()->NewKey( keyName, font, plLocation::kGlobalFixedLoc );
} }
hsgResMgr::ResMgr()->AddViaNotify( font->GetKey(), hsgResMgr::ResMgr()->AddViaNotify( font->GetKey(),
new plGenRefMsg( GetKey(), plRefMsg::kOnCreate, 0, -1 ), new plGenRefMsg( GetKey(), plRefMsg::kOnCreate, 0, -1 ),
plRefFlags::kActiveRef ); plRefFlags::kActiveRef );
//plStatusLog::AddLineS( "pipeline.log", "FontCache: Added custom font %s", keyName ); //plStatusLog::AddLineS( "pipeline.log", "FontCache: Added custom font %s", keyName.c_str() );
} }
} }

7
Sources/Plasma/PubUtilLib/plGImage/plFontCache.h

@ -59,6 +59,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "HeadSpin.h" #include "HeadSpin.h"
#include "hsTemplates.h" #include "hsTemplates.h"
#include "pnKeyedObject/hsKeyedObject.h" #include "pnKeyedObject/hsKeyedObject.h"
#include "plFileSystem.h"
//// Class Definition ///////////////////////////////////////////////////////// //// Class Definition /////////////////////////////////////////////////////////
@ -69,9 +70,9 @@ class plFontCache : public hsKeyedObject
protected: protected:
hsTArray<plFont *> fCache; hsTArray<plFont *> fCache;
char *fCustFontDir; plFileName fCustFontDir;
static plFontCache *fInstance; static plFontCache *fInstance;
void ILoadCustomFonts( void ); void ILoadCustomFonts( void );
@ -96,7 +97,7 @@ class plFontCache : public hsKeyedObject
// void FreeFont( HFONT font ); // void FreeFont( HFONT font );
void Clear( void ); void Clear( void );
void LoadCustomFonts( const char *dir ); void LoadCustomFonts( const plFileName &dir );
// Our custom font extension // Our custom font extension
static const char* kCustFontExtension; static const char* kCustFontExtension;

27
Sources/Plasma/PubUtilLib/plGImage/plWinFontCache.cpp

@ -63,7 +63,6 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "plWinFontCache.h" #include "plWinFontCache.h"
#include "plStatusLog/plStatusLog.h" #include "plStatusLog/plStatusLog.h"
#include "plFile/hsFiles.h"
#include "plGImage/plDynSurfaceWriter.h" #include "plGImage/plDynSurfaceWriter.h"
#if HS_BUILD_FOR_WIN32 #if HS_BUILD_FOR_WIN32
@ -234,11 +233,11 @@ void plWinFontCache::Clear( void )
for( i = 0; i < fCustFonts.GetCount(); i++ ) for( i = 0; i < fCustFonts.GetCount(); i++ )
{ {
#if (_WIN32_WINNT >= 0x0500) #if (_WIN32_WINNT >= 0x0500)
if( plDynSurfaceWriter::CanHandleLotsOfThem() ) if (plDynSurfaceWriter::CanHandleLotsOfThem())
RemoveFontResourceEx( fCustFonts[ i ]->fFilename, FR_PRIVATE, 0 ); RemoveFontResourceExW(fCustFonts[i]->fFilename.AsString().ToWchar(), FR_PRIVATE, 0);
else else
#endif #endif
if( RemoveFontResource( fCustFonts[ i ]->fFilename ) == 0 ) if (RemoveFontResourceW(fCustFonts[i]->fFilename.AsString().ToWchar()) == 0)
{ {
int q= 0; int q= 0;
DWORD e = GetLastError(); DWORD e = GetLastError();
@ -267,31 +266,27 @@ void plWinFontCache::ILoadCustomFonts( void )
return; return;
// Iterate through all the custom fonts in our dir // Iterate through all the custom fonts in our dir
hsFolderIterator iter( fCustFontDir ); int numAdded;
char fileName[ kFolderIterator_MaxPath ];
int numAdded;
while( iter.NextFileSuffix( kCustFontExtension ) ) std::vector<plFileName> fonts = plFileSystem::ListDir(fCustFontDir, kCustFontExtension);
for (auto iter = fonts.begin(); iter != fonts.end(); ++iter)
{ {
iter.GetPathAndName( fileName );
// Note that this call can be translated as "does my OS suck?" // Note that this call can be translated as "does my OS suck?"
#if (_WIN32_WINNT >= 0x0500) #if (_WIN32_WINNT >= 0x0500)
if( plDynSurfaceWriter::CanHandleLotsOfThem() ) if( plDynSurfaceWriter::CanHandleLotsOfThem() )
numAdded = AddFontResourceEx( fileName, FR_PRIVATE, 0 ); numAdded = AddFontResourceExW(iter->AsString().ToWchar(), FR_PRIVATE, 0);
else else
#endif #endif
numAdded = AddFontResource( fileName ); numAdded = AddFontResourceW(iter->AsString().ToWchar());
if( numAdded > 0 ) if( numAdded > 0 )
{ {
plStatusLog::AddLineS( "pipeline.log", "WinFontCache: Added custom font %s, %d fonts", fileName, numAdded ); plStatusLog::AddLineS( "pipeline.log", "WinFontCache: Added custom font %s, %d fonts", iter->GetFileName().c_str(), numAdded );
fCustFonts.Append( new plCustFont( fileName ) ); fCustFonts.Append(new plCustFont(*iter));
} }
else else
{ {
plStatusLog::AddLineS( "pipeline.log", "WinFontCache: Unable to load custom font %s", fileName ); plStatusLog::AddLineS( "pipeline.log", "WinFontCache: Unable to load custom font %s", iter->GetFileName().c_str() );
} }
} }
} }

5
Sources/Plasma/PubUtilLib/plGImage/plWinFontCache.h

@ -90,10 +90,9 @@ class plWinFontCache
class plCustFont class plCustFont
{ {
public: public:
char *fFilename; plFileName fFilename;
plCustFont( const char *c ) { fFilename = hsStrcpy( c ); } plCustFont(const plFileName &c) { fFilename = c; }
~plCustFont() { delete [] fFilename; }
}; };
bool fInShutdown; bool fInShutdown;

12
Sources/Plasma/PubUtilLib/plNetClient/plNetLinkingMgr.cpp

@ -63,7 +63,6 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "plNetMessage/plNetMessage.h" #include "plNetMessage/plNetMessage.h"
#include "plAvatar/plAvatarMgr.h" #include "plAvatar/plAvatarMgr.h"
#include "plAvatar/plArmatureMod.h" #include "plAvatar/plArmatureMod.h"
#include "plFile/hsFiles.h"
/***************************************************************************** /*****************************************************************************
@ -305,15 +304,14 @@ void plNetLinkingMgr::SetEnabled( bool b )
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
// static // static
std::string plNetLinkingMgr::GetProperAgeName( const char * ageName ) plString plNetLinkingMgr::GetProperAgeName( const plString & ageName )
{ {
plNetClientMgr * nc = plNetClientMgr::GetInstance(); plNetClientMgr * nc = plNetClientMgr::GetInstance();
hsFolderIterator it("dat" PATH_SEPARATOR_STR "*.age", true); std::vector<plFileName> files = plFileSystem::ListDir("dat", "*.age");
while ( it.NextFile() ) for (auto iter = files.begin(); iter != files.end(); ++iter)
{ {
std::string work = it.GetFileName(); plString work = iter->GetFileNameNoExt();
work.erase( work.find( ".age" ) ); if (ageName.CompareI(work) == 0)
if ( stricmp( ageName, work.c_str() )==0 )
return work; return work;
} }
return ageName; return ageName;

2
Sources/Plasma/PubUtilLib/plNetClient/plNetLinkingMgr.h

@ -158,7 +158,7 @@ public:
const plNetServerSessionInfo * GetLobbyServerInfo( void ) const { return &fLobbyInfo;} const plNetServerSessionInfo * GetLobbyServerInfo( void ) const { return &fLobbyInfo;}
// helpers // helpers
static std::string GetProperAgeName( const char * ageName ); // attempt to fix wrong case age name. static plString GetProperAgeName( const plString & ageName ); // attempt to fix wrong case age name.
private: private:
bool fLinkingEnabled; bool fLinkingEnabled;

1
Sources/Plasma/PubUtilLib/plNetClientRecorder/plNetClientRecorder.cpp

@ -57,7 +57,6 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "plMessage/plAgeLoadedMsg.h" #include "plMessage/plAgeLoadedMsg.h"
#include "plStatusLog/plStatusLog.h" #include "plStatusLog/plStatusLog.h"
#include "plFile/hsFiles.h"
plNetClientRecorder::plNetClientRecorder(TimeWrapper* timeWrapper) : plNetClientRecorder::plNetClientRecorder(TimeWrapper* timeWrapper) :
fTimeWrapper(timeWrapper) fTimeWrapper(timeWrapper)

1
Sources/Plasma/PubUtilLib/plResMgr/plRegistryNode.cpp

@ -47,7 +47,6 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "pnKeyedObject/plKeyImp.h" #include "pnKeyedObject/plKeyImp.h"
#include "plStatusLog/plStatusLog.h" #include "plStatusLog/plStatusLog.h"
#include "pnFactory/plFactory.h" #include "pnFactory/plFactory.h"
#include "plFile/hsFiles.h"
#include "plVersion.h" #include "plVersion.h"

10
Sources/Plasma/PubUtilLib/plResMgr/plResManager.cpp

@ -59,7 +59,6 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "pnMessage/plObjRefMsg.h" #include "pnMessage/plObjRefMsg.h"
#include "plMessage/plAgeLoadedMsg.h" #include "plMessage/plAgeLoadedMsg.h"
#include "pnMessage/plClientMsg.h" #include "pnMessage/plClientMsg.h"
#include "plFile/hsFiles.h"
#include "pnFactory/plCreator.h" #include "pnFactory/plCreator.h"
#include "pnNetCommon/plSynchedObject.h" #include "pnNetCommon/plSynchedObject.h"
#include "pnNetCommon/plNetApp.h" #include "pnNetCommon/plNetApp.h"
@ -130,13 +129,10 @@ bool plResManager::IInit()
{ {
// We want to go through all the data files in our data path and add new // We want to go through all the data files in our data path and add new
// plRegistryPageNodes to the regTree for each // plRegistryPageNodes to the regTree for each
hsFolderIterator pathIterator(fDataPath.AsString().c_str()); std::vector<plFileName> prpFiles = plFileSystem::ListDir(fDataPath, "*.prp");
while (pathIterator.NextFileSuffix(".prp")) for (auto iter = prpFiles.begin(); iter != prpFiles.end(); ++iter)
{ {
char fileName[kFolderIterator_MaxPath]; plRegistryPageNode* node = new plRegistryPageNode(*iter);
pathIterator.GetPathAndName(fileName);
plRegistryPageNode* node = new plRegistryPageNode(fileName);
plPageInfo pi = node->GetPageInfo(); plPageInfo pi = node->GetPageInfo();
fAllPages[pi.GetLocation()] = node; fAllPages[pi.GetLocation()] = node;
} }

1
Sources/Plasma/PubUtilLib/plSDL/plSDLParser.cpp

@ -41,7 +41,6 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
*==LICENSE==*/ *==LICENSE==*/
#include "HeadSpin.h" #include "HeadSpin.h"
#include "plSDL.h" #include "plSDL.h"
#include "plFile/hsFiles.h"
#include "plFile/plStreamSource.h" #include "plFile/plStreamSource.h"
#include "pnNetCommon/pnNetCommon.h" #include "pnNetCommon/pnNetCommon.h"
#include "pnNetCommon/plNetApp.h" #include "pnNetCommon/plNetApp.h"

28
Sources/Plasma/PubUtilLib/plStatusLog/plStatusLog.cpp

@ -61,7 +61,6 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "hsTemplates.h" #include "hsTemplates.h"
#include "hsTimer.h" #include "hsTimer.h"
#include "plStatusLog.h" #include "plStatusLog.h"
#include "plFile/hsFiles.h"
#include "plUnifiedTime/plUnifiedTime.h" #include "plUnifiedTime/plUnifiedTime.h"
#include "plProduct.h" #include "plProduct.h"
@ -252,29 +251,12 @@ bool plStatusLogMgr::DumpLogs( const plFileName &newFolderName )
newPath = newFolderName; newPath = newFolderName;
plFileSystem::CreateDir(newPath, true); plFileSystem::CreateDir(newPath, true);
#if HS_BUILD_FOR_WIN32 std::vector<plFileName> files = plFileSystem::ListDir(basePath);
hsWFolderIterator folderIterator; for (auto iter = files.begin(); iter != files.end(); ++iter) {
if (basePath.IsValid()) plFileName destination = plFileName::Join(newPath, iter->GetFileName());
folderIterator.SetPath(basePath.AsString().ToWchar()); retVal = plFileSystem::Copy(*iter, destination);
else
folderIterator.SetPath(L".");
while (folderIterator.NextFile())
{
if (folderIterator.IsDirectory())
continue;
plFileName baseFilename = plString::FromWchar(folderIterator.GetFileName());
plFileName source;
if (basePath.IsValid())
source = plFileName::Join(basePath, baseFilename);
else
source = baseFilename;
plFileName destination = plFileName::Join(newPath, baseFilename);
retVal = (plFileSystem::Copy(source, destination) != 0);
} }
#endif
return retVal; return retVal;
} }

1
Sources/Tools/MaxComponent/Pch.h

@ -60,7 +60,6 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "plAudible.h" #include "plAudible.h"
#include "plCreatableIndex.h" #include "plCreatableIndex.h"
#include "plgDispatch.h" #include "plgDispatch.h"
#include "plFile/hsFiles.h"
#include "hsGeometry3.h" #include "hsGeometry3.h"
#include "plLoadMask.h" #include "plLoadMask.h"
#include "hsMatrix44.h" #include "hsMatrix44.h"

15
Sources/Tools/MaxComponent/plGUIComponents.cpp

@ -42,7 +42,6 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "HeadSpin.h" #include "HeadSpin.h"
#include "plgDispatch.h" #include "plgDispatch.h"
#include "plFile/hsFiles.h"
#include "hsTemplates.h" #include "hsTemplates.h"
#include "plComponent.h" #include "plComponent.h"
@ -1464,19 +1463,17 @@ BOOL plGUIDialogProc::DlgProc( TimeValue t, IParamMap2 *pmap, HWND hWnd, UINT ms
case WM_INITDIALOG: case WM_INITDIALOG:
// Load the age combo box // Load the age combo box
{ {
int i, idx, selIdx = 0; int i, idx, selIdx = 0;
HWND ageCombo = GetDlgItem( hWnd, IDC_GUIDLG_AGE ); HWND ageCombo = GetDlgItem( hWnd, IDC_GUIDLG_AGE );
hsTArray<char *> ageList;
plAgeDescInterface::BuildAgeFileList( ageList ); hsTArray<plFileName> ageList = plAgeDescInterface::BuildAgeFileList();
ComboBox_ResetContent( ageCombo ); ComboBox_ResetContent( ageCombo );
for( i = 0; i < ageList.GetCount(); i++ ) for( i = 0; i < ageList.GetCount(); i++ )
{ {
char ageName[ _MAX_FNAME ]; plString ageName = ageList[i].GetFileNameNoExt();
_splitpath( ageList[ i ], nil, nil, ageName, nil );
idx = ComboBox_AddString( ageCombo, ageName ); idx = ComboBox_AddString( ageCombo, ageName.c_str() );
if( stricmp( ageName, pmap->GetParamBlock()->GetStr( plGUIDialogComponent::kRefAgeName ) ) == 0 ) if( ageName.CompareI( pmap->GetParamBlock()->GetStr( plGUIDialogComponent::kRefAgeName ) ) == 0 )
{ {
selIdx = idx; selIdx = idx;
} }

13
Sources/Tools/MaxComponent/plMiscComponents.cpp

@ -43,7 +43,6 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "HeadSpin.h" #include "HeadSpin.h"
#include "plCreatableIndex.h" #include "plCreatableIndex.h"
#include "plgDispatch.h" #include "plgDispatch.h"
#include "plFile/hsFiles.h"
#include "plComponentReg.h" #include "plComponentReg.h"
#include "plMiscComponents.h" #include "plMiscComponents.h"
@ -259,8 +258,7 @@ protected:
HWND hAgeCombo = GetDlgItem(fhDlg, IDC_COMP_LOCATION_AGECOMBO); HWND hAgeCombo = GetDlgItem(fhDlg, IDC_COMP_LOCATION_AGECOMBO);
IClearAges( hAgeCombo ); IClearAges( hAgeCombo );
hsTArray<char *> ageFiles; hsTArray<plFileName> ageFiles = plAgeDescInterface::BuildAgeFileList();
plAgeDescInterface::BuildAgeFileList( ageFiles );
const char *curAge = fPB->GetStr(plPageInfoComponent::kInfoAge); const char *curAge = fPB->GetStr(plPageInfoComponent::kInfoAge);
if (!curAge || *curAge == '\0') if (!curAge || *curAge == '\0')
@ -268,14 +266,13 @@ protected:
for( int i = 0; i < ageFiles.GetCount(); i++ ) for( int i = 0; i < ageFiles.GetCount(); i++ )
{ {
char ageName[_MAX_FNAME]; plString ageName = ageFiles[i].GetFileNameNoExt();
_splitpath( ageFiles[ i ], nil, nil, ageName, nil );
int idx = ComboBox_AddString( hAgeCombo, ageName ); int idx = ComboBox_AddString( hAgeCombo, ageName.c_str() );
// Store the pathas the item data for later (so don't free it yet!) // Store the pathas the item data for later (so don't free it yet!)
ComboBox_SetItemData( hAgeCombo, idx, (LPARAM)ageFiles[ i ] ); ComboBox_SetItemData( hAgeCombo, idx, (LPARAM)ageFiles[i].AsString().c_str() );
if( !strcmp( ageName, curAge ) ) if (ageName == curAge)
ComboBox_SetCurSel( hAgeCombo, idx ); ComboBox_SetCurSel( hAgeCombo, idx );
} }

29
Sources/Tools/MaxComponent/plResponderLink.cpp

@ -41,7 +41,6 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
*==LICENSE==*/ *==LICENSE==*/
#include "HeadSpin.h" #include "HeadSpin.h"
#include "plFile/hsFiles.h"
#include "hsResMgr.h" #include "hsResMgr.h"
#include "plComponentBase.h" #include "plComponentBase.h"
@ -329,18 +328,12 @@ void plResponderLinkProc::ILoadAgeFilenamesCombo(HWND hWnd, IParamBlock2 *pb)
savedName = ""; savedName = "";
// Iterate through the age descriptions // Iterate through the age descriptions
hsFolderIterator ageFolder(agePath.AsString().c_str()); std::vector<plFileName> ages = plFileSystem::ListDir(agePath, "*.age");
while (ageFolder.NextFileSuffix(".age")) for (auto iter = ages.begin(); iter != ages.end(); ++iter)
{ {
char ageFile[MAX_PATH]; int idx = SendMessage(hAge, CB_ADDSTRING, 0, (LPARAM)iter->GetFileNameNoExt().c_str());
ageFolder.GetPathAndName(ageFile);
char name[_MAX_FNAME]; if (iter->GetFileNameNoExt() == savedName)
_splitpath(ageFile, nil, nil, name, nil);
int idx = SendMessage(hAge, CB_ADDSTRING, 0, (LPARAM)name);
if (strcmp(name, savedName) == 0)
SendMessage(hAge, CB_SETCURSEL, idx, 0); SendMessage(hAge, CB_SETCURSEL, idx, 0);
} }
} }
@ -364,18 +357,12 @@ void plResponderLinkProc::ILoadParentAgeFilenamesCombo(HWND hWnd, IParamBlock2 *
savedName = "<None>"; savedName = "<None>";
// Iterate through the age descriptions // Iterate through the age descriptions
hsFolderIterator ageFolder(agePath.AsString().c_str()); std::vector<plFileName> ages = plFileSystem::ListDir(agePath, "*.age");
while (ageFolder.NextFileSuffix(".age")) for (auto iter = ages.begin(); iter != ages.end(); ++iter)
{ {
char ageFile[MAX_PATH]; int idx = SendMessage(hAge, CB_ADDSTRING, 0, (LPARAM)iter->GetFileNameNoExt().c_str());
ageFolder.GetPathAndName(ageFile);
char name[_MAX_FNAME];
_splitpath(ageFile, nil, nil, name, nil);
int idx = SendMessage(hAge, CB_ADDSTRING, 0, (LPARAM)name);
if (strcmp(name, savedName) == 0) if (iter->GetFileNameNoExt() == savedName)
SendMessage(hAge, CB_SETCURSEL, idx, 0); SendMessage(hAge, CB_SETCURSEL, idx, 0);
} }
} }

54
Sources/Tools/MaxExport/plExportDlg.cpp

@ -42,6 +42,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "HeadSpin.h" #include "HeadSpin.h"
#include "hsWindows.h" #include "hsWindows.h"
#include "hsStream.h"
#include <bitmap.h> #include <bitmap.h>
#include <iparamb2.h> #include <iparamb2.h>
@ -330,8 +331,6 @@ void plExportDlgImp::IExportCurrentFile(const char* exportPath)
GetCOREInterface()->ExportToFile(exportPath); GetCOREInterface()->ExportToFile(exportPath);
} }
#include "plFile/hsFiles.h"
void plExportDlgImp::IDoExport() void plExportDlgImp::IDoExport()
{ {
fExporting = true; fExporting = true;
@ -351,13 +350,10 @@ void plExportDlgImp::IDoExport()
IExportCurrentFile(exportPath); IExportCurrentFile(exportPath);
else else
{ {
hsFolderIterator sourceDir(fExportSourceDir.AsString().c_str()); std::vector<plFileName> sources = plFileSystem::ListDir(fExportSourceDir, "*.max");
while (sourceDir.NextFileSuffix(".max")) for (auto iter = sources.begin(); iter != sources.end(); ++iter)
{ {
char exportFile[MAX_PATH]; if (GetCOREInterface()->LoadFromFile(iter->AsString().c_str()))
sourceDir.GetPathAndName(exportFile);
if (GetCOREInterface()->LoadFromFile(exportFile))
IExportCurrentFile(exportPath); IExportCurrentFile(exportPath);
} }
} }
@ -390,18 +386,18 @@ void plExportDlgImp::Show()
fDlg = CreateDialog(hInstance, MAKEINTRESOURCE(IDD_EXPORT), GetCOREInterface()->GetMAXHWnd(), ForwardDlgProc); fDlg = CreateDialog(hInstance, MAKEINTRESOURCE(IDD_EXPORT), GetCOREInterface()->GetMAXHWnd(), ForwardDlgProc);
} }
static bool IsExcluded(const char* fileName, std::vector<std::string>& excludeFiles) static bool IsExcluded(const plFileName& fileName, std::vector<plFileName>& excludeFiles)
{ {
for (int i = 0; i < excludeFiles.size(); i++) for (int i = 0; i < excludeFiles.size(); i++)
{ {
if (!strcmp(fileName, excludeFiles[i].c_str())) if (fileName == excludeFiles[i])
return true; return true;
} }
return false; return false;
} }
static bool AutoExportDir(const char* inputDir, const char* outputDir, const char* groupFiles, std::vector<std::string>& excludeFiles) static bool AutoExportDir(const char* inputDir, const char* outputDir, const plFileName& groupFiles, std::vector<plFileName>& excludeFiles)
{ {
bool exportedFile = false; bool exportedFile = false;
@ -417,37 +413,33 @@ static bool AutoExportDir(const char* inputDir, const char* outputDir, const cha
// Don't give missing bitmap warnings // Don't give missing bitmap warnings
TheManager->SetSilentMode(TRUE); TheManager->SetSilentMode(TRUE);
hsFolderIterator sourceDir(inputDir);
while (sourceDir.NextFileSuffix(".max"))
{
char exportFile[MAX_PATH];
sourceDir.GetPathAndName(exportFile);
if (IsExcluded(sourceDir.GetFileName(), excludeFiles)) std::vector<plFileName> sources = plFileSystem::ListDir(inputDir, "*.max");
for (auto iter = sources.begin(); iter != sources.end(); ++iter)
{
if (IsExcluded(iter->GetFileName(), excludeFiles))
continue; continue;
// If we're doing grouped files, and this isn't one, keep looking // If we're doing grouped files, and this isn't one, keep looking
if (groupFiles && strncmp(sourceDir.GetFileName(), groupFiles, strlen(groupFiles)) != 0) if (groupFiles.IsValid() && groupFiles != iter->GetFileName())
continue; continue;
hsUNIXStream log; hsUNIXStream log;
if (log.Open(outputLog, "ab")) if (log.Open(outputLog, "ab"))
{ {
log.WriteFmt("%s\r\n", sourceDir.GetFileName()); log.WriteFmt("%s\r\n", iter->GetFileName().c_str());
log.Close(); log.Close();
} }
if (GetCOREInterface()->LoadFromFile(exportFile)) if (GetCOREInterface()->LoadFromFile(iter->AsString().c_str()))
{ {
sprintf(doneDir, "%s\\Done\\%s", inputDir, sourceDir.GetFileName()); plFileSystem::Move(*iter, plFileName::Join(inputDir, "Done", iter->GetFileName()));
MoveFileEx(exportFile, doneDir, MOVEFILE_REPLACE_EXISTING);
GetCOREInterface()->ExportToFile(outputFileName, TRUE); GetCOREInterface()->ExportToFile(outputFileName, TRUE);
exportedFile = true; exportedFile = true;
// If we're not doing grouped files, this is it, we exported our one file // If we're not doing grouped files, this is it, we exported our one file
if (!groupFiles) if (!groupFiles.IsValid())
break; break;
} }
} }
@ -471,7 +463,7 @@ static void ShutdownMax()
PostMessage(GetCOREInterface()->GetMAXHWnd(), WM_CLOSE, 0, 0); PostMessage(GetCOREInterface()->GetMAXHWnd(), WM_CLOSE, 0, 0);
} }
static void GetStringSection(const char* configFile, const char* keyName, std::vector<std::string>& strings) static void GetFileNameSection(const char* configFile, const char* keyName, std::vector<plFileName>& strings)
{ {
char source[256]; char source[256];
GetPrivateProfileString("Settings", keyName, "", source, sizeof(source), configFile); GetPrivateProfileString("Settings", keyName, "", source, sizeof(source), configFile);
@ -506,18 +498,18 @@ void plExportDlgImp::StartAutoExport()
hsMessageBox_SuppressPrompts = true; hsMessageBox_SuppressPrompts = true;
// Files to ignore // Files to ignore
std::vector<std::string> excludeFiles; std::vector<plFileName> excludeFiles;
GetStringSection(configFile, "ExcludeFiles", excludeFiles); GetFileNameSection(configFile, "ExcludeFiles", excludeFiles);
// //
// Get the file substrings to export in one session // Get the file substrings to export in one session
// //
std::vector<std::string> groupedFiles; std::vector<plFileName> groupedFiles;
GetStringSection(configFile, "GroupedFiles", groupedFiles); GetFileNameSection(configFile, "GroupedFiles", groupedFiles);
for (int i = 0; i < groupedFiles.size(); i++) for (int i = 0; i < groupedFiles.size(); i++)
{ {
if (AutoExportDir(inputDir, outputDir, groupedFiles[i].c_str(), excludeFiles)) if (AutoExportDir(inputDir, outputDir, groupedFiles[i], excludeFiles))
{ {
ShutdownMax(); ShutdownMax();
fAutoExporting = false; fAutoExporting = false;
@ -525,7 +517,7 @@ void plExportDlgImp::StartAutoExport()
} }
} }
if (AutoExportDir(inputDir, outputDir, NULL, excludeFiles)) if (AutoExportDir(inputDir, outputDir, "", excludeFiles))
{ {
ShutdownMax(); ShutdownMax();
fAutoExporting = false; fAutoExporting = false;

1
Sources/Tools/MaxMain/Pch.h

@ -61,7 +61,6 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "hsColorRGBA.h" #include "hsColorRGBA.h"
#include "plgDispatch.h" #include "plgDispatch.h"
#include "hsFastMath.h" #include "hsFastMath.h"
#include "plFile/hsFiles.h"
#include "hsGeometry3.h" #include "hsGeometry3.h"
#include "pnKeyedObject/plKey.h" #include "pnKeyedObject/plKey.h"
#include "plLoadMask.h" #include "plLoadMask.h"

1
Sources/Tools/MaxMain/main.cpp

@ -41,7 +41,6 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
*==LICENSE==*/ *==LICENSE==*/
#include "HeadSpin.h" #include "HeadSpin.h"
#include "plFile/hsFiles.h"
#include "hsTemplates.h" #include "hsTemplates.h"
#include "MaxComponent/plComponentMgr.h" #include "MaxComponent/plComponentMgr.h"

46
Sources/Tools/MaxMain/plAgeDescInterface.cpp

@ -40,14 +40,11 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
*==LICENSE==*/ *==LICENSE==*/
#include "HeadSpin.h" #include "HeadSpin.h"
#include "plFile/hsFiles.h"
#include "hsStream.h" #include "hsStream.h"
#include "hsTemplates.h" #include "hsTemplates.h"
#include "hsWindows.h" #include "hsWindows.h"
#include <max.h> #include <max.h>
#include <string>
#include <vector>
#include "resource.h" #include "resource.h"
#pragma hdrstop #pragma hdrstop
@ -63,8 +60,6 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#endif #endif
#include "plMaxAccelerators.h" #include "plMaxAccelerators.h"
using std::string;
extern HINSTANCE hInstance; extern HINSTANCE hInstance;
//// Tree Data Wrapper Class ////////////////////////////////////////////////// //// Tree Data Wrapper Class //////////////////////////////////////////////////
@ -72,19 +67,17 @@ extern HINSTANCE hInstance;
class plAgeFile class plAgeFile
{ {
protected: protected:
void IGetAgeName(const char* path) void IGetAgeName(const plFileName& path)
{ {
char name[_MAX_FNAME]; fAgeName = path.GetFileNameNoExt();
_splitpath(path, nil, nil, name, nil);
fAgeName = name;
} }
public: public:
#ifdef MAXASS_VAILABLE #ifdef MAXASS_VAILABLE
jvUniqueId fAssetID; jvUniqueId fAssetID;
#endif #endif
string fPath; plFileName fPath;
string fAgeName; plString fAgeName;
enum Types enum Types
{ {
@ -93,17 +86,16 @@ public:
}; };
Types fType; Types fType;
plAgeFile(Types type) : fType(type), fPath(nil) { } plAgeFile(Types type) : fType(type) { }
plAgeFile(Types type, const char *path) : fType(type) plAgeFile(Types type, const plFileName &path) : fPath(path), fType(type)
{ {
fPath = path;
IGetAgeName(path); IGetAgeName(path);
} }
#ifdef MAXASS_AVAILABLE #ifdef MAXASS_AVAILABLE
plAgeFile(Types type, const char *path, jvUniqueId& id) : fType(type), fAssetID(id) plAgeFile(Types type, const plFileName &path, jvUniqueId& id)
: fPath(path), fType(type), fAssetID(id)
{ {
fPath = path;
IGetAgeName(path); IGetAgeName(path);
} }
#endif #endif
@ -716,7 +708,7 @@ void plAgeDescInterface::IUpdateCurAge( void )
else else
#endif #endif
// Load the local age, also check its sequence #s // Load the local age, also check its sequence #s
ILoadAge( currAge->fPath.c_str(), true ); ILoadAge( currAge->fPath, true );
} }
static const int kDefaultCapacity = 10; static const int kDefaultCapacity = 10;
@ -851,19 +843,15 @@ void plAgeDescInterface::IGetAgeFiles(std::vector<plAgeFile*>& ageFiles)
{ {
IClearAgeFiles(ageFiles); IClearAgeFiles(ageFiles);
char agePath[MAX_PATH];
// Make list of "local" ages. This might contain copies of those in AssetMan, so we make the // Make list of "local" ages. This might contain copies of those in AssetMan, so we make the
// list first and take out the ones that are in AssetMan // list first and take out the ones that are in AssetMan
plFileName localPath = IGetLocalAgePath(); plFileName localPath = IGetLocalAgePath();
if (localPath.IsValid()) if (localPath.IsValid())
{ {
hsFolderIterator ageFolder(localPath.AsString().c_str()); std::vector<plFileName> files = plFileSystem::ListDir(localPath, "*.age");
while (ageFolder.NextFileSuffix(".age")) for (auto iter = files.begin(); iter != files.end(); ++iter)
{ {
ageFolder.GetPathAndName(agePath); plAgeFile* age = new plAgeFile(plAgeFile::kLocalFile, *iter);
plAgeFile* age = new plAgeFile(plAgeFile::kLocalFile, agePath);
ageFiles.push_back(age); ageFiles.push_back(age);
} }
} }
@ -881,6 +869,7 @@ void plAgeDescInterface::IGetAgeFiles(std::vector<plAgeFile*>& ageFiles)
{ {
if( doneAssets.Find( (*assets)[ i ] ) == doneAssets.kMissingIndex ) if( doneAssets.Find( (*assets)[ i ] ) == doneAssets.kMissingIndex )
{ {
char agePath[MAX_PATH];
if (assetMan->GetLatestVersionFile((*assets)[i], agePath, sizeof(agePath))) if (assetMan->GetLatestVersionFile((*assets)[i], agePath, sizeof(agePath)))
{ {
plAgeFile* age = new plAgeFile(plAgeFile::kAssetFile, agePath, (*assets)[i]); plAgeFile* age = new plAgeFile(plAgeFile::kAssetFile, agePath, (*assets)[i]);
@ -911,16 +900,19 @@ void plAgeDescInterface::IClearAgeFiles(std::vector<plAgeFile*>& ageFiles)
ageFiles.clear(); ageFiles.clear();
} }
void plAgeDescInterface::BuildAgeFileList( hsTArray<char *> &ageList ) hsTArray<plFileName> plAgeDescInterface::BuildAgeFileList()
{ {
std::vector<plAgeFile*> tempAgeFiles; std::vector<plAgeFile*> tempAgeFiles;
IGetAgeFiles(tempAgeFiles); IGetAgeFiles(tempAgeFiles);
hsTArray<plFileName> ageList;
for (int i = 0; i < tempAgeFiles.size(); i++) for (int i = 0; i < tempAgeFiles.size(); i++)
{ {
ageList.Push(hsStrcpy(tempAgeFiles[i]->fPath.c_str())); ageList.Push(tempAgeFiles[i]->fPath);
delete tempAgeFiles[ i ]; delete tempAgeFiles[ i ];
} }
return ageList;
} }
//// IFillAgeTree ///////////////////////////////////////////////////////////// //// IFillAgeTree /////////////////////////////////////////////////////////////
@ -1310,7 +1302,7 @@ uint32_t plAgeDescInterface::IGetNextFreeSequencePrefix( bool getReservedPrefix
for( i = 0; i < fAgeFiles.size(); i++ ) for( i = 0; i < fAgeFiles.size(); i++ )
{ {
hsUNIXStream stream; hsUNIXStream stream;
if( stream.Open( fAgeFiles[ i ]->fPath.c_str(), "rt" ) ) if( stream.Open( fAgeFiles[ i ]->fPath, "rt" ) )
{ {
ages[ i ].Read( &stream ); ages[ i ].Read( &stream );
stream.Close(); stream.Close();

2
Sources/Tools/MaxMain/plAgeDescInterface.h

@ -84,7 +84,7 @@ public:
static BOOL CALLBACK ForwardDlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam); static BOOL CALLBACK ForwardDlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam);
BOOL DlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam); BOOL DlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam);
static void BuildAgeFileList( hsTArray<char *> &ageList ); static hsTArray<plFileName> BuildAgeFileList();
protected: protected:
static int IFindAge(const char* ageName, std::vector<plAgeFile*>& ageFiles); static int IFindAge(const char* ageName, std::vector<plAgeFile*>& ageFiles);

18
Sources/Tools/MaxMain/plPythonMgr.cpp

@ -40,9 +40,9 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
*==LICENSE==*/ *==LICENSE==*/
#include "HeadSpin.h" #include "HeadSpin.h"
#include "plFile/hsFiles.h"
#include "plgDispatch.h" #include "plgDispatch.h"
#include "hsWindows.h" #include "hsWindows.h"
#include "plFileSystem.h"
#include <Python.h> #include <Python.h>
#include <string> #include <string>
@ -52,6 +52,8 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include <max.h> #include <max.h>
#pragma hdrstop #pragma hdrstop
#include <direct.h>
#include "plPythonMgr.h" #include "plPythonMgr.h"
#include "plMaxCFGFile.h" #include "plMaxCFGFile.h"
@ -229,7 +231,7 @@ void IExtractVisInfo(PyObject* tuple, int* id, std::vector<std::string>* vec)
} }
} }
bool plPythonMgr::IQueryPythonFile(char *fileName) bool plPythonMgr::IQueryPythonFile(const char *fileName)
{ {
PyObject *module = PyImport_ImportModule(fileName); PyObject *module = PyImport_ImportModule(fileName);
if (module) if (module)
@ -596,8 +598,6 @@ void plPythonMgr::IAddGrassComponent(plAutoUIBlock *autoUI, PyObject *objTuple,
autoUI->AddPickGrassComponentButton(id, nil, paramName.c_str(), vid, vstates); autoUI->AddPickGrassComponentButton(id, nil, paramName.c_str(), vid, vstates);
} }
#include <direct.h>
void plPythonMgr::LoadPythonFiles() void plPythonMgr::LoadPythonFiles()
{ {
plFileName clientPath = plMaxConfig::GetClientPath(false, true); plFileName clientPath = plMaxConfig::GetClientPath(false, true);
@ -612,15 +612,13 @@ void plPythonMgr::LoadPythonFiles()
PythonInterface::initPython(); PythonInterface::initPython();
// Iterate through all the Python files in the folder // Iterate through all the Python files in the folder
hsFolderIterator folder(pythonPath.AsString().c_str()); std::vector<plFileName> pys = plFileSystem::ListDir(pythonPath, "*.py");
while (folder.NextFileSuffix(".py")) for (auto iter = pys.begin(); iter != pys.end(); ++iter)
{ {
// Get the filename without the ".py" (module name) // Get the filename without the ".py" (module name)
const char *fullFileName = folder.GetFileName(); plString fileName = iter->GetFileNameNoExt();
char fileName[_MAX_FNAME];
_splitpath(fullFileName, NULL, NULL, fileName, NULL);
IQueryPythonFile(fileName); IQueryPythonFile(fileName.c_str());
} }
PythonInterface::finiPython(); PythonInterface::finiPython();

2
Sources/Tools/MaxMain/plPythonMgr.h

@ -48,7 +48,7 @@ class plPythonMgr
protected: protected:
plPythonMgr(); plPythonMgr();
bool IQueryPythonFile(char *fileName); bool IQueryPythonFile(const char *fileName);
void IAddBool(plAutoUIBlock *autoUI, PyObject *tuple, char *paramName, int id, int vid, std::vector<std::string>* vstates); void IAddBool(plAutoUIBlock *autoUI, PyObject *tuple, char *paramName, int id, int vid, std::vector<std::string>* vstates);
void IAddInt(plAutoUIBlock *autoUI, PyObject *tuple, char *paramName, int id, int vid, std::vector<std::string>* vstates); void IAddInt(plAutoUIBlock *autoUI, PyObject *tuple, char *paramName, int id, int vid, std::vector<std::string>* vstates);

2
Sources/Tools/MaxSceneViewer/SceneSync.cpp

@ -279,8 +279,6 @@ void SceneSync::IClearDirtyRecur(plMaxNode *node)
IClearDirtyRecur((plMaxNode*)node->GetChildNode(i)); IClearDirtyRecur((plMaxNode*)node->GetChildNode(i));
} }
#include "../plFile/hsFiles.h"
void SceneSync::IDeletePath(const char *path) void SceneSync::IDeletePath(const char *path)
{ {
// Remove any files in the dat directory // Remove any files in the dat directory

23
Sources/Tools/plResBrowser/plResBrowserWndProc.cpp

@ -53,7 +53,6 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "plResMgr/plResManager.h" #include "plResMgr/plResManager.h"
#include "plResMgr/plResMgrSettings.h" #include "plResMgr/plResMgrSettings.h"
#include "plWinRegistryTools.h" #include "plWinRegistryTools.h"
#include "plFile/hsFiles.h"
#define IDC_REGTREEVIEW 1000 #define IDC_REGTREEVIEW 1000
@ -139,14 +138,10 @@ LRESULT CALLBACK HandleCommand( HWND hWnd, WPARAM wParam, LPARAM lParam )
// Load that source // Load that source
plResManager *mgr = (plResManager *)hsgResMgr::ResMgr(); plResManager *mgr = (plResManager *)hsgResMgr::ResMgr();
hsFolderIterator pathIterator(path); std::vector<plFileName> prpFiles = plFileSystem::ListDir(path, "*.prp");
while (pathIterator.NextFileSuffix(".prp")) for (auto iter = prpFiles.begin(); iter != prpFiles.end(); ++iter)
{ mgr->AddSinglePage(*iter);
char fileName[kFolderIterator_MaxPath];
pathIterator.GetPathAndName(fileName);
mgr->AddSinglePage(fileName);
}
plResTreeView::FillTreeViewFromRegistry( gTreeView ); plResTreeView::FillTreeViewFromRegistry( gTreeView );
SetWindowTitle( hWnd, path ); SetWindowTitle( hWnd, path );
@ -388,13 +383,9 @@ LRESULT CALLBACK WndProc( HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam
( (char *)PathFindExtension( path ) )[ 0 ] == 0 ) ( (char *)PathFindExtension( path ) )[ 0 ] == 0 )
{ {
// Must be a directory // Must be a directory
hsFolderIterator pathIterator(path); std::vector<plFileName> prpFiles = plFileSystem::ListDir(path, "*.prp");
while (pathIterator.NextFileSuffix(".prp")) for (auto iter = prpFiles.begin(); iter != prpFiles.end(); ++iter)
{ mgr->AddSinglePage(*iter);
char fileName[kFolderIterator_MaxPath];
pathIterator.GetPathAndName(fileName);
mgr->AddSinglePage(fileName);
}
} }
else else
{ {

Loading…
Cancel
Save