From ece2b3d4405e0dd7489ec1f845f1760147c8fac5 Mon Sep 17 00:00:00 2001 From: Adam Johnson Date: Mon, 28 Jan 2013 23:23:01 -0500 Subject: [PATCH] Just enough plFileName to make things interesting. Fixes botched export paths --- Sources/Tools/MaxExport/SimpleExport.cpp | 28 +++++------------------- Sources/Tools/MaxExport/plExportDlg.cpp | 10 ++++----- 2 files changed, 10 insertions(+), 28 deletions(-) diff --git a/Sources/Tools/MaxExport/SimpleExport.cpp b/Sources/Tools/MaxExport/SimpleExport.cpp index 8af0793e..97eb124a 100644 --- a/Sources/Tools/MaxExport/SimpleExport.cpp +++ b/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 class plTextureLoggerCBack : public plRegistryKeyIterator { @@ -269,10 +251,10 @@ int HSExport2::DoExport(const TCHAR *name,ExpInterface *ei,Interface *gi, BOOL s BroadcastNotification(NOTIFY_PRE_EXPORT); // get just the path (not the file) of where we are going to export to - char out_path[256]; - IGetPath(name, out_path); + plFileName out_path = plFileName(name).StripFileName(); + // 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 @@ -286,7 +268,7 @@ int HSExport2::DoExport(const TCHAR *name,ExpInterface *ei,Interface *gi, BOOL s if (dot) *dot = 0; 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 // 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(); // Free the material cache. This will delete unused materials. - hsMaterialConverter::Instance().FreeMaterialCache(out_path); + hsMaterialConverter::Instance().FreeMaterialCache(out_path.AsString().c_str()); if (convertOK) { diff --git a/Sources/Tools/MaxExport/plExportDlg.cpp b/Sources/Tools/MaxExport/plExportDlg.cpp index b3fa69d5..5af2fb0e 100644 --- a/Sources/Tools/MaxExport/plExportDlg.cpp +++ b/Sources/Tools/MaxExport/plExportDlg.cpp @@ -339,22 +339,22 @@ void plExportDlgImp::IDoExport() ShowWindow(fDlg, SW_HIDE); // Do the export - char exportPath[MAX_PATH]; - GetDlgItemText(fDlg, IDC_CLIENT_PATH, exportPath, sizeof(exportPath)); - strcat(exportPath, "Export.prd"); + wchar_t exportPathTEMP[MAX_PATH]; + GetDlgItemTextW(fDlg, IDC_CLIENT_PATH, exportPathTEMP, arrsize(exportPathTEMP)); + plFileName exportPath = plFileName::Join(plString::FromWchar(exportPathTEMP), "Export.prd"); // For export time stats DWORD exportTime = timeGetTime(); if (fExportFile) - IExportCurrentFile(exportPath); + IExportCurrentFile(exportPath.AsString().c_str()); else { std::vector sources = plFileSystem::ListDir(fExportSourceDir, "*.max"); for (auto iter = sources.begin(); iter != sources.end(); ++iter) { if (GetCOREInterface()->LoadFromFile(iter->AsString().c_str())) - IExportCurrentFile(exportPath); + IExportCurrentFile(exportPath.AsString().c_str()); } }