mirror of
https://foundry.openuru.org/gitblit/r/CWE-ou-minkata.git
synced 2025-07-14 02:27:40 -04:00
Remove hsFiles in favor of plFilesystem stuff
This commit is contained in:
@ -83,7 +83,6 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
#include "pfConsole/pfConsoleDirSrc.h"
|
||||
#include "plScene/plPageTreeMgr.h"
|
||||
#include "plScene/plVisMgr.h"
|
||||
#include "plFile/hsFiles.h"
|
||||
|
||||
#include "pfKI/pfKI.h"
|
||||
|
||||
@ -1635,19 +1634,17 @@ void plClient::IPatchGlobalAgeFiles( void )
|
||||
void plClient::InitDLLs()
|
||||
{
|
||||
hsStatusMessage("Init dlls client\n");
|
||||
char str[255];
|
||||
typedef void (*PInitGlobalsFunc) (hsResMgr *, plFactory *, plTimerCallbackManager *, plTimerShare*,
|
||||
plNetClientApp*);
|
||||
|
||||
hsFolderIterator modDllFolder("ModDLL\\");
|
||||
while (modDllFolder.NextFileSuffix(".dll"))
|
||||
std::vector<plFileName> dlls = plFileSystem::ListDir("ModDLL", "*.dll");
|
||||
for (auto iter = dlls.begin(); iter != dlls.end(); ++iter)
|
||||
{
|
||||
modDllFolder.GetPathAndName(str);
|
||||
HMODULE hMod = LoadLibrary(str);
|
||||
HMODULE hMod = LoadLibraryW(iter->AsString().ToWchar());
|
||||
if (hMod)
|
||||
{
|
||||
PInitGlobalsFunc initGlobals = (PInitGlobalsFunc)GetProcAddress(hMod, "InitGlobals");
|
||||
initGlobals(hsgResMgr::ResMgr(), plFactory::GetTheFactory(), plgTimerCallbackMgr::Mgr(),
|
||||
(*initGlobals)(hsgResMgr::ResMgr(), plFactory::GetTheFactory(), plgTimerCallbackMgr::Mgr(),
|
||||
hsTimer::GetTheTimer(), plNetClientApp::GetInstance());
|
||||
fLoadedDLLs.Append(hMod);
|
||||
}
|
||||
@ -2495,7 +2492,7 @@ void plClient::IOnAsyncInitComplete () {
|
||||
|
||||
// run fni in the Aux Init dir
|
||||
if (fpAuxInitDir)
|
||||
{
|
||||
{
|
||||
dirSrc.ParseDirectory(fpAuxInitDir, "net*.fni"); // connect to net first
|
||||
dirSrc.ParseDirectory(fpAuxInitDir, "*.fni");
|
||||
}
|
||||
|
@ -39,25 +39,25 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
Mead, WA 99021
|
||||
|
||||
*==LICENSE==*/
|
||||
#include "plFile/hsFiles.h"
|
||||
#include "plFile/plEncryptedStream.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() {
|
||||
printf("%s\n\n", plProduct::ProductString().c_str());
|
||||
puts(plProduct::ProductString().c_str());
|
||||
puts("");
|
||||
}
|
||||
|
||||
void print_help() {
|
||||
printf("plFileEncrypt - Encrypts and Decrypts Uru Files.\n\n");
|
||||
puts("plFileEncrypt - Encrypts and Decrypts Uru Files.\n");
|
||||
print_version();
|
||||
printf("Usage: plFileEncrypt \t[(encrypt|-e)|(decrypt|-d|)|(--help|-h|-?|/h)|(-v)]\n");
|
||||
printf("\tencrypt|-e\t - Encrypts All .age, .fni, .ini, .csv, and .sdl files in the current folder.\n");
|
||||
printf("\tdecrypt|-d\t - Decrypts All .age, .fni, .ini, .csv, and .sdl files in the current folder.\n");
|
||||
printf("\t--help|-h|-?|/h\t - Prints Help. This Screen.\n");
|
||||
printf("\t-v|--version\t - Prints build version information\n");
|
||||
puts("Usage: plFileEncrypt \t[(encrypt|-e)|(decrypt|-d|)|(--help|-h|-?|/h)|(-v)]");
|
||||
puts("\tencrypt|-e\t - Encrypts All .age, .fni, .ini, .csv, and .sdl files in the current folder.");
|
||||
puts("\tdecrypt|-d\t - Decrypts All .age, .fni, .ini, .csv, and .sdl files in the current folder.");
|
||||
puts("\t--help|-h|-?|/h\t - Prints Help. This Screen.");
|
||||
puts("\t-v|--version\t - Prints build version information");
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
@ -87,37 +87,34 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
else if (ARGCMP("-v") || ARGCMP("--version"))
|
||||
{
|
||||
print_version();
|
||||
print_version();
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
#undef ARGCMP
|
||||
|
||||
EncryptFiles(dir, ".age", encrypt);
|
||||
EncryptFiles(dir, ".fni", encrypt);
|
||||
EncryptFiles(dir, ".ini", encrypt);
|
||||
EncryptFiles(dir, ".sdl", encrypt);
|
||||
EncryptFiles(dir, ".csv", encrypt);
|
||||
EncryptFiles(dir, "*.age", encrypt);
|
||||
EncryptFiles(dir, "*.fni", encrypt);
|
||||
EncryptFiles(dir, "*.ini", encrypt);
|
||||
EncryptFiles(dir, "*.sdl", encrypt);
|
||||
EncryptFiles(dir, "*.csv", encrypt);
|
||||
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];
|
||||
|
||||
hsFolderIterator folder(dir);
|
||||
while (folder.NextFileSuffix(ext))
|
||||
std::vector<plFileName> files = plFileSystem::ListDir(dir, ext);
|
||||
for (auto iter = files.begin(); iter != files.end(); ++iter)
|
||||
{
|
||||
folder.GetPathAndName(filePath);
|
||||
if (encrypt)
|
||||
{
|
||||
printf("encrypting: %s\n", folder.GetFileName());
|
||||
plEncryptedStream::FileEncrypt(filePath);
|
||||
printf("encrypting: %s\n", iter->GetFileName().c_str());
|
||||
plEncryptedStream::FileEncrypt(*iter);
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("decrypting: %s\n", folder.GetFileName());
|
||||
plEncryptedStream::FileDecrypt(filePath);
|
||||
printf("decrypting: %s\n", iter->GetFileName().c_str());
|
||||
plEncryptedStream::FileDecrypt(*iter);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -39,7 +39,6 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
Mead, WA 99021
|
||||
|
||||
*==LICENSE==*/
|
||||
#include "plFile/hsFiles.h"
|
||||
#include "plFile/plSecureStream.h"
|
||||
#include "plProduct.h"
|
||||
|
||||
@ -48,26 +47,27 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
#include <string>
|
||||
|
||||
void print_version() {
|
||||
printf("%s\n\n", plProduct::ProductString().c_str());
|
||||
puts(plProduct::ProductString().c_str());
|
||||
puts("");
|
||||
}
|
||||
|
||||
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();
|
||||
printf("Usage:\n");
|
||||
printf("\tplFileSecure (<directory> <ext>)|[/generate /default]\n");
|
||||
printf("\n");
|
||||
printf("<directory> <ext> : The directory and extension of files to secure. Cannot\n");
|
||||
puts ("Usage:");
|
||||
puts ("\tplFileSecure (<directory> <ext>)|[/generate /default]");
|
||||
puts ("");
|
||||
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(" 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(" file in the current directory. Cannot be used with\n");
|
||||
printf(" <directory> <ext>\n");
|
||||
puts (" file in the current directory. Cannot be used with");
|
||||
puts (" <directory> <ext>");
|
||||
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");
|
||||
printf(" secures with the default key instead of the\n");
|
||||
puts (" with the default key. If used with <directory> <ext>, it");
|
||||
puts (" secures with the default key instead of the");
|
||||
printf(" %s file's key\n", plSecureStream::kKeyFilename);
|
||||
printf("\n");
|
||||
puts ("");
|
||||
}
|
||||
|
||||
void GenerateKey(bool useDefault)
|
||||
@ -105,16 +105,13 @@ void GenerateKey(bool useDefault)
|
||||
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];
|
||||
|
||||
hsFolderIterator folder(dir.c_str());
|
||||
while (folder.NextFileSuffix(ext.c_str()))
|
||||
std::vector<plFileName> files = plFileSystem::ListDir(dir, ext.c_str());
|
||||
for (auto iter = files.begin(); iter != files.end(); ++iter)
|
||||
{
|
||||
folder.GetPathAndName(filePath);
|
||||
printf("securing: %s\n", folder.GetFileName());
|
||||
plSecureStream::FileEncrypt(filePath, key);
|
||||
printf("securing: %s\n", iter->GetFileName());
|
||||
plSecureStream::FileEncrypt(*iter, key);
|
||||
}
|
||||
}
|
||||
|
||||
@ -122,8 +119,8 @@ int main(int argc, char *argv[])
|
||||
{
|
||||
bool generatingKey = false;
|
||||
bool useDefault = false;
|
||||
std::string directory;
|
||||
std::string ext;
|
||||
plFileName directory;
|
||||
plString ext;
|
||||
|
||||
if (argc > 1)
|
||||
{
|
||||
@ -163,9 +160,9 @@ int main(int argc, char *argv[])
|
||||
else
|
||||
{
|
||||
// else it is a directory or extension
|
||||
if (directory == "")
|
||||
if (!directory.IsValid())
|
||||
directory = argv[i];
|
||||
else if (ext == "")
|
||||
else if (ext.IsEmpty())
|
||||
ext = argv[i];
|
||||
else
|
||||
{
|
||||
@ -175,7 +172,7 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
}
|
||||
|
||||
if (generatingKey && ((directory != "") || (ext != "")))
|
||||
if (generatingKey && ((directory.IsValid()) || (!ext.IsEmpty())))
|
||||
{
|
||||
print_help();
|
||||
return 0;
|
||||
@ -193,8 +190,11 @@ int main(int argc, char *argv[])
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (ext[0] != '.')
|
||||
ext = "." + ext; // tack on the dot if necessary
|
||||
// Make sure ext is a real pattern, or we won't find anything
|
||||
if (ext.CharAt(0) == '.')
|
||||
ext = "*" + ext;
|
||||
else if (ext.CharAt(0) != '*')
|
||||
ext = "*." + ext;
|
||||
|
||||
if (useDefault)
|
||||
SecureFiles(directory, ext, nil);
|
||||
|
@ -41,7 +41,6 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
*==LICENSE==*/
|
||||
|
||||
#include "hsTimer.h"
|
||||
#include "plFile/hsFiles.h"
|
||||
#include "plResMgr/plResManager.h"
|
||||
#include "plResMgr/plResMgrSettings.h"
|
||||
|
||||
|
@ -45,10 +45,11 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
#include "eval.h"
|
||||
#include "marshal.h"
|
||||
#include "cStringIO.h"
|
||||
#include "plFileSystem.h"
|
||||
|
||||
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 ( Py_IsInitialized() == 0 )
|
||||
@ -77,27 +78,27 @@ void PythonInterface::initPython(std::string rootDir)
|
||||
PyObject* sys_dict = PyModule_GetDict(sysmod);
|
||||
if (stdFile != nil)
|
||||
{
|
||||
PyDict_SetItemString(sys_dict,"stdout", stdFile);
|
||||
PyDict_SetItemString(sys_dict,"stderr", stdFile);
|
||||
PyDict_SetItemString(sys_dict, "stdout", stdFile);
|
||||
PyDict_SetItemString(sys_dict, "stderr", stdFile);
|
||||
}
|
||||
// NOTE: we will reset the path to not include paths
|
||||
// ...that Python may have found in the registery
|
||||
PyObject* path_list = PyList_New(0);
|
||||
printf("Setting up include dirs:\n");
|
||||
printf("%s\n",rootDir.c_str());
|
||||
PyObject* more_path = PyString_FromString(rootDir.c_str());
|
||||
printf("%s\n", rootDir.AsString().c_str());
|
||||
PyObject* more_path = PyString_FromString(rootDir.AsString().c_str());
|
||||
PyList_Append(path_list, more_path);
|
||||
// make sure that our plasma libraries are gotten before the system ones
|
||||
std::string temp = rootDir + "plasma";
|
||||
printf("%s\n",temp.c_str());
|
||||
PyObject* more_path3 = PyString_FromString(temp.c_str());
|
||||
plFileName temp = plFileName::Join(rootDir, "plasma");
|
||||
printf("%s\n", temp.AsString().c_str());
|
||||
PyObject* more_path3 = PyString_FromString(temp.AsString().c_str());
|
||||
PyList_Append(path_list, more_path3);
|
||||
temp = rootDir + "system";
|
||||
printf("%s\n\n",temp.c_str());
|
||||
temp = plFileName::Join(rootDir, "system");
|
||||
printf("%s\n\n", temp.AsString().c_str());
|
||||
PyObject* more_path2 = PyString_FromString("system");
|
||||
PyList_Append(path_list, more_path2);
|
||||
// set the path to be this one
|
||||
PyDict_SetItemString(sys_dict,"path",path_list);
|
||||
PyDict_SetItemString(sys_dict, "path", path_list);
|
||||
|
||||
|
||||
Py_DECREF(sysmod);
|
||||
@ -106,7 +107,7 @@ void PythonInterface::initPython(std::string rootDir)
|
||||
// initialized++;
|
||||
}
|
||||
|
||||
void PythonInterface::addPythonPath(std::string path)
|
||||
void PythonInterface::addPythonPath(const plFileName& path)
|
||||
{
|
||||
PyObject* sysmod = PyImport_ImportModule("sys");
|
||||
if (sysmod != NULL)
|
||||
@ -114,8 +115,8 @@ void PythonInterface::addPythonPath(std::string path)
|
||||
PyObject* sys_dict = PyModule_GetDict(sysmod);
|
||||
PyObject* path_list = PyDict_GetItemString(sys_dict, "path");
|
||||
|
||||
printf("Adding path %s\n", path.c_str());
|
||||
PyObject* more_path = PyString_FromString(path.c_str());
|
||||
printf("Adding path %s\n", path.AsString().c_str());
|
||||
PyObject* more_path = PyString_FromString(path.AsString().c_str());
|
||||
PyList_Append(path_list, more_path);
|
||||
|
||||
Py_DECREF(sysmod);
|
||||
@ -138,9 +139,9 @@ void PythonInterface::finiPython()
|
||||
//
|
||||
// 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;
|
||||
}
|
||||
|
||||
|
@ -44,14 +44,16 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
|
||||
#include <string>
|
||||
|
||||
class plFileName;
|
||||
|
||||
namespace PythonInterface
|
||||
{
|
||||
void initPython(std::string rootDir);
|
||||
void initPython(const plFileName& rootDir);
|
||||
void finiPython();
|
||||
// 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);
|
||||
int getOutputAndReset(char** line=nil);
|
||||
PyObject* CreateModule(const char* module);
|
||||
|
@ -42,7 +42,6 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
#include "PythonInterface.h"
|
||||
|
||||
#include "hsStream.h"
|
||||
#include "plFile/hsFiles.h"
|
||||
|
||||
#include <vector>
|
||||
#include <string>
|
||||
@ -71,25 +70,24 @@ static const char* kPackFileName = "python.pak";
|
||||
#endif
|
||||
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;
|
||||
std::string filePath;
|
||||
size_t filestart = fileName.find_last_of('.');
|
||||
if(filestart != std::string::npos)
|
||||
filePath = fileName.substr(filestart+1, std::string::npos);
|
||||
plFileName filePath;
|
||||
size_t filestart = fileName.AsString().FindLast('.');
|
||||
if (filestart >= 0)
|
||||
filePath = fileName.AsString().Substr(filestart+1);
|
||||
else
|
||||
filePath = fileName;
|
||||
filePath += ".py";
|
||||
filePath = path + filePath;
|
||||
filePath = plFileName::Join(path, filePath + ".py");
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
printf("==Packing %s, ",fileName.c_str());
|
||||
printf("==Packing %s, ", fileName.AsString().c_str());
|
||||
|
||||
pyStream.FastFwd();
|
||||
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
|
||||
PyImport_ImportModule(fileName.c_str());
|
||||
PyObject* pythonCode = PythonInterface::CompileString(code, fileName.c_str());
|
||||
PyImport_ImportModule(fileName.AsString().c_str());
|
||||
PyObject* pythonCode = PythonInterface::CompileString(code, fileName);
|
||||
if (pythonCode)
|
||||
{
|
||||
// we need to find out if this is PythonFile module
|
||||
// create a module name... with the '.' as an X
|
||||
// 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
|
||||
if (PythonInterface::RunPYC(pythonCode, fModule) )
|
||||
{
|
||||
// set the name of the file (in the global dictionary of the module)
|
||||
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);
|
||||
// next we need to:
|
||||
// - create instance of class
|
||||
@ -167,7 +165,7 @@ void WritePythonFile(std::string fileName, std::string path, hsStream *s)
|
||||
// else
|
||||
// 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???");
|
||||
printf("an import file ");
|
||||
}
|
||||
@ -227,23 +225,15 @@ void WritePythonFile(std::string fileName, std::string path, hsStream *s)
|
||||
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
|
||||
hsFolderIterator folder;
|
||||
std::vector<plFileName> pys = plFileSystem::ListDir(path, "*.py");
|
||||
|
||||
// if there is a path... set it
|
||||
if ( path )
|
||||
folder.SetPath(path);
|
||||
|
||||
while (folder.NextFileSuffix(".py"))
|
||||
for (auto iter = pys.begin(); iter != pys.end(); ++iter)
|
||||
{
|
||||
const char *fileName = folder.GetFileName();
|
||||
filenames.push_back(fileName);
|
||||
if ( path )
|
||||
pathnames.push_back(path);
|
||||
else
|
||||
pathnames.push_back("");
|
||||
filenames.push_back(iter->GetFileName());
|
||||
pathnames.push_back(path);
|
||||
}
|
||||
}
|
||||
|
||||
@ -260,22 +250,13 @@ std::string ToLowerCase(std::string str)
|
||||
return retVal;
|
||||
}
|
||||
|
||||
void FindSubDirs(std::vector<std::string> &dirnames, const char *path)
|
||||
void FindSubDirs(std::vector<plFileName> &dirnames, const plFileName &path)
|
||||
{
|
||||
hsFolderIterator folder;
|
||||
if (path)
|
||||
folder.SetPath(path);
|
||||
|
||||
while (folder.NextFile())
|
||||
{
|
||||
if (folder.IsDirectory())
|
||||
{
|
||||
std::string dirName = folder.GetFileName();
|
||||
if ((dirName != ".")&&(dirName != "..")&&(ToLowerCase(dirName) != "system") && (ToLowerCase(dirName) != "plasma"))
|
||||
{
|
||||
dirnames.push_back(dirName);
|
||||
}
|
||||
}
|
||||
std::vector<plFileName> subdirs = plFileSystem::ListSubdirs(path);
|
||||
for (auto iter = subdirs.begin(); iter != subdirs.end(); ++iter) {
|
||||
plString name = iter->GetFileName();
|
||||
if (name.CompareI("system") != 0 && name.CompareI("plasma") != 0)
|
||||
dirnames.push_back(name);
|
||||
}
|
||||
}
|
||||
|
||||
@ -343,66 +324,62 @@ std::string ConcatDirs(std::string fullPath, std::string partialPath)
|
||||
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);
|
||||
for (int i = 0; i < packages.size(); i++)
|
||||
{
|
||||
std::string packageName;
|
||||
if(!parent_package.empty())
|
||||
plString packageName;
|
||||
if (!parent_package.IsEmpty())
|
||||
packageName = parent_package + ".";
|
||||
packageName += packages[i];
|
||||
std::vector<std::string> packageFileNames;
|
||||
std::vector<std::string> packagePathNames;
|
||||
std::string packagePath = path;
|
||||
packagePath += "/" + packages[i];
|
||||
FindFiles(packageFileNames, packagePathNames, packagePath.c_str());
|
||||
packageName += packages[i].AsString();
|
||||
std::vector<plFileName> packageFileNames;
|
||||
std::vector<plFileName> packagePathNames;
|
||||
plFileName packagePath = plFileName::Join(path, packages[i]);
|
||||
FindFiles(packageFileNames, packagePathNames, packagePath);
|
||||
for (int j = 0; j < packageFileNames.size(); j++) {
|
||||
fileNames.push_back(packageName+"."+packageFileNames[j]);
|
||||
pathNames.push_back(packagePathNames[j]+"/");
|
||||
fileNames.push_back(packageName+"."+packageFileNames[j].AsString());
|
||||
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
|
||||
dir = AdjustEndingSlash(dir,true);
|
||||
|
||||
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("\nCreating %s using the contents of %s\n", pakName.AsString().c_str(), dir.AsString().c_str());
|
||||
printf("Changing working directory to %s\n", rootPath.AsString().c_str());
|
||||
if (!plFileSystem::SetCWD(rootPath))
|
||||
{
|
||||
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");
|
||||
return;
|
||||
}
|
||||
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<std::string> pathNames;
|
||||
std::vector<plFileName> fileNames;
|
||||
std::vector<plFileName> pathNames;
|
||||
|
||||
FindFiles(fileNames,pathNames,dir.c_str());
|
||||
FindPackages(fileNames,pathNames,dir.c_str());
|
||||
FindFiles(fileNames, pathNames, dir);
|
||||
FindPackages(fileNames, pathNames, dir);
|
||||
if (packSysAndPlasma)
|
||||
{
|
||||
printf("Adding the system and plasma directories to this pack file\n");
|
||||
std::string tempPath;
|
||||
tempPath = dir + "system/";
|
||||
FindFiles(fileNames,pathNames,tempPath.c_str());
|
||||
FindPackages(fileNames,pathNames,tempPath.c_str());
|
||||
tempPath = dir + "plasma/";
|
||||
FindFiles(fileNames,pathNames,tempPath.c_str());
|
||||
FindPackages(fileNames,pathNames,tempPath.c_str());
|
||||
plFileName tempPath;
|
||||
tempPath = plFileName::Join(dir, "system");
|
||||
FindFiles(fileNames, pathNames, tempPath);
|
||||
FindPackages(fileNames, pathNames, tempPath);
|
||||
tempPath = plFileName::Join(dir, "plasma");
|
||||
FindFiles(fileNames, pathNames, tempPath);
|
||||
FindPackages(fileNames, pathNames, tempPath);
|
||||
}
|
||||
|
||||
|
||||
// ok, we know how many files we're gonna pack, so make a fake index (we'll fill in later)
|
||||
hsUNIXStream s;
|
||||
if (!s.Open(pakName.c_str(), "wb"))
|
||||
if (!s.Open(pakName, "wb"))
|
||||
return;
|
||||
|
||||
s.WriteLE32(fileNames.size());
|
||||
@ -410,13 +387,13 @@ void PackDirectory(std::string dir, std::string rootPath, std::string pakName, s
|
||||
int i;
|
||||
for (i = 0; i < fileNames.size(); i++)
|
||||
{
|
||||
s.WriteSafeString(fileNames[i].c_str());
|
||||
s.WriteSafeString(fileNames[i].AsString());
|
||||
s.WriteLE32(0);
|
||||
}
|
||||
|
||||
PythonInterface::initPython(rootPath);
|
||||
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)
|
||||
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++)
|
||||
{
|
||||
// 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();
|
||||
WritePythonFile(properFileName, pathNames[i], &s);
|
||||
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));
|
||||
for (i = 0; i < fileNames.size(); i++)
|
||||
{
|
||||
s.WriteSafeString(fileNames[i].c_str());
|
||||
s.WriteSafeString(fileNames[i].AsString());
|
||||
s.WriteLE32(filePositions[i]);
|
||||
}
|
||||
|
||||
@ -459,9 +436,7 @@ int main(int argc, char *argv[])
|
||||
{
|
||||
printf("The Python Pack Utility\n");
|
||||
|
||||
char buffer[MAXPATHLEN];
|
||||
getcwd(buffer, MAXPATHLEN);
|
||||
std::string baseWorkingDir = buffer;
|
||||
plFileName baseWorkingDir = plFileSystem::GetCWD();
|
||||
|
||||
// are they asking for usage?
|
||||
if (argc == 2)
|
||||
@ -482,26 +457,25 @@ int main(int argc, char *argv[])
|
||||
return -1;
|
||||
}
|
||||
|
||||
std::vector<std::string> dirNames;
|
||||
std::string rootPath;
|
||||
std::vector<plFileName> dirNames;
|
||||
plFileName rootPath;
|
||||
|
||||
if (argc == 1)
|
||||
{
|
||||
FindSubDirs(dirNames,nil);
|
||||
rootPath = AdjustEndingSlash(baseWorkingDir,true);
|
||||
FindSubDirs(dirNames, "");
|
||||
rootPath = baseWorkingDir;
|
||||
}
|
||||
else
|
||||
{
|
||||
std::string path = argv[1];
|
||||
FindSubDirs(dirNames,argv[1]);
|
||||
rootPath = ConcatDirs(baseWorkingDir,path);
|
||||
rootPath = AdjustEndingSlash(rootPath,true);
|
||||
plFileName path = argv[1];
|
||||
FindSubDirs(dirNames, argv[1]);
|
||||
rootPath = plFileName::Join(baseWorkingDir, path);
|
||||
}
|
||||
|
||||
PackDirectory(rootPath,rootPath,rootPath+kPackFileName,dirNames,true);
|
||||
|
||||
PackDirectory(rootPath, rootPath, plFileName::Join(rootPath, kPackFileName), dirNames, true);
|
||||
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;
|
||||
|
@ -47,7 +47,6 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
|
||||
#include "Pch.h"
|
||||
#include "hsThread.h"
|
||||
#include "plFile/hsFiles.h"
|
||||
#include <algorithm>
|
||||
#pragma hdrstop
|
||||
|
||||
|
@ -297,7 +297,8 @@ bool plFileSystem::Unlink(const plFileName &filename)
|
||||
bool plFileSystem::Move(const plFileName &from, const plFileName &to)
|
||||
{
|
||||
#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
|
||||
if (!Copy(from, to))
|
||||
return false;
|
||||
@ -396,6 +397,46 @@ std::vector<plFileName> plFileSystem::ListDir(const plFileName &path, const char
|
||||
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()
|
||||
{
|
||||
|
@ -312,6 +312,11 @@ namespace plFileSystem
|
||||
std::vector<plFileName> ListDir(const plFileName &path,
|
||||
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
|
||||
* create it.
|
||||
*/
|
||||
|
@ -155,7 +155,6 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
#include "plUnifiedTime/plUnifiedTime.h"
|
||||
//end for agedefn test
|
||||
|
||||
#include "plFile/hsFiles.h"
|
||||
#include "pnSceneObject/plAudioInterface.h"
|
||||
|
||||
#include "plStatusLog/plStatusLog.h"
|
||||
@ -3932,32 +3931,6 @@ PF_CONSOLE_CMD( Nav, PageInNode, // Group name, Function name
|
||||
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
|
||||
|
||||
|
||||
|
@ -84,8 +84,6 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
#include "plUnifiedTime/plUnifiedTime.h"
|
||||
//end for agedefn test
|
||||
|
||||
#include "plFile/hsFiles.h"
|
||||
|
||||
#include "plStatusLog/plStatusLog.h"
|
||||
|
||||
#include "hsTemplates.h"
|
||||
|
@ -51,7 +51,6 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
|
||||
#include "plResMgr/plLocalization.h"
|
||||
|
||||
#include "plFile/hsFiles.h"
|
||||
#include "plFile/plEncryptedStream.h"
|
||||
#include "plStatusLog/plStatusLog.h"
|
||||
|
||||
@ -645,19 +644,16 @@ void LocalizationDatabase::Parse(const plFileName & directory)
|
||||
fDirectory = directory;
|
||||
fFiles.clear();
|
||||
|
||||
char filename[255];
|
||||
hsFolderIterator xmlFolder(directory.AsString().c_str());
|
||||
while (xmlFolder.NextFileSuffix(".loc"))
|
||||
std::vector<plFileName> locFiles = plFileSystem::ListDir(directory, "*.loc");
|
||||
for (auto iter = locFiles.begin(); iter != locFiles.end(); ++iter)
|
||||
{
|
||||
xmlFolder.GetPathAndName(filename);
|
||||
|
||||
LocalizationXMLFile newFile;
|
||||
bool retVal = newFile.Parse(filename);
|
||||
bool retVal = newFile.Parse(*iter);
|
||||
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);
|
||||
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();
|
||||
|
@ -51,7 +51,6 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
|
||||
#include "plPythonPack.h"
|
||||
|
||||
#include "plFile/hsFiles.h"
|
||||
#include "plFile/plSecureStream.h"
|
||||
#include "plFile/plStreamSource.h"
|
||||
|
||||
|
@ -43,7 +43,6 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
#include "hsStream.h"
|
||||
#include "plAgeDescription.h"
|
||||
|
||||
#include "plFile/hsFiles.h"
|
||||
#include "plFile/plInitFileReader.h"
|
||||
#include "plFile/plEncryptedStream.h"
|
||||
#include "hsStringTokenizer.h"
|
||||
|
@ -51,7 +51,6 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
#include "plAgeManifest.h"
|
||||
|
||||
|
||||
#include "plFile/hsFiles.h"
|
||||
#include "plFile/plInitFileReader.h"
|
||||
#include "hsStringTokenizer.h"
|
||||
|
||||
|
@ -44,7 +44,6 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
#include "hsGeometry3.h"
|
||||
#include "plgDispatch.h"
|
||||
#include "plProfile.h"
|
||||
#include "plFile/hsFiles.h"
|
||||
|
||||
#include "plWin32Sound.h"
|
||||
#include "plWin32StreamingSound.h"
|
||||
|
@ -55,7 +55,6 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
#include "plAudioCore.h"
|
||||
//#include "hsTimer.h"
|
||||
|
||||
#include "plFile/hsFiles.h"
|
||||
#include "plUnifiedTime/plUnifiedTime.h"
|
||||
#include "plBufferedFileReader.h"
|
||||
#include "plCachedFileReader.h"
|
||||
|
@ -49,7 +49,6 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
#include "plgDispatch.h"
|
||||
#include "hsResMgr.h"
|
||||
#include "pnMessage/plRefMsg.h"
|
||||
#include "plFile/hsFiles.h"
|
||||
#include "plUnifiedTime/plUnifiedTime.h"
|
||||
#include "plStatusLog/plStatusLog.h"
|
||||
#include "hsTimer.h"
|
||||
|
@ -5,7 +5,6 @@ include_directories("../../PubUtilLib")
|
||||
include_directories(${ZLIB_INCLUDE_DIR})
|
||||
|
||||
set(plFile_SOURCES
|
||||
hsFiles.cpp
|
||||
plBrowseFolder.cpp
|
||||
plEncryptedStream.cpp
|
||||
plInitFileReader.cpp
|
||||
@ -13,16 +12,7 @@ set(plFile_SOURCES
|
||||
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
|
||||
hsFiles.h
|
||||
plBrowseFolder.h
|
||||
plEncryptedStream.h
|
||||
plInitFileReader.h
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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
|
@ -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
|
||||
|
@ -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
|
@ -41,7 +41,6 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
*==LICENSE==*/
|
||||
|
||||
#include <string>
|
||||
#include "hsFiles.h"
|
||||
#include "plStreamSource.h"
|
||||
#include "plSecureStream.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
|
||||
std::vector<plFileName> retVal;
|
||||
decltype(fFileData.begin()) curData;
|
||||
for (curData = fFileData.begin(); curData != fFileData.end(); curData++)
|
||||
for (auto curData = fFileData.begin(); curData != fFileData.end(); curData++)
|
||||
{
|
||||
if ((curData->second.fDir == sDir) && (curData->second.fExt == ext))
|
||||
retVal.push_back(curData->second.fFilename);
|
||||
@ -116,15 +114,11 @@ std::vector<plFileName> plStreamSource::GetListOfNames(const plFileName& dir, co
|
||||
#ifndef PLASMA_EXTERNAL_RELEASE
|
||||
// in internal releases, we can use on-disk files if they exist
|
||||
// Build the search string as "dir/*.ext"
|
||||
plString searchStr = plFileName::Join(sDir, "*." + ext).AsString();
|
||||
|
||||
hsFolderIterator folderIter(searchStr.c_str(), true);
|
||||
while (folderIter.NextFile())
|
||||
std::vector<plFileName> files = plFileSystem::ListDir(sDir, ("*." + ext).c_str());
|
||||
for (auto iter = files.begin(); iter != files.end(); ++iter)
|
||||
{
|
||||
plFileName filename = plFileName::Join(sDir, folderIter.GetFileName());
|
||||
|
||||
if (fFileData.find(filename) == fFileData.end()) // we haven't added it yet
|
||||
retVal.push_back(filename);
|
||||
if (fFileData.find(*iter) == fFileData.end()) // we haven't added it yet
|
||||
retVal.push_back(*iter);
|
||||
}
|
||||
#endif // PLASMA_EXTERNAL_RELEASE
|
||||
|
||||
|
@ -1063,7 +1063,7 @@ uint8_t *plFont::IGetFreeCharData( uint32_t &newOffset )
|
||||
//// LoadFromP2FFile //////////////////////////////////////////////////////////
|
||||
// Handy quick wrapper
|
||||
|
||||
bool plFont::LoadFromP2FFile( const char *path )
|
||||
bool plFont::LoadFromP2FFile( const plFileName &path )
|
||||
{
|
||||
hsUNIXStream stream;
|
||||
if( stream.Open( path, "rb" ) )
|
||||
|
@ -289,7 +289,7 @@ class plFont : public hsKeyedObject
|
||||
bool LoadFromBDF( const char *path, plBDFConvertCallback *callback );
|
||||
bool LoadFromBDFStream( hsStream *stream, plBDFConvertCallback *callback );
|
||||
|
||||
bool LoadFromP2FFile( const char *path );
|
||||
bool LoadFromP2FFile( const plFileName &path );
|
||||
|
||||
bool ReadRaw( hsStream *stream );
|
||||
bool WriteRaw( hsStream *stream );
|
||||
|
@ -57,7 +57,6 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
|
||||
#include "plFont.h"
|
||||
#include "plStatusLog/plStatusLog.h"
|
||||
#include "plFile/hsFiles.h"
|
||||
#include "pnMessage/plRefMsg.h"
|
||||
|
||||
#include "hsResMgr.h"
|
||||
@ -71,7 +70,6 @@ plFontCache *plFontCache::fInstance = nil;
|
||||
|
||||
plFontCache::plFontCache()
|
||||
{
|
||||
fCustFontDir = nil;
|
||||
RegisterAs( kFontCache_KEY );
|
||||
fInstance = this;
|
||||
}
|
||||
@ -79,7 +77,6 @@ plFontCache::plFontCache()
|
||||
plFontCache::~plFontCache()
|
||||
{
|
||||
Clear();
|
||||
delete [] fCustFontDir;
|
||||
fInstance = nil;
|
||||
}
|
||||
|
||||
@ -151,46 +148,38 @@ plFont *plFontCache::GetFont( const char *face, uint8_t size, uint32_t fontFlag
|
||||
return nil;
|
||||
}
|
||||
|
||||
void plFontCache::LoadCustomFonts( const char *dir )
|
||||
void plFontCache::LoadCustomFonts( const plFileName &dir )
|
||||
{
|
||||
delete [] fCustFontDir;
|
||||
fCustFontDir = ( dir != nil ) ? hsStrcpy( dir ) : nil;
|
||||
|
||||
fCustFontDir = dir;
|
||||
ILoadCustomFonts();
|
||||
}
|
||||
|
||||
void plFontCache::ILoadCustomFonts( void )
|
||||
void plFontCache::ILoadCustomFonts( void )
|
||||
{
|
||||
if( fCustFontDir == nil )
|
||||
if (!fCustFontDir.IsValid())
|
||||
return;
|
||||
|
||||
// Iterate through all the custom fonts in our dir
|
||||
hsFolderIterator iter( fCustFontDir );
|
||||
char fileName[ kFolderIterator_MaxPath ];
|
||||
|
||||
|
||||
hsFolderIterator iter2( fCustFontDir );
|
||||
while( iter2.NextFileSuffix( ".p2f" ) )
|
||||
std::vector<plFileName> fonts = plFileSystem::ListDir(fCustFontDir, "*.p2f");
|
||||
for (auto iter = fonts.begin(); iter != fonts.end(); ++iter)
|
||||
{
|
||||
iter2.GetPathAndName( fileName );
|
||||
|
||||
plFont *font = new plFont;
|
||||
if( !font->LoadFromP2FFile( fileName ) )
|
||||
if (!font->LoadFromP2FFile(*iter))
|
||||
delete font;
|
||||
else
|
||||
{
|
||||
plString keyName;
|
||||
if( font->GetKey() == nil )
|
||||
if (font->GetKey() == nil)
|
||||
{
|
||||
keyName = plString::Format( "%s-%d", font->GetFace(), font->GetSize() );
|
||||
hsgResMgr::ResMgr()->NewKey( keyName, font, plLocation::kGlobalFixedLoc );
|
||||
}
|
||||
|
||||
hsgResMgr::ResMgr()->AddViaNotify( font->GetKey(),
|
||||
new plGenRefMsg( GetKey(), plRefMsg::kOnCreate, 0, -1 ),
|
||||
plRefFlags::kActiveRef );
|
||||
hsgResMgr::ResMgr()->AddViaNotify( font->GetKey(),
|
||||
new plGenRefMsg( GetKey(), plRefMsg::kOnCreate, 0, -1 ),
|
||||
plRefFlags::kActiveRef );
|
||||
|
||||
//plStatusLog::AddLineS( "pipeline.log", "FontCache: Added custom font %s", keyName );
|
||||
//plStatusLog::AddLineS( "pipeline.log", "FontCache: Added custom font %s", keyName.c_str() );
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -59,6 +59,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
#include "HeadSpin.h"
|
||||
#include "hsTemplates.h"
|
||||
#include "pnKeyedObject/hsKeyedObject.h"
|
||||
#include "plFileSystem.h"
|
||||
|
||||
|
||||
//// Class Definition /////////////////////////////////////////////////////////
|
||||
@ -69,9 +70,9 @@ class plFontCache : public hsKeyedObject
|
||||
protected:
|
||||
|
||||
hsTArray<plFont *> fCache;
|
||||
char *fCustFontDir;
|
||||
plFileName fCustFontDir;
|
||||
|
||||
static plFontCache *fInstance;
|
||||
static plFontCache *fInstance;
|
||||
|
||||
void ILoadCustomFonts( void );
|
||||
|
||||
@ -96,7 +97,7 @@ class plFontCache : public hsKeyedObject
|
||||
// void FreeFont( HFONT font );
|
||||
void Clear( void );
|
||||
|
||||
void LoadCustomFonts( const char *dir );
|
||||
void LoadCustomFonts( const plFileName &dir );
|
||||
|
||||
// Our custom font extension
|
||||
static const char* kCustFontExtension;
|
||||
|
@ -63,7 +63,6 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
#include "plWinFontCache.h"
|
||||
|
||||
#include "plStatusLog/plStatusLog.h"
|
||||
#include "plFile/hsFiles.h"
|
||||
#include "plGImage/plDynSurfaceWriter.h"
|
||||
|
||||
#if HS_BUILD_FOR_WIN32
|
||||
@ -234,11 +233,11 @@ void plWinFontCache::Clear( void )
|
||||
for( i = 0; i < fCustFonts.GetCount(); i++ )
|
||||
{
|
||||
#if (_WIN32_WINNT >= 0x0500)
|
||||
if( plDynSurfaceWriter::CanHandleLotsOfThem() )
|
||||
RemoveFontResourceEx( fCustFonts[ i ]->fFilename, FR_PRIVATE, 0 );
|
||||
if (plDynSurfaceWriter::CanHandleLotsOfThem())
|
||||
RemoveFontResourceExW(fCustFonts[i]->fFilename.AsString().ToWchar(), FR_PRIVATE, 0);
|
||||
else
|
||||
#endif
|
||||
if( RemoveFontResource( fCustFonts[ i ]->fFilename ) == 0 )
|
||||
if (RemoveFontResourceW(fCustFonts[i]->fFilename.AsString().ToWchar()) == 0)
|
||||
{
|
||||
int q= 0;
|
||||
DWORD e = GetLastError();
|
||||
@ -267,31 +266,27 @@ void plWinFontCache::ILoadCustomFonts( void )
|
||||
return;
|
||||
|
||||
// Iterate through all the custom fonts in our dir
|
||||
hsFolderIterator iter( fCustFontDir );
|
||||
char fileName[ kFolderIterator_MaxPath ];
|
||||
int numAdded;
|
||||
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?"
|
||||
#if (_WIN32_WINNT >= 0x0500)
|
||||
if( plDynSurfaceWriter::CanHandleLotsOfThem() )
|
||||
numAdded = AddFontResourceEx( fileName, FR_PRIVATE, 0 );
|
||||
numAdded = AddFontResourceExW(iter->AsString().ToWchar(), FR_PRIVATE, 0);
|
||||
else
|
||||
#endif
|
||||
numAdded = AddFontResource( fileName );
|
||||
numAdded = AddFontResourceW(iter->AsString().ToWchar());
|
||||
|
||||
if( numAdded > 0 )
|
||||
{
|
||||
plStatusLog::AddLineS( "pipeline.log", "WinFontCache: Added custom font %s, %d fonts", fileName, numAdded );
|
||||
fCustFonts.Append( new plCustFont( fileName ) );
|
||||
plStatusLog::AddLineS( "pipeline.log", "WinFontCache: Added custom font %s, %d fonts", iter->GetFileName().c_str(), numAdded );
|
||||
fCustFonts.Append(new plCustFont(*iter));
|
||||
}
|
||||
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() );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -90,10 +90,9 @@ class plWinFontCache
|
||||
class plCustFont
|
||||
{
|
||||
public:
|
||||
char *fFilename;
|
||||
plFileName fFilename;
|
||||
|
||||
plCustFont( const char *c ) { fFilename = hsStrcpy( c ); }
|
||||
~plCustFont() { delete [] fFilename; }
|
||||
plCustFont(const plFileName &c) { fFilename = c; }
|
||||
};
|
||||
|
||||
bool fInShutdown;
|
||||
|
@ -63,7 +63,6 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
#include "plNetMessage/plNetMessage.h"
|
||||
#include "plAvatar/plAvatarMgr.h"
|
||||
#include "plAvatar/plArmatureMod.h"
|
||||
#include "plFile/hsFiles.h"
|
||||
|
||||
|
||||
/*****************************************************************************
|
||||
@ -305,15 +304,14 @@ void plNetLinkingMgr::SetEnabled( bool b )
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
// static
|
||||
std::string plNetLinkingMgr::GetProperAgeName( const char * ageName )
|
||||
plString plNetLinkingMgr::GetProperAgeName( const plString & ageName )
|
||||
{
|
||||
plNetClientMgr * nc = plNetClientMgr::GetInstance();
|
||||
hsFolderIterator it("dat" PATH_SEPARATOR_STR "*.age", true);
|
||||
while ( it.NextFile() )
|
||||
std::vector<plFileName> files = plFileSystem::ListDir("dat", "*.age");
|
||||
for (auto iter = files.begin(); iter != files.end(); ++iter)
|
||||
{
|
||||
std::string work = it.GetFileName();
|
||||
work.erase( work.find( ".age" ) );
|
||||
if ( stricmp( ageName, work.c_str() )==0 )
|
||||
plString work = iter->GetFileNameNoExt();
|
||||
if (ageName.CompareI(work) == 0)
|
||||
return work;
|
||||
}
|
||||
return ageName;
|
||||
|
@ -158,7 +158,7 @@ public:
|
||||
const plNetServerSessionInfo * GetLobbyServerInfo( void ) const { return &fLobbyInfo;}
|
||||
|
||||
// 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:
|
||||
bool fLinkingEnabled;
|
||||
|
@ -57,7 +57,6 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
#include "plMessage/plAgeLoadedMsg.h"
|
||||
|
||||
#include "plStatusLog/plStatusLog.h"
|
||||
#include "plFile/hsFiles.h"
|
||||
|
||||
plNetClientRecorder::plNetClientRecorder(TimeWrapper* timeWrapper) :
|
||||
fTimeWrapper(timeWrapper)
|
||||
|
@ -47,7 +47,6 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
#include "pnKeyedObject/plKeyImp.h"
|
||||
#include "plStatusLog/plStatusLog.h"
|
||||
#include "pnFactory/plFactory.h"
|
||||
#include "plFile/hsFiles.h"
|
||||
|
||||
#include "plVersion.h"
|
||||
|
||||
|
@ -59,7 +59,6 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
#include "pnMessage/plObjRefMsg.h"
|
||||
#include "plMessage/plAgeLoadedMsg.h"
|
||||
#include "pnMessage/plClientMsg.h"
|
||||
#include "plFile/hsFiles.h"
|
||||
#include "pnFactory/plCreator.h"
|
||||
#include "pnNetCommon/plSynchedObject.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
|
||||
// plRegistryPageNodes to the regTree for each
|
||||
hsFolderIterator pathIterator(fDataPath.AsString().c_str());
|
||||
while (pathIterator.NextFileSuffix(".prp"))
|
||||
std::vector<plFileName> prpFiles = plFileSystem::ListDir(fDataPath, "*.prp");
|
||||
for (auto iter = prpFiles.begin(); iter != prpFiles.end(); ++iter)
|
||||
{
|
||||
char fileName[kFolderIterator_MaxPath];
|
||||
pathIterator.GetPathAndName(fileName);
|
||||
|
||||
plRegistryPageNode* node = new plRegistryPageNode(fileName);
|
||||
plRegistryPageNode* node = new plRegistryPageNode(*iter);
|
||||
plPageInfo pi = node->GetPageInfo();
|
||||
fAllPages[pi.GetLocation()] = node;
|
||||
}
|
||||
|
@ -41,7 +41,6 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
*==LICENSE==*/
|
||||
#include "HeadSpin.h"
|
||||
#include "plSDL.h"
|
||||
#include "plFile/hsFiles.h"
|
||||
#include "plFile/plStreamSource.h"
|
||||
#include "pnNetCommon/pnNetCommon.h"
|
||||
#include "pnNetCommon/plNetApp.h"
|
||||
|
@ -61,7 +61,6 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
#include "hsTemplates.h"
|
||||
#include "hsTimer.h"
|
||||
#include "plStatusLog.h"
|
||||
#include "plFile/hsFiles.h"
|
||||
#include "plUnifiedTime/plUnifiedTime.h"
|
||||
#include "plProduct.h"
|
||||
|
||||
@ -252,29 +251,12 @@ bool plStatusLogMgr::DumpLogs( const plFileName &newFolderName )
|
||||
newPath = newFolderName;
|
||||
plFileSystem::CreateDir(newPath, true);
|
||||
|
||||
#if HS_BUILD_FOR_WIN32
|
||||
hsWFolderIterator folderIterator;
|
||||
if (basePath.IsValid())
|
||||
folderIterator.SetPath(basePath.AsString().ToWchar());
|
||||
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);
|
||||
std::vector<plFileName> files = plFileSystem::ListDir(basePath);
|
||||
for (auto iter = files.begin(); iter != files.end(); ++iter) {
|
||||
plFileName destination = plFileName::Join(newPath, iter->GetFileName());
|
||||
retVal = plFileSystem::Copy(*iter, destination);
|
||||
}
|
||||
#endif
|
||||
|
||||
return retVal;
|
||||
}
|
||||
|
||||
|
@ -60,7 +60,6 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
#include "plAudible.h"
|
||||
#include "plCreatableIndex.h"
|
||||
#include "plgDispatch.h"
|
||||
#include "plFile/hsFiles.h"
|
||||
#include "hsGeometry3.h"
|
||||
#include "plLoadMask.h"
|
||||
#include "hsMatrix44.h"
|
||||
|
@ -42,7 +42,6 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
|
||||
#include "HeadSpin.h"
|
||||
#include "plgDispatch.h"
|
||||
#include "plFile/hsFiles.h"
|
||||
#include "hsTemplates.h"
|
||||
|
||||
#include "plComponent.h"
|
||||
@ -1464,19 +1463,17 @@ BOOL plGUIDialogProc::DlgProc( TimeValue t, IParamMap2 *pmap, HWND hWnd, UINT ms
|
||||
case WM_INITDIALOG:
|
||||
// Load the age combo box
|
||||
{
|
||||
int i, idx, selIdx = 0;
|
||||
HWND ageCombo = GetDlgItem( hWnd, IDC_GUIDLG_AGE );
|
||||
hsTArray<char *> ageList;
|
||||
int i, idx, selIdx = 0;
|
||||
HWND ageCombo = GetDlgItem( hWnd, IDC_GUIDLG_AGE );
|
||||
|
||||
plAgeDescInterface::BuildAgeFileList( ageList );
|
||||
hsTArray<plFileName> ageList = plAgeDescInterface::BuildAgeFileList();
|
||||
ComboBox_ResetContent( ageCombo );
|
||||
for( i = 0; i < ageList.GetCount(); i++ )
|
||||
{
|
||||
char ageName[ _MAX_FNAME ];
|
||||
_splitpath( ageList[ i ], nil, nil, ageName, nil );
|
||||
plString ageName = ageList[i].GetFileNameNoExt();
|
||||
|
||||
idx = ComboBox_AddString( ageCombo, ageName );
|
||||
if( stricmp( ageName, pmap->GetParamBlock()->GetStr( plGUIDialogComponent::kRefAgeName ) ) == 0 )
|
||||
idx = ComboBox_AddString( ageCombo, ageName.c_str() );
|
||||
if( ageName.CompareI( pmap->GetParamBlock()->GetStr( plGUIDialogComponent::kRefAgeName ) ) == 0 )
|
||||
{
|
||||
selIdx = idx;
|
||||
}
|
||||
|
@ -43,7 +43,6 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
#include "HeadSpin.h"
|
||||
#include "plCreatableIndex.h"
|
||||
#include "plgDispatch.h"
|
||||
#include "plFile/hsFiles.h"
|
||||
|
||||
#include "plComponentReg.h"
|
||||
#include "plMiscComponents.h"
|
||||
@ -259,8 +258,7 @@ protected:
|
||||
HWND hAgeCombo = GetDlgItem(fhDlg, IDC_COMP_LOCATION_AGECOMBO);
|
||||
IClearAges( hAgeCombo );
|
||||
|
||||
hsTArray<char *> ageFiles;
|
||||
plAgeDescInterface::BuildAgeFileList( ageFiles );
|
||||
hsTArray<plFileName> ageFiles = plAgeDescInterface::BuildAgeFileList();
|
||||
|
||||
const char *curAge = fPB->GetStr(plPageInfoComponent::kInfoAge);
|
||||
if (!curAge || *curAge == '\0')
|
||||
@ -268,14 +266,13 @@ protected:
|
||||
|
||||
for( int i = 0; i < ageFiles.GetCount(); i++ )
|
||||
{
|
||||
char ageName[_MAX_FNAME];
|
||||
_splitpath( ageFiles[ i ], nil, nil, ageName, nil );
|
||||
plString ageName = ageFiles[i].GetFileNameNoExt();
|
||||
|
||||
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!)
|
||||
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 );
|
||||
}
|
||||
|
||||
|
@ -41,7 +41,6 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
*==LICENSE==*/
|
||||
|
||||
#include "HeadSpin.h"
|
||||
#include "plFile/hsFiles.h"
|
||||
#include "hsResMgr.h"
|
||||
|
||||
#include "plComponentBase.h"
|
||||
@ -329,18 +328,12 @@ void plResponderLinkProc::ILoadAgeFilenamesCombo(HWND hWnd, IParamBlock2 *pb)
|
||||
savedName = "";
|
||||
|
||||
// Iterate through the age descriptions
|
||||
hsFolderIterator ageFolder(agePath.AsString().c_str());
|
||||
while (ageFolder.NextFileSuffix(".age"))
|
||||
std::vector<plFileName> ages = plFileSystem::ListDir(agePath, "*.age");
|
||||
for (auto iter = ages.begin(); iter != ages.end(); ++iter)
|
||||
{
|
||||
char ageFile[MAX_PATH];
|
||||
ageFolder.GetPathAndName(ageFile);
|
||||
int idx = SendMessage(hAge, CB_ADDSTRING, 0, (LPARAM)iter->GetFileNameNoExt().c_str());
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
@ -364,18 +357,12 @@ void plResponderLinkProc::ILoadParentAgeFilenamesCombo(HWND hWnd, IParamBlock2 *
|
||||
savedName = "<None>";
|
||||
|
||||
// Iterate through the age descriptions
|
||||
hsFolderIterator ageFolder(agePath.AsString().c_str());
|
||||
while (ageFolder.NextFileSuffix(".age"))
|
||||
std::vector<plFileName> ages = plFileSystem::ListDir(agePath, "*.age");
|
||||
for (auto iter = ages.begin(); iter != ages.end(); ++iter)
|
||||
{
|
||||
char ageFile[MAX_PATH];
|
||||
ageFolder.GetPathAndName(ageFile);
|
||||
int idx = SendMessage(hAge, CB_ADDSTRING, 0, (LPARAM)iter->GetFileNameNoExt().c_str());
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
@ -42,6 +42,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
|
||||
#include "HeadSpin.h"
|
||||
#include "hsWindows.h"
|
||||
#include "hsStream.h"
|
||||
|
||||
#include <bitmap.h>
|
||||
#include <iparamb2.h>
|
||||
@ -330,8 +331,6 @@ void plExportDlgImp::IExportCurrentFile(const char* exportPath)
|
||||
GetCOREInterface()->ExportToFile(exportPath);
|
||||
}
|
||||
|
||||
#include "plFile/hsFiles.h"
|
||||
|
||||
void plExportDlgImp::IDoExport()
|
||||
{
|
||||
fExporting = true;
|
||||
@ -351,13 +350,10 @@ void plExportDlgImp::IDoExport()
|
||||
IExportCurrentFile(exportPath);
|
||||
else
|
||||
{
|
||||
hsFolderIterator sourceDir(fExportSourceDir.AsString().c_str());
|
||||
while (sourceDir.NextFileSuffix(".max"))
|
||||
std::vector<plFileName> sources = plFileSystem::ListDir(fExportSourceDir, "*.max");
|
||||
for (auto iter = sources.begin(); iter != sources.end(); ++iter)
|
||||
{
|
||||
char exportFile[MAX_PATH];
|
||||
sourceDir.GetPathAndName(exportFile);
|
||||
|
||||
if (GetCOREInterface()->LoadFromFile(exportFile))
|
||||
if (GetCOREInterface()->LoadFromFile(iter->AsString().c_str()))
|
||||
IExportCurrentFile(exportPath);
|
||||
}
|
||||
}
|
||||
@ -390,18 +386,18 @@ void plExportDlgImp::Show()
|
||||
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++)
|
||||
{
|
||||
if (!strcmp(fileName, excludeFiles[i].c_str()))
|
||||
if (fileName == excludeFiles[i])
|
||||
return true;
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
@ -417,37 +413,33 @@ static bool AutoExportDir(const char* inputDir, const char* outputDir, const cha
|
||||
|
||||
// Don't give missing bitmap warnings
|
||||
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;
|
||||
|
||||
// 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;
|
||||
|
||||
hsUNIXStream log;
|
||||
if (log.Open(outputLog, "ab"))
|
||||
{
|
||||
log.WriteFmt("%s\r\n", sourceDir.GetFileName());
|
||||
log.WriteFmt("%s\r\n", iter->GetFileName().c_str());
|
||||
log.Close();
|
||||
}
|
||||
|
||||
if (GetCOREInterface()->LoadFromFile(exportFile))
|
||||
if (GetCOREInterface()->LoadFromFile(iter->AsString().c_str()))
|
||||
{
|
||||
sprintf(doneDir, "%s\\Done\\%s", inputDir, sourceDir.GetFileName());
|
||||
MoveFileEx(exportFile, doneDir, MOVEFILE_REPLACE_EXISTING);
|
||||
plFileSystem::Move(*iter, plFileName::Join(inputDir, "Done", iter->GetFileName()));
|
||||
|
||||
GetCOREInterface()->ExportToFile(outputFileName, TRUE);
|
||||
exportedFile = true;
|
||||
|
||||
// If we're not doing grouped files, this is it, we exported our one file
|
||||
if (!groupFiles)
|
||||
if (!groupFiles.IsValid())
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -471,7 +463,7 @@ static void ShutdownMax()
|
||||
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];
|
||||
GetPrivateProfileString("Settings", keyName, "", source, sizeof(source), configFile);
|
||||
@ -506,18 +498,18 @@ void plExportDlgImp::StartAutoExport()
|
||||
hsMessageBox_SuppressPrompts = true;
|
||||
|
||||
// Files to ignore
|
||||
std::vector<std::string> excludeFiles;
|
||||
GetStringSection(configFile, "ExcludeFiles", excludeFiles);
|
||||
std::vector<plFileName> excludeFiles;
|
||||
GetFileNameSection(configFile, "ExcludeFiles", excludeFiles);
|
||||
|
||||
//
|
||||
// Get the file substrings to export in one session
|
||||
//
|
||||
std::vector<std::string> groupedFiles;
|
||||
GetStringSection(configFile, "GroupedFiles", groupedFiles);
|
||||
std::vector<plFileName> groupedFiles;
|
||||
GetFileNameSection(configFile, "GroupedFiles", groupedFiles);
|
||||
|
||||
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();
|
||||
fAutoExporting = false;
|
||||
@ -525,7 +517,7 @@ void plExportDlgImp::StartAutoExport()
|
||||
}
|
||||
}
|
||||
|
||||
if (AutoExportDir(inputDir, outputDir, NULL, excludeFiles))
|
||||
if (AutoExportDir(inputDir, outputDir, "", excludeFiles))
|
||||
{
|
||||
ShutdownMax();
|
||||
fAutoExporting = false;
|
||||
|
@ -61,7 +61,6 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
#include "hsColorRGBA.h"
|
||||
#include "plgDispatch.h"
|
||||
#include "hsFastMath.h"
|
||||
#include "plFile/hsFiles.h"
|
||||
#include "hsGeometry3.h"
|
||||
#include "pnKeyedObject/plKey.h"
|
||||
#include "plLoadMask.h"
|
||||
|
@ -41,7 +41,6 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
*==LICENSE==*/
|
||||
|
||||
#include "HeadSpin.h"
|
||||
#include "plFile/hsFiles.h"
|
||||
#include "hsTemplates.h"
|
||||
|
||||
#include "MaxComponent/plComponentMgr.h"
|
||||
|
@ -40,14 +40,11 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
|
||||
*==LICENSE==*/
|
||||
#include "HeadSpin.h"
|
||||
#include "plFile/hsFiles.h"
|
||||
#include "hsStream.h"
|
||||
#include "hsTemplates.h"
|
||||
#include "hsWindows.h"
|
||||
|
||||
#include <max.h>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "resource.h"
|
||||
#pragma hdrstop
|
||||
@ -63,8 +60,6 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
#endif
|
||||
#include "plMaxAccelerators.h"
|
||||
|
||||
using std::string;
|
||||
|
||||
extern HINSTANCE hInstance;
|
||||
|
||||
//// Tree Data Wrapper Class //////////////////////////////////////////////////
|
||||
@ -72,19 +67,17 @@ extern HINSTANCE hInstance;
|
||||
class plAgeFile
|
||||
{
|
||||
protected:
|
||||
void IGetAgeName(const char* path)
|
||||
void IGetAgeName(const plFileName& path)
|
||||
{
|
||||
char name[_MAX_FNAME];
|
||||
_splitpath(path, nil, nil, name, nil);
|
||||
fAgeName = name;
|
||||
fAgeName = path.GetFileNameNoExt();
|
||||
}
|
||||
|
||||
public:
|
||||
#ifdef MAXASS_VAILABLE
|
||||
jvUniqueId fAssetID;
|
||||
#endif
|
||||
string fPath;
|
||||
string fAgeName;
|
||||
plFileName fPath;
|
||||
plString fAgeName;
|
||||
|
||||
enum Types
|
||||
{
|
||||
@ -93,17 +86,16 @@ public:
|
||||
};
|
||||
Types fType;
|
||||
|
||||
plAgeFile(Types type) : fType(type), fPath(nil) { }
|
||||
plAgeFile(Types type, const char *path) : fType(type)
|
||||
plAgeFile(Types type) : fType(type) { }
|
||||
plAgeFile(Types type, const plFileName &path) : fPath(path), fType(type)
|
||||
{
|
||||
fPath = path;
|
||||
IGetAgeName(path);
|
||||
}
|
||||
|
||||
#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);
|
||||
}
|
||||
#endif
|
||||
@ -716,7 +708,7 @@ void plAgeDescInterface::IUpdateCurAge( void )
|
||||
else
|
||||
#endif
|
||||
// Load the local age, also check its sequence #s
|
||||
ILoadAge( currAge->fPath.c_str(), true );
|
||||
ILoadAge( currAge->fPath, true );
|
||||
}
|
||||
|
||||
static const int kDefaultCapacity = 10;
|
||||
@ -851,19 +843,15 @@ void plAgeDescInterface::IGetAgeFiles(std::vector<plAgeFile*>& ageFiles)
|
||||
{
|
||||
IClearAgeFiles(ageFiles);
|
||||
|
||||
char agePath[MAX_PATH];
|
||||
|
||||
// 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
|
||||
plFileName localPath = IGetLocalAgePath();
|
||||
if (localPath.IsValid())
|
||||
{
|
||||
hsFolderIterator ageFolder(localPath.AsString().c_str());
|
||||
while (ageFolder.NextFileSuffix(".age"))
|
||||
std::vector<plFileName> files = plFileSystem::ListDir(localPath, "*.age");
|
||||
for (auto iter = files.begin(); iter != files.end(); ++iter)
|
||||
{
|
||||
ageFolder.GetPathAndName(agePath);
|
||||
|
||||
plAgeFile* age = new plAgeFile(plAgeFile::kLocalFile, agePath);
|
||||
plAgeFile* age = new plAgeFile(plAgeFile::kLocalFile, *iter);
|
||||
ageFiles.push_back(age);
|
||||
}
|
||||
}
|
||||
@ -881,6 +869,7 @@ void plAgeDescInterface::IGetAgeFiles(std::vector<plAgeFile*>& ageFiles)
|
||||
{
|
||||
if( doneAssets.Find( (*assets)[ i ] ) == doneAssets.kMissingIndex )
|
||||
{
|
||||
char agePath[MAX_PATH];
|
||||
if (assetMan->GetLatestVersionFile((*assets)[i], agePath, sizeof(agePath)))
|
||||
{
|
||||
plAgeFile* age = new plAgeFile(plAgeFile::kAssetFile, agePath, (*assets)[i]);
|
||||
@ -911,16 +900,19 @@ void plAgeDescInterface::IClearAgeFiles(std::vector<plAgeFile*>& ageFiles)
|
||||
ageFiles.clear();
|
||||
}
|
||||
|
||||
void plAgeDescInterface::BuildAgeFileList( hsTArray<char *> &ageList )
|
||||
hsTArray<plFileName> plAgeDescInterface::BuildAgeFileList()
|
||||
{
|
||||
std::vector<plAgeFile*> tempAgeFiles;
|
||||
IGetAgeFiles(tempAgeFiles);
|
||||
|
||||
hsTArray<plFileName> ageList;
|
||||
for (int i = 0; i < tempAgeFiles.size(); i++)
|
||||
{
|
||||
ageList.Push(hsStrcpy(tempAgeFiles[i]->fPath.c_str()));
|
||||
ageList.Push(tempAgeFiles[i]->fPath);
|
||||
delete tempAgeFiles[ i ];
|
||||
}
|
||||
|
||||
return ageList;
|
||||
}
|
||||
|
||||
//// IFillAgeTree /////////////////////////////////////////////////////////////
|
||||
@ -1310,7 +1302,7 @@ uint32_t plAgeDescInterface::IGetNextFreeSequencePrefix( bool getReservedPrefix
|
||||
for( i = 0; i < fAgeFiles.size(); i++ )
|
||||
{
|
||||
hsUNIXStream stream;
|
||||
if( stream.Open( fAgeFiles[ i ]->fPath.c_str(), "rt" ) )
|
||||
if( stream.Open( fAgeFiles[ i ]->fPath, "rt" ) )
|
||||
{
|
||||
ages[ i ].Read( &stream );
|
||||
stream.Close();
|
||||
|
@ -84,7 +84,7 @@ public:
|
||||
static BOOL CALLBACK ForwardDlgProc(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:
|
||||
static int IFindAge(const char* ageName, std::vector<plAgeFile*>& ageFiles);
|
||||
|
@ -40,9 +40,9 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
|
||||
*==LICENSE==*/
|
||||
#include "HeadSpin.h"
|
||||
#include "plFile/hsFiles.h"
|
||||
#include "plgDispatch.h"
|
||||
#include "hsWindows.h"
|
||||
#include "plFileSystem.h"
|
||||
|
||||
#include <Python.h>
|
||||
#include <string>
|
||||
@ -52,6 +52,8 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
#include <max.h>
|
||||
#pragma hdrstop
|
||||
|
||||
#include <direct.h>
|
||||
|
||||
#include "plPythonMgr.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);
|
||||
if (module)
|
||||
@ -596,8 +598,6 @@ void plPythonMgr::IAddGrassComponent(plAutoUIBlock *autoUI, PyObject *objTuple,
|
||||
autoUI->AddPickGrassComponentButton(id, nil, paramName.c_str(), vid, vstates);
|
||||
}
|
||||
|
||||
#include <direct.h>
|
||||
|
||||
void plPythonMgr::LoadPythonFiles()
|
||||
{
|
||||
plFileName clientPath = plMaxConfig::GetClientPath(false, true);
|
||||
@ -612,15 +612,13 @@ void plPythonMgr::LoadPythonFiles()
|
||||
PythonInterface::initPython();
|
||||
|
||||
// Iterate through all the Python files in the folder
|
||||
hsFolderIterator folder(pythonPath.AsString().c_str());
|
||||
while (folder.NextFileSuffix(".py"))
|
||||
std::vector<plFileName> pys = plFileSystem::ListDir(pythonPath, "*.py");
|
||||
for (auto iter = pys.begin(); iter != pys.end(); ++iter)
|
||||
{
|
||||
// Get the filename without the ".py" (module name)
|
||||
const char *fullFileName = folder.GetFileName();
|
||||
char fileName[_MAX_FNAME];
|
||||
_splitpath(fullFileName, NULL, NULL, fileName, NULL);
|
||||
plString fileName = iter->GetFileNameNoExt();
|
||||
|
||||
IQueryPythonFile(fileName);
|
||||
IQueryPythonFile(fileName.c_str());
|
||||
}
|
||||
|
||||
PythonInterface::finiPython();
|
||||
|
@ -48,7 +48,7 @@ class plPythonMgr
|
||||
protected:
|
||||
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 IAddInt(plAutoUIBlock *autoUI, PyObject *tuple, char *paramName, int id, int vid, std::vector<std::string>* vstates);
|
||||
|
@ -279,8 +279,6 @@ void SceneSync::IClearDirtyRecur(plMaxNode *node)
|
||||
IClearDirtyRecur((plMaxNode*)node->GetChildNode(i));
|
||||
}
|
||||
|
||||
#include "../plFile/hsFiles.h"
|
||||
|
||||
void SceneSync::IDeletePath(const char *path)
|
||||
{
|
||||
// Remove any files in the dat directory
|
||||
|
@ -53,7 +53,6 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
#include "plResMgr/plResManager.h"
|
||||
#include "plResMgr/plResMgrSettings.h"
|
||||
#include "plWinRegistryTools.h"
|
||||
#include "plFile/hsFiles.h"
|
||||
|
||||
#define IDC_REGTREEVIEW 1000
|
||||
|
||||
@ -139,14 +138,10 @@ LRESULT CALLBACK HandleCommand( HWND hWnd, WPARAM wParam, LPARAM lParam )
|
||||
// Load that source
|
||||
plResManager *mgr = (plResManager *)hsgResMgr::ResMgr();
|
||||
|
||||
hsFolderIterator pathIterator(path);
|
||||
while (pathIterator.NextFileSuffix(".prp"))
|
||||
{
|
||||
char fileName[kFolderIterator_MaxPath];
|
||||
pathIterator.GetPathAndName(fileName);
|
||||
mgr->AddSinglePage(fileName);
|
||||
}
|
||||
|
||||
std::vector<plFileName> prpFiles = plFileSystem::ListDir(path, "*.prp");
|
||||
for (auto iter = prpFiles.begin(); iter != prpFiles.end(); ++iter)
|
||||
mgr->AddSinglePage(*iter);
|
||||
|
||||
plResTreeView::FillTreeViewFromRegistry( gTreeView );
|
||||
|
||||
SetWindowTitle( hWnd, path );
|
||||
@ -388,13 +383,9 @@ LRESULT CALLBACK WndProc( HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam
|
||||
( (char *)PathFindExtension( path ) )[ 0 ] == 0 )
|
||||
{
|
||||
// Must be a directory
|
||||
hsFolderIterator pathIterator(path);
|
||||
while (pathIterator.NextFileSuffix(".prp"))
|
||||
{
|
||||
char fileName[kFolderIterator_MaxPath];
|
||||
pathIterator.GetPathAndName(fileName);
|
||||
mgr->AddSinglePage(fileName);
|
||||
}
|
||||
std::vector<plFileName> prpFiles = plFileSystem::ListDir(path, "*.prp");
|
||||
for (auto iter = prpFiles.begin(); iter != prpFiles.end(); ++iter)
|
||||
mgr->AddSinglePage(*iter);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
Reference in New Issue
Block a user