From 033a337419a3c318fc5bcc91d4b33ab551f0044e Mon Sep 17 00:00:00 2001 From: kervala Date: Tue, 22 Nov 2016 19:34:43 +0100 Subject: [PATCH] Changed: Replace all _splitpath by NeL methods --HG-- branch : develop --- code/nel/tools/3d/ligo/plugin_max/script.cpp | 80 +++++++------------ .../3d/object_viewer/animation_set_dlg.cpp | 6 +- .../3d/object_viewer/edit_morph_mesh_dlg.cpp | 14 +--- code/nel/tools/3d/object_viewer/mesh_dlg.cpp | 17 ++-- .../plugin_max/nel_export/nel_export_view.cpp | 10 +-- .../nel_mesh_lib/export_material.cpp | 16 ---- .../plugin_max/nel_mesh_lib/export_misc.cpp | 7 +- .../3d/plugin_max/nel_patch_paint/paint.cpp | 10 +-- .../plugin_max/nel_patch_paint/paint_ui.cpp | 24 ++---- .../plugin_max/tile_utility/tile_utility.cpp | 17 ++-- code/nel/tools/3d/tile_edit/Browse.cpp | 26 +++--- .../3d/tile_edit/SelectionTerritoire.cpp | 18 ++--- code/nel/tools/3d/tile_edit/View.cpp | 26 +++--- .../leveldesign/georges_dll/dfn_dialog.cpp | 14 ++-- .../georges_dll/file_tree_view.cpp | 8 +- .../leveldesign/georges_dll/form_dialog.cpp | 4 +- .../leveldesign/georges_dll/georges_edit.cpp | 36 +++------ .../georges_dll/georges_edit_doc.cpp | 21 ++--- .../leveldesign/georges_dll/imagelist_ex.cpp | 12 +-- .../world_editor/imagelist_ex.cpp | 12 +-- 20 files changed, 126 insertions(+), 252 deletions(-) diff --git a/code/nel/tools/3d/ligo/plugin_max/script.cpp b/code/nel/tools/3d/ligo/plugin_max/script.cpp index d8f8123cd..b494f69ff 100644 --- a/code/nel/tools/3d/ligo/plugin_max/script.cpp +++ b/code/nel/tools/3d/ligo/plugin_max/script.cpp @@ -151,7 +151,7 @@ Value* export_material_cf (Value** arg_list, int count) nlassert (node); // The second arg - const char *fileName = arg_list[1]->to_string(); + const std::string fileName = tStrToUtf8(arg_list[1]->to_string()); // The third arg bool checkOnly = (arg_list[2]->to_bool() != FALSE); @@ -204,12 +204,7 @@ Value* export_material_cf (Value** arg_list, int count) { // Make a name for the zone - char drive[512]; - char dir[512]; - char name[512]; - char path[512]; - _splitpath (fileName, drive, dir, name, NULL); - _makepath (path, drive, dir, name, ".zone"); + std::string path = CFile::getPath(fileName) + CFile::getFilenameWithoutExtension(fileName) + ".zone"; // Ok ? bool ok = true; @@ -322,7 +317,7 @@ Value* export_transition_cf (Value** arg_list, int count) nlassert (is_array(nodes)); // The second arg - const char *fileName = arg_list[1]->to_string(); + std::string fileName = tStrToUtf8(arg_list[1]->to_string()); // The second arg string matFilename[2]; @@ -505,10 +500,7 @@ Value* export_transition_cf (Value** arg_list, int count) for (zone=0; zoneSaved.AnimationFileName.size(); i++) { // Get the animation name - char name[512]; - _splitpath (object->Saved.AnimationFileName[i].c_str(), NULL, NULL, name, NULL); + std::string name = NLMISC::CFile::getFilenameWithoutExtension(object->Saved.AnimationFileName[i]); // Get the animation pointer CAnimation *anim = object->AnimationSet.getAnimation (object->AnimationSet.getAnimationIdByName (name)); @@ -314,8 +313,7 @@ void CAnimationSetDlg::refresh (BOOL update) for (i=0; iSaved.SWTFileName.size(); i++) { // Get the animation name - char name[512]; - _splitpath (object->Saved.SWTFileName[i].c_str(), NULL, NULL, name, NULL); + std::string name = NLMISC::CFile::getFilenameWithoutExtension(object->Saved.SWTFileName[i]); // Get the animation pointer CSkeletonWeight *swt = object->AnimationSet.getSkeletonWeight (object->AnimationSet.getSkeletonWeightIdByName (name)); diff --git a/code/nel/tools/3d/object_viewer/edit_morph_mesh_dlg.cpp b/code/nel/tools/3d/object_viewer/edit_morph_mesh_dlg.cpp index afcc75e34..0c7def7e9 100644 --- a/code/nel/tools/3d/object_viewer/edit_morph_mesh_dlg.cpp +++ b/code/nel/tools/3d/object_viewer/edit_morph_mesh_dlg.cpp @@ -84,21 +84,9 @@ bool CEditMorphMeshDlg::getShapeNameFromDlg(std::string &name) CFileDialog fd(TRUE, _T(".shape"), _T("*.shape"), 0, NULL, this); if (fd.DoModal() == IDOK) { - // Add to the path - /* - char drive[256]; - char dir[256]; - char path[256]; - char fname[256]; - char ext[256]; - */ - - // Add search path for the texture /* - _splitpath (fd.GetPathName(), drive, dir, fname, ext); - _makepath (path, drive, dir, NULL, NULL); - NLMISC::CPath::addSearchPath (path); + NLMISC::CPath::addSearchPath (NLMISC::CFile::getPath(tStrToUtf8(fd.GetPathName())); */ name = tStrToUtf8(fd.GetPathName()); diff --git a/code/nel/tools/3d/object_viewer/mesh_dlg.cpp b/code/nel/tools/3d/object_viewer/mesh_dlg.cpp index 991ae09f3..c81a1d92a 100644 --- a/code/nel/tools/3d/object_viewer/mesh_dlg.cpp +++ b/code/nel/tools/3d/object_viewer/mesh_dlg.cpp @@ -94,22 +94,17 @@ void CMeshDlg::OnBrowseShape() if (fd.DoModal() == IDOK) { // Add to the path - char drive[256]; - char dir[256]; - char path[256]; - char fname[256]; - char ext[256]; - + std::string fullPath = tStrToUtf8(fd.GetPathName()); + std::string fname = NLMISC::CFile::getFilenameWithoutExtension(fullPath); + std::string ext = NLMISC::CFile::getExtension(fullPath); // Add search path for the texture - _splitpath (fd.GetPathName(), drive, dir, fname, ext); - _makepath (path, drive, dir, NULL, NULL); - NLMISC::CPath::addSearchPath (path); + NLMISC::CPath::addSearchPath (NLMISC::CFile::getPath(fullPath)); try { - _ShapeParticle->setShape(std::string(fname) + ext); - m_ShapeName = (std::string(fname) + ext).c_str(); + _ShapeParticle->setShape(fname + "." + ext); + m_ShapeName = utf8ToTStr(fname + "." + ext); touchPSState(); } catch (const NLMISC::Exception &e) diff --git a/code/nel/tools/3d/plugin_max/nel_export/nel_export_view.cpp b/code/nel/tools/3d/plugin_max/nel_export/nel_export_view.cpp index 3461f0e46..bff98becc 100644 --- a/code/nel/tools/3d/plugin_max/nel_export/nel_export_view.cpp +++ b/code/nel/tools/3d/plugin_max/nel_export/nel_export_view.cpp @@ -111,15 +111,13 @@ void regsiterOVPath () if (!hModule) { ::MessageBox(NULL, "'hModule' failed at '" __FUNCTION__ "' in file '" __FILE__ " on line " NL_MACRO_TO_STR(__LINE__), "NeL Export", MB_OK | MB_ICONERROR); return; } char sModulePath[256]; int res = GetModuleFileName(hModule, sModulePath, 256); - if (!res) { ::MessageBox(NULL, "'res' failed at '" __FUNCTION__ "' in file '" __FILE__ " on line " NL_MACRO_TO_STR(__LINE__), "NeL Export", MB_OK | MB_ICONERROR); return; } - char SDrive[512]; - char SDir[512]; - _splitpath (sModulePath, SDrive, SDir, NULL, NULL); - _makepath (sModulePath, SDrive, SDir, "object_viewer", ".cfg"); + if (!res) { ::MessageBox(NULL, _T("'res' failed at '") __FUNCTION__ _T("' in file '") __FILE__ _T(" on line ") NL_MACRO_TO_STR(__LINE__), _T("NeL Export"), MB_OK | MB_ICONERROR); return; } + + std::string modulePath = NLMISC::CFile::getPath(tStrToUtf8(sModulePath)) + "object_viewer.cfg"; // Load the config file CConfigFile cf; - cf.load (sModulePath); + cf.load (modulePath); try { diff --git a/code/nel/tools/3d/plugin_max/nel_mesh_lib/export_material.cpp b/code/nel/tools/3d/plugin_max/nel_mesh_lib/export_material.cpp index d39d00cf7..8f7957175 100644 --- a/code/nel/tools/3d/plugin_max/nel_mesh_lib/export_material.cpp +++ b/code/nel/tools/3d/plugin_max/nel_mesh_lib/export_material.cpp @@ -1142,22 +1142,6 @@ int CExportNel::getVertMapChannel (Texmap& texmap, Matrix3& channelMatrix, TimeV // get the absolute or relative path from a texture filename static std::string ConvertTexFileName(const std::string &path, bool _AbsolutePath) { - /*// File name, maxlen 256 under windows - char sFileName[512]; - strcpy (sFileName, src); - - // Let absolute path ? - if (!_AbsolutePath) - { - // Decompose bitmap file name - char sName[256]; - char sExt[256]; - _splitpath (sFileName, NULL, NULL, sName, sExt); - - // Make the final path - _makepath (sFileName, NULL, NULL, sName, sExt); - } - return std::string(sFileName);*/ if (_AbsolutePath) { return path; diff --git a/code/nel/tools/3d/plugin_max/nel_mesh_lib/export_misc.cpp b/code/nel/tools/3d/plugin_max/nel_mesh_lib/export_misc.cpp index 87bc96be6..51b8aa367 100644 --- a/code/nel/tools/3d/plugin_max/nel_mesh_lib/export_misc.cpp +++ b/code/nel/tools/3d/plugin_max/nel_mesh_lib/export_misc.cpp @@ -561,13 +561,10 @@ std::string CExportNel::getNelObjectName (INode& node) ad = obj->GetAppDataChunk (MAXSCRIPT_UTILITY_CLASS_ID, UTILITY_CLASS_ID, NEL3D_APPDATA_INSTANCE_SHAPE); if (ad&&ad->data) { - if (::strlen((const char *) ad->data) != 0) + if (_tcslen((const TCHAR *) ad->data) != 0) { // get file name only - char fName[_MAX_FNAME]; - char ext[_MAX_FNAME]; - ::_splitpath((const char*)ad->data, NULL, NULL, fName, ext) ; - return std::string(fName + std::string(ext)); + return NLMISC::CFile::getFilename(tStrToUtf8((const TCHAR*)ad->data)); } else { diff --git a/code/nel/tools/3d/plugin_max/nel_patch_paint/paint.cpp b/code/nel/tools/3d/plugin_max/nel_patch_paint/paint.cpp index 799f1012d..9f5c7b4cb 100644 --- a/code/nel/tools/3d/plugin_max/nel_patch_paint/paint.cpp +++ b/code/nel/tools/3d/plugin_max/nel_patch_paint/paint.cpp @@ -4058,20 +4058,18 @@ bool loadLigoConfigFile (CLigoConfig& config, Interface& it) if (hModule) { // Get the path - char sModulePath[256]; + TCHAR sModulePath[256]; int res=GetModuleFileName(hModule, sModulePath, 256); // Success ? if (res) { // Path - char sDrive[256]; - char sDir[256]; - _splitpath (sModulePath, sDrive, sDir, NULL, NULL); - _makepath (sModulePath, sDrive, sDir, "ligoscape", ".cfg"); + std::string modulePath = NLMISC::CFile::getPath(tStrToUtf8(sModulePath)); + try { // Load the config file - config.readConfigFile (sModulePath, false); + config.readConfigFile (modulePath, false); // ok return true; } diff --git a/code/nel/tools/3d/plugin_max/nel_patch_paint/paint_ui.cpp b/code/nel/tools/3d/plugin_max/nel_patch_paint/paint_ui.cpp index 46b1ad1d7..7f6fec25c 100644 --- a/code/nel/tools/3d/plugin_max/nel_patch_paint/paint_ui.cpp +++ b/code/nel/tools/3d/plugin_max/nel_patch_paint/paint_ui.cpp @@ -409,24 +409,17 @@ void LoadKeyCfg () HMODULE hModule = hInstance; if (hModule) { - char sModulePath[256]; + TCHAR sModulePath[256]; int res=GetModuleFileName(hModule, sModulePath, 256); if (res) { - // split path - char drive[256]; - char dir[256]; - _splitpath (sModulePath, drive, dir, NULL, NULL); - // Make a new path - char cgfPath[256]; - _makepath (cgfPath, drive, dir, "keys", ".cfg"); - + std::string cfgPath = NLMISC::CFile::getPath(tStrToUtf8(sModulePath)) + "keys.cfg"; CConfigFile cf; // Load and parse "test.txt" file - cf.load (cgfPath); + cf.load (cfgPath); // For each keys for (uint key=0; keygetTile())->getRelativeFileName (m_ctrl.Texture==1?CTile::diffuse:CTile::additive).empty()) { // Try to load a tile with a file name like /tiletransition0.tga - char sName2[256]; - char sFinal[256]; - sprintf (sName2, "%s%02d", sName, (int)transition); - _makepath (sFinal, sDrive, sPath, sName2, sExt); - FILE *pFile=fopen (sFinal, "rb"); + std::string sFinal = path + toString("%s%02d.%s", filename.c_str(), (int)transition, ext.c_str()); + + FILE *pFile = nlfopen (sFinal, "rb"); // Close the file and add the tile if opened if (pFile) diff --git a/code/nel/tools/3d/tile_edit/SelectionTerritoire.cpp b/code/nel/tools/3d/tile_edit/SelectionTerritoire.cpp index a7493c62e..eb7738411 100644 --- a/code/nel/tools/3d/tile_edit/SelectionTerritoire.cpp +++ b/code/nel/tools/3d/tile_edit/SelectionTerritoire.cpp @@ -386,12 +386,8 @@ void SelectionTerritoire::OnSelect() list2->AddString(tileBank.getTileSet(i)->getName().c_str()); } - char drive[256],name[256],path[256],ext[256]; - _splitpath(temp,drive,path,name,ext); - MainFileName = name; - MainFileName += ext; - DefautPath = drive; - DefautPath += path; + MainFileName = CString(utf8ToTStr(NLMISC::CFile::getFilename(temp))); + DefautPath = CString(utf8ToTStr(NLMISC::CFile::getPath(temp))); MainFileOk = 1; CButton *button = (CButton*)GetDlgItem(IDC_ADD_TERRITOIRE); @@ -468,12 +464,10 @@ void SelectionTerritoire::OnSaveAs() button->EnableWindow(true); // Create a file name - char drive[256],name[256],path[256],ext[256]; - _splitpath(sFile.GetPathName(), drive, path, name, ext); - MainFileName = name; - MainFileName += ext; - DefautPath = drive; - DefautPath += path; + std::string temp = tStrToUtf8(sFile.GetPathName()); + + MainFileName = CString(utf8ToTStr(NLMISC::CFile::getFilename(temp))); + DefautPath = CString(utf8ToTStr(NLMISC::CFile::getPath(temp))); } } diff --git a/code/nel/tools/3d/tile_edit/View.cpp b/code/nel/tools/3d/tile_edit/View.cpp index 0cfe0719a..354f1e51d 100644 --- a/code/nel/tools/3d/tile_edit/View.cpp +++ b/code/nel/tools/3d/tile_edit/View.cpp @@ -1283,11 +1283,10 @@ void CTView::DrawTile(tilelist::iterator i,CDC *pDC,int clear, int n) &*bits->begin(),bmpinf,DIB_RGB_COLORS,SRCCOPY); } - char temp[100]; - char Name[256]; Name[0] = 0; + std::string Name; if (InfoTexte==2) { - _splitpath(pth.c_str(),temp,temp,Name,temp); + Name = NLMISC::CFile::getFilenameWithoutExtension(pth); } else if (InfoTexte==3) { @@ -1295,12 +1294,20 @@ void CTView::DrawTile(tilelist::iterator i,CDC *pDC,int clear, int n) } else if (InfoTexte==1) { - sprintf(Name,"%d",i->id); + Name = NLMISC::toString("%d", i->id); } rect_txt.top = pt.y + sizetile_y + spacing_tile_text; rect_txt.bottom += rect_txt.top + sizetext_y; rect_txt.left -= spacing_x; - pDC->DrawText(Name,(int)strlen(Name),&rect_txt,DT_CENTER | DT_SINGLELINE); + +#ifdef _UNICODE + ucstring tmp; + tmp.fromUtf8(Name); +#else + std::string tmp = Name; +#endif + + pDC->DrawText((LPCTSTR)tmp.c_str(), (int)tmp.length(), &rect_txt,DT_CENTER | DT_SINGLELINE); // Restore the device context pDC->SetBkColor( clrBk ); @@ -1537,15 +1544,12 @@ LRESULT CTView::WindowProc(UINT message, WPARAM wParam, LPARAM lParam) { CString str = load.GetNextPathName(p); - char sDrive[256]; - char sPath[256]; - _splitpath (str, sDrive, sPath, NULL, NULL); - LastPath=string (sDrive)+string (sPath); + LastPath = NLMISC::CFile::getPath(tStrToUtf8(str)); - if (str!=CString("")) + if (!str.IsEmpty()) { int index=0; - const char *pathname = (LPCTSTR)str; + std::string pathname = tStrToUtf8(str); // Add mode, to the end of the list if (id==ID_MENU_ADD) diff --git a/code/ryzom/tools/leveldesign/georges_dll/dfn_dialog.cpp b/code/ryzom/tools/leveldesign/georges_dll/dfn_dialog.cpp index 2e1cafce8..3c12eb254 100644 --- a/code/ryzom/tools/leveldesign/georges_dll/dfn_dialog.cpp +++ b/code/ryzom/tools/leveldesign/georges_dll/dfn_dialog.cpp @@ -420,19 +420,17 @@ void CDfnEditListCtrl::onItemChanged (uint item, uint subItem) { CString str; str = Dialog->Struct.ListCtrl.GetItemText (item, 2); - char ext[MAX_PATH]; - _splitpath (str, NULL, NULL, NULL, ext); - if (stricmp (ext, ".typ") != 0) - Dialog->Struct.ListCtrl.SetItemText (item, 2, theApp.DefaultType.c_str ()); + std::string ext = NLMISC::CFile::getExtension(tStrToUtf8(str)); + if (ext == "typ") + Dialog->Struct.ListCtrl.SetItemText (item, 2, utf8ToTStr(theApp.DefaultType)); } else if ((type == "Dfn") || (type == "Dfn array")) { CString str; str = Dialog->Struct.ListCtrl.GetItemText (item, 2); - char ext[MAX_PATH]; - _splitpath (str, NULL, NULL, NULL, ext); - if (stricmp (ext, ".dfn") != 0) - Dialog->Struct.ListCtrl.SetItemText (item, 2, theApp.DefaultDfn.c_str ()); + std::string ext = NLMISC::CFile::getExtension(tStrToUtf8(str)); + if (ext == "dfn") + Dialog->Struct.ListCtrl.SetItemText (item, 2, utf8ToTStr(theApp.DefaultDfn)); // Clear default value Dialog->Struct.ListCtrl.SetItemText (item, 3, _T("")); diff --git a/code/ryzom/tools/leveldesign/georges_dll/file_tree_view.cpp b/code/ryzom/tools/leveldesign/georges_dll/file_tree_view.cpp index 43c71f240..fac4cb052 100644 --- a/code/ryzom/tools/leveldesign/georges_dll/file_tree_view.cpp +++ b/code/ryzom/tools/leveldesign/georges_dll/file_tree_view.cpp @@ -403,11 +403,9 @@ int CALLBACK CompareFunc(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort) return stricmp (pItemInfo1->displayName.c_str(), pItemInfo2->displayName.c_str()); if (pfileTreeCtrl->_ArrangeMode == CFileTreeCtrl::ByType) { - char ext1[_MAX_EXT]; - _splitpath (pItemInfo1->displayName.c_str(), NULL, NULL, NULL, ext1); - char ext2[_MAX_EXT]; - _splitpath (pItemInfo2->displayName.c_str(), NULL, NULL, NULL, ext2); - int res = stricmp (ext1, ext2); + std::string ext1 = NLMISC::CFile::getExtension(pItemInfo1->displayName); + std::string ext2 = NLMISC::CFile::getExtension(pItemInfo2->displayName); + int res = stricmp (ext1.c_str(), ext2.c_str()); if ( res == 0) return stricmp (pItemInfo1->displayName.c_str(), pItemInfo2->displayName.c_str()); else diff --git a/code/ryzom/tools/leveldesign/georges_dll/form_dialog.cpp b/code/ryzom/tools/leveldesign/georges_dll/form_dialog.cpp index 60a555797..76421972b 100644 --- a/code/ryzom/tools/leveldesign/georges_dll/form_dialog.cpp +++ b/code/ryzom/tools/leveldesign/georges_dll/form_dialog.cpp @@ -1173,9 +1173,7 @@ void CFormDialog::getDfnName (string &result) const { // Get the DFN filename CString str = doc->GetPathName (); - char extension[512]; - _splitpath (str, NULL, NULL, NULL, extension); - result = (*extension == '.') ? extension+1 : extension; + result NLMISC::CFile::getExtension(tStrToUtf8(str)); } else result.clear(); diff --git a/code/ryzom/tools/leveldesign/georges_dll/georges_edit.cpp b/code/ryzom/tools/leveldesign/georges_dll/georges_edit.cpp index e42408f3d..d11e33a5a 100644 --- a/code/ryzom/tools/leveldesign/georges_dll/georges_edit.cpp +++ b/code/ryzom/tools/leveldesign/georges_dll/georges_edit.cpp @@ -485,12 +485,7 @@ void CGeorgesEditApp::outputError (const char* message) void CGeorgesEditApp::getConfigFilePath (std::string &output) { // Get the config file path - char sDrive[MAX_PATH]; - char sDir[MAX_PATH]; - char sPath[MAX_PATH]; - _splitpath (theApp.ExePath.c_str (), sDrive, sDir, NULL, NULL); - _makepath (sPath, sDrive, sDir, "georges", ".cfg"); - output = sPath; + output = NLMISC::CFile::getPath(theApp.ExePath) + "georges.cfg"; } bool CGeorgesEditApp::loadCfg () @@ -962,12 +957,7 @@ void CGeorgesEditApp::gotoURL (LPCTSTR url) void CGeorgesEditApp::WinHelp(DWORD dwData, UINT nCmd) { - char drive[512]; - char dir[512]; - char path[512]; - _splitpath (ExePath.c_str (), drive, dir, NULL, NULL); - _makepath (path, drive, dir, "georges_edit", ".html"); - gotoURL (path); + gotoURL(utf8ToTStr(NLMISC::CFile::getPath(ExePath) + "georges_edit.html")); } void CGeorgesEditApp::OnViewRefresh() @@ -1478,9 +1468,8 @@ BOOL CGeorgesEditApp::OnDDECommand(LPTSTR lpszCommand) name = name.substr (6, name.size ()-8); // Get the extension - char ext[MAX_PATH]; - _splitpath (name.c_str (), NULL, NULL, NULL, ext); - string dfnName = string (ext+1) + ".dfn"; + std::string ext = NLMISC::CFile::getExtension(name); + string dfnName = ext + ".dfn"; // Get the doc template CMultiDocTemplate *docTemplate = getFormDocTemplate (dfnName.c_str ()); @@ -1541,18 +1530,15 @@ BOOL CGeorgesEditApp::OnDDECommand(LPTSTR lpszCommand) name = name.substr (8, name.size ()-10); // Get the extension - char ext[MAX_PATH]; - _splitpath (name.c_str (), NULL, NULL, NULL, ext); - string dfnName = string (ext+1) + ".dfn"; + std::string ext = NLMISC::CFile::getExtension(name); + string dfnName = ext + ".dfn"; // Create a document CGeorgesEditDocForm *doc = (CGeorgesEditDocForm*)createDocument (dfnName.c_str (), ""); if (doc) { - char nameFile[MAX_PATH]; - char extFile[MAX_PATH]; - _splitpath (name.c_str (), NULL, NULL, nameFile, extFile); - doc->addParent ((string (nameFile) + extFile).c_str ()); + std::string nameFile = NLMISC::CFile::getFilename(name); + doc->addParent (nameFile.c_str()); doc->updateDocumentStructure (); doc->UpdateAllViews (NULL); } @@ -1570,11 +1556,7 @@ BOOL CGeorgesEditApp::OnDDECommand(LPTSTR lpszCommand) name = name.substr (10, name.size ()-12); // Get the extension - char name2[MAX_PATH]; - char ext[MAX_PATH]; - _splitpath (name.c_str (), NULL, NULL, name2, ext); - string dfnName = name2; - dfnName += ext; + std::string dfnName = NLMISC::CFile::getFilename(name); // Create a document CGeorgesEditDocForm *doc = (CGeorgesEditDocForm*)createDocument (dfnName.c_str (), ""); diff --git a/code/ryzom/tools/leveldesign/georges_dll/georges_edit_doc.cpp b/code/ryzom/tools/leveldesign/georges_dll/georges_edit_doc.cpp index 7ecae14db..941824e73 100644 --- a/code/ryzom/tools/leveldesign/georges_dll/georges_edit_doc.cpp +++ b/code/ryzom/tools/leveldesign/georges_dll/georges_edit_doc.cpp @@ -181,13 +181,9 @@ bool CGeorgesEditDocForm::initDocument (const char *dfnName, bool newElement) } // Set file name and title - char name[512]; - char ext[512]; - _splitpath (dfnName, NULL, NULL, name, ext); - string name2 = (const char*)(name); - name2 = strlwr (name2); - SetPathName ( ("*."+name2).c_str(), FALSE); - SetTitle ( ("New "+name2+" form").c_str() ); + std::string name2 = toLower(NLMISC::CFile::getFilenameWithoutExtension(dfnName)); + SetPathName (utf8ToTStr("*." + name2), FALSE); + SetTitle (utf8ToTStr("New " + name2 + " form")); // TMp if (newElement) @@ -547,9 +543,9 @@ BOOL CGeorgesEditDoc::OnOpenDocument(LPCTSTR lpszPathName) try { // Check form - char ext[MAX_PATH]; - _splitpath (lpszPathName, NULL, NULL, NULL, ext); - string extLower = strlwr (string (ext)); + std::string ext = NLMISC::CFile::getExtension(tStrToUtf8(lpszPathName)); + string extLower = toLower(ext); + if (!extLower.empty ()) { string dfnName = extLower.substr (1, string::npos) + ".dfn"; @@ -1090,10 +1086,7 @@ void CGeorgesEditDoc::getDfnFilename (std::string &dfnName) // Get the DFN filename CString str = GetPathName (); - char extension[512]; - _splitpath (str, NULL, NULL, NULL, extension); - dfnName = extension+1; - dfnName += ".dfn"; + dfnName = NLMISC::CFile::getExtension(tStrToUtf8(str)) + ".dfn"; } // *************************************************************************** diff --git a/code/ryzom/tools/leveldesign/georges_dll/imagelist_ex.cpp b/code/ryzom/tools/leveldesign/georges_dll/imagelist_ex.cpp index 195a44381..590e98a25 100644 --- a/code/ryzom/tools/leveldesign/georges_dll/imagelist_ex.cpp +++ b/code/ryzom/tools/leveldesign/georges_dll/imagelist_ex.cpp @@ -103,10 +103,8 @@ void CImageListEx::addResourceIcon (const char *filename) index = ImageList.Replace( index, handle); // Add in the map - char name[MAX_PATH]; - _splitpath (filename, NULL, NULL, name, NULL); - string llwr = strlwr (string (name)); - _IconMapString.insert (std::map::value_type (llwr, index)); + std::string name = NLMISC::CFile::getFilenameWithoutExtension(filename); + _IconMapString.insert (std::map::value_type (toLower(name), index)); // Release the icon DestroyIcon (handle); @@ -131,10 +129,8 @@ int CImageListEx::getImage (int resource) const int CImageListEx::getImage (const char *filename) const { - char name[MAX_PATH]; - _splitpath (filename, NULL, NULL, name, NULL); - string llwr = strlwr (string (name)); - std::map::const_iterator ite = _IconMapString.find (llwr); + std::string name = toLower(NLMISC::CFile::getFilenameWithoutExtension(filename)); + std::map::const_iterator ite = _IconMapString.find (name); if (ite == _IconMapString.end()) return -1; else diff --git a/code/ryzom/tools/leveldesign/world_editor/world_editor/imagelist_ex.cpp b/code/ryzom/tools/leveldesign/world_editor/world_editor/imagelist_ex.cpp index 195a44381..90a917225 100644 --- a/code/ryzom/tools/leveldesign/world_editor/world_editor/imagelist_ex.cpp +++ b/code/ryzom/tools/leveldesign/world_editor/world_editor/imagelist_ex.cpp @@ -103,10 +103,8 @@ void CImageListEx::addResourceIcon (const char *filename) index = ImageList.Replace( index, handle); // Add in the map - char name[MAX_PATH]; - _splitpath (filename, NULL, NULL, name, NULL); - string llwr = strlwr (string (name)); - _IconMapString.insert (std::map::value_type (llwr, index)); + std::string name = toLower(NLMISC::CFile::getFilenameWithoutExtension(filename)); + _IconMapString.insert (std::map::value_type (name, index)); // Release the icon DestroyIcon (handle); @@ -131,10 +129,8 @@ int CImageListEx::getImage (int resource) const int CImageListEx::getImage (const char *filename) const { - char name[MAX_PATH]; - _splitpath (filename, NULL, NULL, name, NULL); - string llwr = strlwr (string (name)); - std::map::const_iterator ite = _IconMapString.find (llwr); + std::string name = toLower(NLMISC::CFile::getFilenameWithoutExtension(filename)); + std::map::const_iterator ite = _IconMapString.find (name); if (ite == _IconMapString.end()) return -1; else