Browse Source

Just enough plFileName to make things interesting.

Fixes botched export paths
Adam Johnson 12 years ago
parent
commit
ece2b3d440
  1. 28
      Sources/Tools/MaxExport/SimpleExport.cpp
  2. 10
      Sources/Tools/MaxExport/plExportDlg.cpp

28
Sources/Tools/MaxExport/SimpleExport.cpp

@ -192,24 +192,6 @@ void HSExport2::ShowAbout(HWND hWnd)
{ {
} }
void IGetPath(const char* name, char* path)
{
int i;
// find the last backslash in the full path
for ( i=strlen(name)-1; i>=0 ; i-- )
{
if ( name[i] == '\\' )
break;
}
if ( i >= 0 && i < 256) // if either we couldn't the backslash or the path was too big
{
strncpy(path,name,i+1);
path[i+1] = '\0'; //null terminate string (cause strncpy might not)
}
else
path[0] = '\0'; // otherwise just make it a null string
}
// Another little helper class to help write out a list of textures to a log file // Another little helper class to help write out a list of textures to a log file
class plTextureLoggerCBack : public plRegistryKeyIterator class plTextureLoggerCBack : public plRegistryKeyIterator
{ {
@ -269,10 +251,10 @@ int HSExport2::DoExport(const TCHAR *name,ExpInterface *ei,Interface *gi, BOOL s
BroadcastNotification(NOTIFY_PRE_EXPORT); BroadcastNotification(NOTIFY_PRE_EXPORT);
// get just the path (not the file) of where we are going to export to // get just the path (not the file) of where we are going to export to
char out_path[256]; plFileName out_path = plFileName(name).StripFileName();
IGetPath(name, out_path);
// Apparently this was implied by the open dialog, but not if you call Max's ExportToFile() func // Apparently this was implied by the open dialog, but not if you call Max's ExportToFile() func
SetCurrentDirectory(out_path); SetCurrentDirectoryW(out_path.AsString().ToWchar());
// //
// Setup ErrorMsg // Setup ErrorMsg
@ -286,7 +268,7 @@ int HSExport2::DoExport(const TCHAR *name,ExpInterface *ei,Interface *gi, BOOL s
if (dot) if (dot)
*dot = 0; *dot = 0;
char ErrorLogName[512]; char ErrorLogName[512];
sprintf(ErrorLogName, "%s%s.err", out_path, fName); sprintf(ErrorLogName, "%s%s.err", out_path.AsString().c_str(), fName);
plExportLogErrorMsg logonly_errorMessage(ErrorLogName); // This errorMessage just writes it all to a file plExportLogErrorMsg logonly_errorMessage(ErrorLogName); // This errorMessage just writes it all to a file
// now decide which errorMessage object to use // now decide which errorMessage object to use
@ -341,7 +323,7 @@ int HSExport2::DoExport(const TCHAR *name,ExpInterface *ei,Interface *gi, BOOL s
bool convertOK = plConvert::Instance().Convert(); bool convertOK = plConvert::Instance().Convert();
// Free the material cache. This will delete unused materials. // Free the material cache. This will delete unused materials.
hsMaterialConverter::Instance().FreeMaterialCache(out_path); hsMaterialConverter::Instance().FreeMaterialCache(out_path.AsString().c_str());
if (convertOK) if (convertOK)
{ {

10
Sources/Tools/MaxExport/plExportDlg.cpp

@ -339,22 +339,22 @@ void plExportDlgImp::IDoExport()
ShowWindow(fDlg, SW_HIDE); ShowWindow(fDlg, SW_HIDE);
// Do the export // Do the export
char exportPath[MAX_PATH]; wchar_t exportPathTEMP[MAX_PATH];
GetDlgItemText(fDlg, IDC_CLIENT_PATH, exportPath, sizeof(exportPath)); GetDlgItemTextW(fDlg, IDC_CLIENT_PATH, exportPathTEMP, arrsize(exportPathTEMP));
strcat(exportPath, "Export.prd"); plFileName exportPath = plFileName::Join(plString::FromWchar(exportPathTEMP), "Export.prd");
// For export time stats // For export time stats
DWORD exportTime = timeGetTime(); DWORD exportTime = timeGetTime();
if (fExportFile) if (fExportFile)
IExportCurrentFile(exportPath); IExportCurrentFile(exportPath.AsString().c_str());
else else
{ {
std::vector<plFileName> sources = plFileSystem::ListDir(fExportSourceDir, "*.max"); std::vector<plFileName> sources = plFileSystem::ListDir(fExportSourceDir, "*.max");
for (auto iter = sources.begin(); iter != sources.end(); ++iter) for (auto iter = sources.begin(); iter != sources.end(); ++iter)
{ {
if (GetCOREInterface()->LoadFromFile(iter->AsString().c_str())) if (GetCOREInterface()->LoadFromFile(iter->AsString().c_str()))
IExportCurrentFile(exportPath); IExportCurrentFile(exportPath.AsString().c_str());
} }
} }

Loading…
Cancel
Save