Changed: Replace all _splitpath by NeL methods

--HG--
branch : develop
This commit is contained in:
kervala 2016-11-22 19:34:43 +01:00
parent 35e3e27924
commit 033a337419
20 changed files with 126 additions and 252 deletions

View file

@ -151,7 +151,7 @@ Value* export_material_cf (Value** arg_list, int count)
nlassert (node); nlassert (node);
// The second arg // The second arg
const char *fileName = arg_list[1]->to_string(); const std::string fileName = tStrToUtf8(arg_list[1]->to_string());
// The third arg // The third arg
bool checkOnly = (arg_list[2]->to_bool() != FALSE); 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 // Make a name for the zone
char drive[512]; std::string path = CFile::getPath(fileName) + CFile::getFilenameWithoutExtension(fileName) + ".zone";
char dir[512];
char name[512];
char path[512];
_splitpath (fileName, drive, dir, name, NULL);
_makepath (path, drive, dir, name, ".zone");
// Ok ? // Ok ?
bool ok = true; bool ok = true;
@ -322,7 +317,7 @@ Value* export_transition_cf (Value** arg_list, int count)
nlassert (is_array(nodes)); nlassert (is_array(nodes));
// The second arg // The second arg
const char *fileName = arg_list[1]->to_string(); std::string fileName = tStrToUtf8(arg_list[1]->to_string());
// The second arg // The second arg
string matFilename[2]; string matFilename[2];
@ -505,10 +500,7 @@ Value* export_transition_cf (Value** arg_list, int count)
for (zone=0; zone<CTransition::TransitionZoneCount; zone++) for (zone=0; zone<CTransition::TransitionZoneCount; zone++)
{ {
// Final path // Final path
char path[512]; std::string path = CFile::getPath(fileName) + toString("%s-%u", CFile::getFilenameWithoutExtension(fileName).c_str(), zone) + ".zone";
_splitpath (fileName, drive, dir, path, NULL);
sprintf (name, "%s-%d", path, zone);
_makepath (path, drive, dir, name, ".zone");
// Another the stream // Another the stream
COFile outputfile2; COFile outputfile2;
@ -1072,30 +1064,17 @@ Value* export_zone_cf (Value** arg_list, int count)
else else
{ {
// Build a filename // Build a filename
char drive[512]; std::string path = NLMISC::CFile::getPath(fileName);
char path[512]; std::string name = NLMISC::CFile::getFilenameWithoutExtension(fileName);
char finalpath[512];
char name[512];
char ext[512];
_splitpath (fileName.c_str(), drive, path, name, ext);
// Build the zone filename // Build the zone filename
char outputFilenameZone[512]; std::string outputFilenameZone = path + "zones/" + name + ".zone";
strcpy (finalpath, path);
strcat (finalpath, "zones\\");
_makepath (outputFilenameZone, drive, finalpath, name, ".zone");
// Build the snap shot filename // Build the snap shot filename
char outputFilenameSnapShot[512]; std::string outputFilenameSnapShot = path + "zonesBitmaps/" + name + ".tga";
strcpy (finalpath, path);
strcat (finalpath, "zoneBitmaps\\");
_makepath (outputFilenameSnapShot, drive, finalpath, name, ".tga");
// Build the ligozone filename // Build the ligozone filename
char outputFilenameLigozone[512]; std::string outputFilenameLigozone = path + "zoneLigos/" + name + ".ligozone";
strcpy (finalpath, path);
strcat (finalpath, "zoneLigos\\");
_makepath (outputFilenameLigozone, drive, finalpath, name, ".ligozone");
// Build the zone // Build the zone
CZone zone; CZone zone;
@ -1179,12 +1158,12 @@ Value* export_zone_cf (Value** arg_list, int count)
if (weWantToMakeASnapshot) if (weWantToMakeASnapshot)
{ {
CIFile fileFarBank; CIFile fileFarBank;
char drive[512];
char path[512]; std::string path = NLMISC::CFile::getPath(GetBankPathName());
char name[512]; std::string name = NLMISC::CFile::getFilenameWithoutExtension(GetBankPathName());
char farBankPathName[512];
_splitpath (GetBankPathName ().c_str (), drive, path, name, NULL); std::string farBankPathName = path + name + ".farbank";
_makepath (farBankPathName, drive, path, name, "farbank");
if (fileFarBank.open (farBankPathName)) if (fileFarBank.open (farBankPathName))
{ {
// Create an xml stream // Create an xml stream
@ -1908,11 +1887,9 @@ Value* make_snapshot_cf (Value** arg_list, int count)
else else
{ {
// Build a filename // Build a filename
char drivetga[512]; std::string nametga = CFile::getFilenameWithoutExtension(fileName);
char pathtga[512]; std::string pathtga = CFile::getPath(fileName);
char nametga[512];
char exttga[512];
_splitpath (fileName.c_str(), drivetga, pathtga, nametga, exttga);
// Build the zone // Build the zone
CZone zone; CZone zone;
@ -1956,12 +1933,9 @@ Value* make_snapshot_cf (Value** arg_list, int count)
if (tileBank != NULL) if (tileBank != NULL)
{ {
CIFile fileFarBank; CIFile fileFarBank;
char drive[512]; std::string name = CFile::getFilenameWithoutExtension(GetBankPathName());
char path[512]; std::string farBankPathName = CFile::getPath(GetBankPathName()) + name + ".farbank";
char name[512];
char farBankPathName[512];
_splitpath (GetBankPathName ().c_str (), drive, path, name, NULL);
_makepath (farBankPathName, drive, path, name, "farbank");
if (fileFarBank.open (farBankPathName)) if (fileFarBank.open (farBankPathName))
{ {
// Create an xml stream // Create an xml stream
@ -1974,8 +1948,7 @@ Value* make_snapshot_cf (Value** arg_list, int count)
if (MakeSnapShot (snapshot, *tileBank, *tileFarBank, xMin, xMax, yMin, yMax, config, errorInDialog)) if (MakeSnapShot (snapshot, *tileBank, *tileFarBank, xMin, xMax, yMin, yMax, config, errorInDialog))
{ {
// Build the snap shot filename // Build the snap shot filename
char outputFilenameSnapShot[512]; std::string outputFilenameSnapShot = pathtga + nametga + ".tga";
_makepath (outputFilenameSnapShot, drivetga, pathtga, nametga, ".tga");
// Output the snap shot // Output the snap shot
COFile outputSnapShot; COFile outputSnapShot;
@ -2014,12 +1987,14 @@ Value* make_snapshot_cf (Value** arg_list, int count)
bankElm.addCategory (strlwr (categories[j].first), strlwr (categories[j].second)); bankElm.addCategory (strlwr (categories[j].first), strlwr (categories[j].second));
} }
// Catch exception
#if 0
// Write the zone // Write the zone
COFile outputLigoZone; COFile outputLigoZone;
std::string outputFilenameSnapShot = pathtga + nametga + ".tga";
_makepath (outputFilenameSnapShot, drivetga, pathtga, nametga, ".ligozone"); _makepath (outputFilenameSnapShot, drivetga, pathtga, nametga, ".ligozone");
// Catch exception try
/*try
{ {
// Open the selected zone file // Open the selected zone file
if (outputLigoZone.open (outputFilenameSnapShot)) if (outputLigoZone.open (outputFilenameSnapShot))
@ -2048,7 +2023,8 @@ Value* make_snapshot_cf (Value** arg_list, int count)
char tmp[512]; char tmp[512];
smprintf (tmp, 512, "Error while loading the file %s : %s", fileName, e.what()); smprintf (tmp, 512, "Error while loading the file %s : %s", fileName, e.what());
CMaxToLigo::errorMessage (tmp, "NeL Ligo export zone", *MAXScript_interface, errorInDialog); CMaxToLigo::errorMessage (tmp, "NeL Ligo export zone", *MAXScript_interface, errorInDialog);
}*/ }
#endif
} }
else else
{ {

View file

@ -262,8 +262,7 @@ void CAnimationSetDlg::refresh (BOOL update)
for (i=0; i<object->Saved.AnimationFileName.size(); i++) for (i=0; i<object->Saved.AnimationFileName.size(); i++)
{ {
// Get the animation name // Get the animation name
char name[512]; std::string name = NLMISC::CFile::getFilenameWithoutExtension(object->Saved.AnimationFileName[i]);
_splitpath (object->Saved.AnimationFileName[i].c_str(), NULL, NULL, name, NULL);
// Get the animation pointer // Get the animation pointer
CAnimation *anim = object->AnimationSet.getAnimation (object->AnimationSet.getAnimationIdByName (name)); CAnimation *anim = object->AnimationSet.getAnimation (object->AnimationSet.getAnimationIdByName (name));
@ -314,8 +313,7 @@ void CAnimationSetDlg::refresh (BOOL update)
for (i=0; i<object->Saved.SWTFileName.size(); i++) for (i=0; i<object->Saved.SWTFileName.size(); i++)
{ {
// Get the animation name // Get the animation name
char name[512]; std::string name = NLMISC::CFile::getFilenameWithoutExtension(object->Saved.SWTFileName[i]);
_splitpath (object->Saved.SWTFileName[i].c_str(), NULL, NULL, name, NULL);
// Get the animation pointer // Get the animation pointer
CSkeletonWeight *swt = object->AnimationSet.getSkeletonWeight (object->AnimationSet.getSkeletonWeightIdByName (name)); CSkeletonWeight *swt = object->AnimationSet.getSkeletonWeight (object->AnimationSet.getSkeletonWeightIdByName (name));

View file

@ -84,21 +84,9 @@ bool CEditMorphMeshDlg::getShapeNameFromDlg(std::string &name)
CFileDialog fd(TRUE, _T(".shape"), _T("*.shape"), 0, NULL, this); CFileDialog fd(TRUE, _T(".shape"), _T("*.shape"), 0, NULL, this);
if (fd.DoModal() == IDOK) 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 // Add search path for the texture
/* /*
_splitpath (fd.GetPathName(), drive, dir, fname, ext); NLMISC::CPath::addSearchPath (NLMISC::CFile::getPath(tStrToUtf8(fd.GetPathName()));
_makepath (path, drive, dir, NULL, NULL);
NLMISC::CPath::addSearchPath (path);
*/ */
name = tStrToUtf8(fd.GetPathName()); name = tStrToUtf8(fd.GetPathName());

View file

@ -94,22 +94,17 @@ void CMeshDlg::OnBrowseShape()
if (fd.DoModal() == IDOK) if (fd.DoModal() == IDOK)
{ {
// Add to the path // Add to the path
char drive[256]; std::string fullPath = tStrToUtf8(fd.GetPathName());
char dir[256]; std::string fname = NLMISC::CFile::getFilenameWithoutExtension(fullPath);
char path[256]; std::string ext = NLMISC::CFile::getExtension(fullPath);
char fname[256];
char ext[256];
// Add search path for the texture // Add search path for the texture
_splitpath (fd.GetPathName(), drive, dir, fname, ext); NLMISC::CPath::addSearchPath (NLMISC::CFile::getPath(fullPath));
_makepath (path, drive, dir, NULL, NULL);
NLMISC::CPath::addSearchPath (path);
try try
{ {
_ShapeParticle->setShape(std::string(fname) + ext); _ShapeParticle->setShape(fname + "." + ext);
m_ShapeName = (std::string(fname) + ext).c_str(); m_ShapeName = utf8ToTStr(fname + "." + ext);
touchPSState(); touchPSState();
} }
catch (const NLMISC::Exception &e) catch (const NLMISC::Exception &e)

View file

@ -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; } 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]; char sModulePath[256];
int res = GetModuleFileName(hModule, 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; } 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; }
char SDrive[512];
char SDir[512]; std::string modulePath = NLMISC::CFile::getPath(tStrToUtf8(sModulePath)) + "object_viewer.cfg";
_splitpath (sModulePath, SDrive, SDir, NULL, NULL);
_makepath (sModulePath, SDrive, SDir, "object_viewer", ".cfg");
// Load the config file // Load the config file
CConfigFile cf; CConfigFile cf;
cf.load (sModulePath); cf.load (modulePath);
try try
{ {

View file

@ -1142,22 +1142,6 @@ int CExportNel::getVertMapChannel (Texmap& texmap, Matrix3& channelMatrix, TimeV
// get the absolute or relative path from a texture filename // get the absolute or relative path from a texture filename
static std::string ConvertTexFileName(const std::string &path, bool _AbsolutePath) 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) if (_AbsolutePath)
{ {
return path; return path;

View file

@ -561,13 +561,10 @@ std::string CExportNel::getNelObjectName (INode& node)
ad = obj->GetAppDataChunk (MAXSCRIPT_UTILITY_CLASS_ID, UTILITY_CLASS_ID, NEL3D_APPDATA_INSTANCE_SHAPE); ad = obj->GetAppDataChunk (MAXSCRIPT_UTILITY_CLASS_ID, UTILITY_CLASS_ID, NEL3D_APPDATA_INSTANCE_SHAPE);
if (ad&&ad->data) if (ad&&ad->data)
{ {
if (::strlen((const char *) ad->data) != 0) if (_tcslen((const TCHAR *) ad->data) != 0)
{ {
// get file name only // get file name only
char fName[_MAX_FNAME]; return NLMISC::CFile::getFilename(tStrToUtf8((const TCHAR*)ad->data));
char ext[_MAX_FNAME];
::_splitpath((const char*)ad->data, NULL, NULL, fName, ext) ;
return std::string(fName + std::string(ext));
} }
else else
{ {

View file

@ -4058,20 +4058,18 @@ bool loadLigoConfigFile (CLigoConfig& config, Interface& it)
if (hModule) if (hModule)
{ {
// Get the path // Get the path
char sModulePath[256]; TCHAR sModulePath[256];
int res=GetModuleFileName(hModule, sModulePath, 256); int res=GetModuleFileName(hModule, sModulePath, 256);
// Success ? // Success ?
if (res) if (res)
{ {
// Path // Path
char sDrive[256]; std::string modulePath = NLMISC::CFile::getPath(tStrToUtf8(sModulePath));
char sDir[256];
_splitpath (sModulePath, sDrive, sDir, NULL, NULL);
_makepath (sModulePath, sDrive, sDir, "ligoscape", ".cfg");
try try
{ {
// Load the config file // Load the config file
config.readConfigFile (sModulePath, false); config.readConfigFile (modulePath, false);
// ok // ok
return true; return true;
} }

View file

@ -409,24 +409,17 @@ void LoadKeyCfg ()
HMODULE hModule = hInstance; HMODULE hModule = hInstance;
if (hModule) if (hModule)
{ {
char sModulePath[256]; TCHAR sModulePath[256];
int res=GetModuleFileName(hModule, sModulePath, 256); int res=GetModuleFileName(hModule, sModulePath, 256);
if (res) if (res)
{ {
// split path
char drive[256];
char dir[256];
_splitpath (sModulePath, drive, dir, NULL, NULL);
// Make a new path // Make a new path
char cgfPath[256]; std::string cfgPath = NLMISC::CFile::getPath(tStrToUtf8(sModulePath)) + "keys.cfg";
_makepath (cgfPath, drive, dir, "keys", ".cfg");
CConfigFile cf; CConfigFile cf;
// Load and parse "test.txt" file // Load and parse "test.txt" file
cf.load (cgfPath); cf.load (cfgPath);
// For each keys // For each keys
for (uint key=0; key<KeyCounter; key++) for (uint key=0; key<KeyCounter; key++)
@ -458,23 +451,18 @@ void LoadVarCfg ()
HMODULE hModule = hInstance; HMODULE hModule = hInstance;
if (hModule) if (hModule)
{ {
char sModulePath[256]; TCHAR sModulePath[256];
int res=GetModuleFileName(hModule, sModulePath, 256); int res=GetModuleFileName(hModule, sModulePath, 256);
if (res) if (res)
{ {
// split path
char drive[256];
char dir[256];
_splitpath (sModulePath, drive, dir, NULL, NULL);
// Make a new path // Make a new path
char cgfPath[256]; char cgfPath[256];
_makepath (cgfPath, drive, dir, "keys", ".cfg"); std::string cfgPath = NLMISC::CFile::getPath(tStrToUtf8(sModulePath)) + "keys.cfg";
CConfigFile cf; CConfigFile cf;
// Load and parse "test.txt" file // Load and parse "test.txt" file
cf.load (cgfPath); cf.load (cfgPath);
// go // go
try try

View file

@ -366,18 +366,15 @@ void Tile_utility::SetupUI ()
if (Bank.getLandCount()) if (Bank.getLandCount())
{ {
// Button text // Button text
char sName[256]; std::string name = toLower(NLMISC::CFile::getFilenameWithoutExtension(Path));
_splitpath (Path.c_str(), NULL, NULL, sName, NULL);
char *sName2=sName; if (!name.empty())
if (*sName2)
*sName2=toupper (*sName2);
sName2++;
while (*sName2)
{ {
*sName2=tolower (*sName2); std::string upName = toUpper(name);
sName2++; name[0] = upName[0];
} }
SetWindowText (hwnd, sName);
SetWindowText (hwnd, utf8ToTStr(name));
// Static text // Static text
TCHAR sTmp[256]; TCHAR sTmp[256];

View file

@ -889,11 +889,11 @@ void Browse::OnBatchLoad ()
if (sFile.DoModal()==IDOK) if (sFile.DoModal()==IDOK)
{ {
char sDrive[256]; std::string fullPath = tStrToUtf8(sFile.GetPathName());
char sPath[256];
char sName[256]; std::string path = NLMISC::CFile::getPath(fullPath);
char sExt[256]; std::string filename = NLMISC::CFile::getFilenameWithoutExtension(fullPath);
_splitpath (sFile.GetPathName(), sDrive, sPath, sName, sExt); std::string ext = NLMISC::CFile::getExtension(fullPath);
// look for some numbers.. // look for some numbers..
char *sNumber=sName+strlen(sName)-1; char *sNumber=sName+strlen(sName)-1;
@ -925,11 +925,9 @@ void Browse::OnBatchLoad ()
for (int rot=0; rot<4; rot++) for (int rot=0; rot<4; rot++)
{ {
// Try to load a tile with a file name like /tiletransition0.tga // Try to load a tile with a file name like /tiletransition0.tga
char sName2[256]; std::string sFinal = path + toString("%s%02d.%s", filename.c_str(), (int)transition, ext.c_str());
char sFinal[256];
sprintf (sName2, "%s%02d", sName, (int)transition); FILE *pFile = nlfopen (sFinal, "rb");
_makepath (sFinal, sDrive, sPath, sName2, sExt);
FILE *pFile=fopen (sFinal, "rb");
// Close the file and add the tile if opened // Close the file and add the tile if opened
if (pFile) if (pFile)
@ -961,11 +959,9 @@ void Browse::OnBatchLoad ()
if (tileBank2.getTile (trans->getTile())->getRelativeFileName (m_ctrl.Texture==1?CTile::diffuse:CTile::additive).empty()) if (tileBank2.getTile (trans->getTile())->getRelativeFileName (m_ctrl.Texture==1?CTile::diffuse:CTile::additive).empty())
{ {
// Try to load a tile with a file name like /tiletransition0.tga // Try to load a tile with a file name like /tiletransition0.tga
char sName2[256]; std::string sFinal = path + toString("%s%02d.%s", filename.c_str(), (int)transition, ext.c_str());
char sFinal[256];
sprintf (sName2, "%s%02d", sName, (int)transition); FILE *pFile = nlfopen (sFinal, "rb");
_makepath (sFinal, sDrive, sPath, sName2, sExt);
FILE *pFile=fopen (sFinal, "rb");
// Close the file and add the tile if opened // Close the file and add the tile if opened
if (pFile) if (pFile)

View file

@ -386,12 +386,8 @@ void SelectionTerritoire::OnSelect()
list2->AddString(tileBank.getTileSet(i)->getName().c_str()); list2->AddString(tileBank.getTileSet(i)->getName().c_str());
} }
char drive[256],name[256],path[256],ext[256]; MainFileName = CString(utf8ToTStr(NLMISC::CFile::getFilename(temp)));
_splitpath(temp,drive,path,name,ext); DefautPath = CString(utf8ToTStr(NLMISC::CFile::getPath(temp)));
MainFileName = name;
MainFileName += ext;
DefautPath = drive;
DefautPath += path;
MainFileOk = 1; MainFileOk = 1;
CButton *button = (CButton*)GetDlgItem(IDC_ADD_TERRITOIRE); CButton *button = (CButton*)GetDlgItem(IDC_ADD_TERRITOIRE);
@ -468,12 +464,10 @@ void SelectionTerritoire::OnSaveAs()
button->EnableWindow(true); button->EnableWindow(true);
// Create a file name // Create a file name
char drive[256],name[256],path[256],ext[256]; std::string temp = tStrToUtf8(sFile.GetPathName());
_splitpath(sFile.GetPathName(), drive, path, name, ext);
MainFileName = name; MainFileName = CString(utf8ToTStr(NLMISC::CFile::getFilename(temp)));
MainFileName += ext; DefautPath = CString(utf8ToTStr(NLMISC::CFile::getPath(temp)));
DefautPath = drive;
DefautPath += path;
} }
} }

View file

@ -1283,11 +1283,10 @@ void CTView::DrawTile(tilelist::iterator i,CDC *pDC,int clear, int n)
&*bits->begin(),bmpinf,DIB_RGB_COLORS,SRCCOPY); &*bits->begin(),bmpinf,DIB_RGB_COLORS,SRCCOPY);
} }
char temp[100]; std::string Name;
char Name[256]; Name[0] = 0;
if (InfoTexte==2) if (InfoTexte==2)
{ {
_splitpath(pth.c_str(),temp,temp,Name,temp); Name = NLMISC::CFile::getFilenameWithoutExtension(pth);
} }
else if (InfoTexte==3) else if (InfoTexte==3)
{ {
@ -1295,12 +1294,20 @@ void CTView::DrawTile(tilelist::iterator i,CDC *pDC,int clear, int n)
} }
else if (InfoTexte==1) 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.top = pt.y + sizetile_y + spacing_tile_text;
rect_txt.bottom += rect_txt.top + sizetext_y; rect_txt.bottom += rect_txt.top + sizetext_y;
rect_txt.left -= spacing_x; 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 // Restore the device context
pDC->SetBkColor( clrBk ); pDC->SetBkColor( clrBk );
@ -1537,15 +1544,12 @@ LRESULT CTView::WindowProc(UINT message, WPARAM wParam, LPARAM lParam)
{ {
CString str = load.GetNextPathName(p); CString str = load.GetNextPathName(p);
char sDrive[256]; LastPath = NLMISC::CFile::getPath(tStrToUtf8(str));
char sPath[256];
_splitpath (str, sDrive, sPath, NULL, NULL);
LastPath=string (sDrive)+string (sPath);
if (str!=CString("")) if (!str.IsEmpty())
{ {
int index=0; int index=0;
const char *pathname = (LPCTSTR)str; std::string pathname = tStrToUtf8(str);
// Add mode, to the end of the list // Add mode, to the end of the list
if (id==ID_MENU_ADD) if (id==ID_MENU_ADD)

View file

@ -420,19 +420,17 @@ void CDfnEditListCtrl::onItemChanged (uint item, uint subItem)
{ {
CString str; CString str;
str = Dialog->Struct.ListCtrl.GetItemText (item, 2); str = Dialog->Struct.ListCtrl.GetItemText (item, 2);
char ext[MAX_PATH]; std::string ext = NLMISC::CFile::getExtension(tStrToUtf8(str));
_splitpath (str, NULL, NULL, NULL, ext); if (ext == "typ")
if (stricmp (ext, ".typ") != 0) Dialog->Struct.ListCtrl.SetItemText (item, 2, utf8ToTStr(theApp.DefaultType));
Dialog->Struct.ListCtrl.SetItemText (item, 2, theApp.DefaultType.c_str ());
} }
else if ((type == "Dfn") || (type == "Dfn array")) else if ((type == "Dfn") || (type == "Dfn array"))
{ {
CString str; CString str;
str = Dialog->Struct.ListCtrl.GetItemText (item, 2); str = Dialog->Struct.ListCtrl.GetItemText (item, 2);
char ext[MAX_PATH]; std::string ext = NLMISC::CFile::getExtension(tStrToUtf8(str));
_splitpath (str, NULL, NULL, NULL, ext); if (ext == "dfn")
if (stricmp (ext, ".dfn") != 0) Dialog->Struct.ListCtrl.SetItemText (item, 2, utf8ToTStr(theApp.DefaultDfn));
Dialog->Struct.ListCtrl.SetItemText (item, 2, theApp.DefaultDfn.c_str ());
// Clear default value // Clear default value
Dialog->Struct.ListCtrl.SetItemText (item, 3, _T("")); Dialog->Struct.ListCtrl.SetItemText (item, 3, _T(""));

View file

@ -403,11 +403,9 @@ int CALLBACK CompareFunc(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort)
return stricmp (pItemInfo1->displayName.c_str(), pItemInfo2->displayName.c_str()); return stricmp (pItemInfo1->displayName.c_str(), pItemInfo2->displayName.c_str());
if (pfileTreeCtrl->_ArrangeMode == CFileTreeCtrl::ByType) if (pfileTreeCtrl->_ArrangeMode == CFileTreeCtrl::ByType)
{ {
char ext1[_MAX_EXT]; std::string ext1 = NLMISC::CFile::getExtension(pItemInfo1->displayName);
_splitpath (pItemInfo1->displayName.c_str(), NULL, NULL, NULL, ext1); std::string ext2 = NLMISC::CFile::getExtension(pItemInfo2->displayName);
char ext2[_MAX_EXT]; int res = stricmp (ext1.c_str(), ext2.c_str());
_splitpath (pItemInfo2->displayName.c_str(), NULL, NULL, NULL, ext2);
int res = stricmp (ext1, ext2);
if ( res == 0) if ( res == 0)
return stricmp (pItemInfo1->displayName.c_str(), pItemInfo2->displayName.c_str()); return stricmp (pItemInfo1->displayName.c_str(), pItemInfo2->displayName.c_str());
else else

View file

@ -1173,9 +1173,7 @@ void CFormDialog::getDfnName (string &result) const
{ {
// Get the DFN filename // Get the DFN filename
CString str = doc->GetPathName (); CString str = doc->GetPathName ();
char extension[512]; result NLMISC::CFile::getExtension(tStrToUtf8(str));
_splitpath (str, NULL, NULL, NULL, extension);
result = (*extension == '.') ? extension+1 : extension;
} }
else else
result.clear(); result.clear();

View file

@ -485,12 +485,7 @@ void CGeorgesEditApp::outputError (const char* message)
void CGeorgesEditApp::getConfigFilePath (std::string &output) void CGeorgesEditApp::getConfigFilePath (std::string &output)
{ {
// Get the config file path // Get the config file path
char sDrive[MAX_PATH]; output = NLMISC::CFile::getPath(theApp.ExePath) + "georges.cfg";
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;
} }
bool CGeorgesEditApp::loadCfg () bool CGeorgesEditApp::loadCfg ()
@ -962,12 +957,7 @@ void CGeorgesEditApp::gotoURL (LPCTSTR url)
void CGeorgesEditApp::WinHelp(DWORD dwData, UINT nCmd) void CGeorgesEditApp::WinHelp(DWORD dwData, UINT nCmd)
{ {
char drive[512]; gotoURL(utf8ToTStr(NLMISC::CFile::getPath(ExePath) + "georges_edit.html"));
char dir[512];
char path[512];
_splitpath (ExePath.c_str (), drive, dir, NULL, NULL);
_makepath (path, drive, dir, "georges_edit", ".html");
gotoURL (path);
} }
void CGeorgesEditApp::OnViewRefresh() void CGeorgesEditApp::OnViewRefresh()
@ -1478,9 +1468,8 @@ BOOL CGeorgesEditApp::OnDDECommand(LPTSTR lpszCommand)
name = name.substr (6, name.size ()-8); name = name.substr (6, name.size ()-8);
// Get the extension // Get the extension
char ext[MAX_PATH]; std::string ext = NLMISC::CFile::getExtension(name);
_splitpath (name.c_str (), NULL, NULL, NULL, ext); string dfnName = ext + ".dfn";
string dfnName = string (ext+1) + ".dfn";
// Get the doc template // Get the doc template
CMultiDocTemplate *docTemplate = getFormDocTemplate (dfnName.c_str ()); CMultiDocTemplate *docTemplate = getFormDocTemplate (dfnName.c_str ());
@ -1541,18 +1530,15 @@ BOOL CGeorgesEditApp::OnDDECommand(LPTSTR lpszCommand)
name = name.substr (8, name.size ()-10); name = name.substr (8, name.size ()-10);
// Get the extension // Get the extension
char ext[MAX_PATH]; std::string ext = NLMISC::CFile::getExtension(name);
_splitpath (name.c_str (), NULL, NULL, NULL, ext); string dfnName = ext + ".dfn";
string dfnName = string (ext+1) + ".dfn";
// Create a document // Create a document
CGeorgesEditDocForm *doc = (CGeorgesEditDocForm*)createDocument (dfnName.c_str (), ""); CGeorgesEditDocForm *doc = (CGeorgesEditDocForm*)createDocument (dfnName.c_str (), "");
if (doc) if (doc)
{ {
char nameFile[MAX_PATH]; std::string nameFile = NLMISC::CFile::getFilename(name);
char extFile[MAX_PATH]; doc->addParent (nameFile.c_str());
_splitpath (name.c_str (), NULL, NULL, nameFile, extFile);
doc->addParent ((string (nameFile) + extFile).c_str ());
doc->updateDocumentStructure (); doc->updateDocumentStructure ();
doc->UpdateAllViews (NULL); doc->UpdateAllViews (NULL);
} }
@ -1570,11 +1556,7 @@ BOOL CGeorgesEditApp::OnDDECommand(LPTSTR lpszCommand)
name = name.substr (10, name.size ()-12); name = name.substr (10, name.size ()-12);
// Get the extension // Get the extension
char name2[MAX_PATH]; std::string dfnName = NLMISC::CFile::getFilename(name);
char ext[MAX_PATH];
_splitpath (name.c_str (), NULL, NULL, name2, ext);
string dfnName = name2;
dfnName += ext;
// Create a document // Create a document
CGeorgesEditDocForm *doc = (CGeorgesEditDocForm*)createDocument (dfnName.c_str (), ""); CGeorgesEditDocForm *doc = (CGeorgesEditDocForm*)createDocument (dfnName.c_str (), "");

View file

@ -181,13 +181,9 @@ bool CGeorgesEditDocForm::initDocument (const char *dfnName, bool newElement)
} }
// Set file name and title // Set file name and title
char name[512]; std::string name2 = toLower(NLMISC::CFile::getFilenameWithoutExtension(dfnName));
char ext[512]; SetPathName (utf8ToTStr("*." + name2), FALSE);
_splitpath (dfnName, NULL, NULL, name, ext); SetTitle (utf8ToTStr("New " + name2 + " form"));
string name2 = (const char*)(name);
name2 = strlwr (name2);
SetPathName ( ("*."+name2).c_str(), FALSE);
SetTitle ( ("New "+name2+" form").c_str() );
// TMp // TMp
if (newElement) if (newElement)
@ -547,9 +543,9 @@ BOOL CGeorgesEditDoc::OnOpenDocument(LPCTSTR lpszPathName)
try try
{ {
// Check form // Check form
char ext[MAX_PATH]; std::string ext = NLMISC::CFile::getExtension(tStrToUtf8(lpszPathName));
_splitpath (lpszPathName, NULL, NULL, NULL, ext); string extLower = toLower(ext);
string extLower = strlwr (string (ext));
if (!extLower.empty ()) if (!extLower.empty ())
{ {
string dfnName = extLower.substr (1, string::npos) + ".dfn"; string dfnName = extLower.substr (1, string::npos) + ".dfn";
@ -1090,10 +1086,7 @@ void CGeorgesEditDoc::getDfnFilename (std::string &dfnName)
// Get the DFN filename // Get the DFN filename
CString str = GetPathName (); CString str = GetPathName ();
char extension[512]; dfnName = NLMISC::CFile::getExtension(tStrToUtf8(str)) + ".dfn";
_splitpath (str, NULL, NULL, NULL, extension);
dfnName = extension+1;
dfnName += ".dfn";
} }
// *************************************************************************** // ***************************************************************************

View file

@ -103,10 +103,8 @@ void CImageListEx::addResourceIcon (const char *filename)
index = ImageList.Replace( index, handle); index = ImageList.Replace( index, handle);
// Add in the map // Add in the map
char name[MAX_PATH]; std::string name = NLMISC::CFile::getFilenameWithoutExtension(filename);
_splitpath (filename, NULL, NULL, name, NULL); _IconMapString.insert (std::map<string, int>::value_type (toLower(name), index));
string llwr = strlwr (string (name));
_IconMapString.insert (std::map<string, int>::value_type (llwr, index));
// Release the icon // Release the icon
DestroyIcon (handle); DestroyIcon (handle);
@ -131,10 +129,8 @@ int CImageListEx::getImage (int resource) const
int CImageListEx::getImage (const char *filename) const int CImageListEx::getImage (const char *filename) const
{ {
char name[MAX_PATH]; std::string name = toLower(NLMISC::CFile::getFilenameWithoutExtension(filename));
_splitpath (filename, NULL, NULL, name, NULL); std::map<string, int>::const_iterator ite = _IconMapString.find (name);
string llwr = strlwr (string (name));
std::map<string, int>::const_iterator ite = _IconMapString.find (llwr);
if (ite == _IconMapString.end()) if (ite == _IconMapString.end())
return -1; return -1;
else else

View file

@ -103,10 +103,8 @@ void CImageListEx::addResourceIcon (const char *filename)
index = ImageList.Replace( index, handle); index = ImageList.Replace( index, handle);
// Add in the map // Add in the map
char name[MAX_PATH]; std::string name = toLower(NLMISC::CFile::getFilenameWithoutExtension(filename));
_splitpath (filename, NULL, NULL, name, NULL); _IconMapString.insert (std::map<string, int>::value_type (name, index));
string llwr = strlwr (string (name));
_IconMapString.insert (std::map<string, int>::value_type (llwr, index));
// Release the icon // Release the icon
DestroyIcon (handle); DestroyIcon (handle);
@ -131,10 +129,8 @@ int CImageListEx::getImage (int resource) const
int CImageListEx::getImage (const char *filename) const int CImageListEx::getImage (const char *filename) const
{ {
char name[MAX_PATH]; std::string name = toLower(NLMISC::CFile::getFilenameWithoutExtension(filename));
_splitpath (filename, NULL, NULL, name, NULL); std::map<string, int>::const_iterator ite = _IconMapString.find (name);
string llwr = strlwr (string (name));
std::map<string, int>::const_iterator ite = _IconMapString.find (llwr);
if (ite == _IconMapString.end()) if (ite == _IconMapString.end())
return -1; return -1;
else else