1
0
mirror of https://foundry.openuru.org/gitblit/r/CWE-ou-minkata.git synced 2025-07-18 11:19:10 +00:00

Remove hsFiles in favor of plFilesystem stuff

This commit is contained in:
2013-01-20 20:17:39 -08:00
parent cc54fb07be
commit 2c028c4b07
51 changed files with 327 additions and 1249 deletions

View File

@ -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"

View File

@ -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;
}

View File

@ -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 );
}

View File

@ -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);
}
}

View File

@ -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;

View File

@ -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"

View File

@ -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"

View File

@ -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();

View File

@ -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);

View File

@ -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();

View File

@ -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);

View File

@ -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

View File

@ -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
{