From 8e15feaa135ee813fabfac96dca0f930c96c6f45 Mon Sep 17 00:00:00 2001 From: kervala Date: Wed, 7 Dec 2016 14:22:50 +0100 Subject: [PATCH] Fixed: Replace Win32 code by multiplatform one using NeL classes --HG-- branch : develop --- code/nel/src/ligo/zone_bank.cpp | 23 ++++++++--------------- 1 file changed, 8 insertions(+), 15 deletions(-) diff --git a/code/nel/src/ligo/zone_bank.cpp b/code/nel/src/ligo/zone_bank.cpp index a72d1a98f..095410582 100644 --- a/code/nel/src/ligo/zone_bank.cpp +++ b/code/nel/src/ligo/zone_bank.cpp @@ -493,32 +493,25 @@ void CZoneBank::reset () _Selection.clear (); } -#ifdef NL_OS_WINDOWS // --------------------------------------------------------------------------- bool CZoneBank::initFromPath(const std::string &sPathName, std::string &error) { - char sDirBackup[512]; - GetCurrentDirectory (512, sDirBackup); - SetCurrentDirectory (sPathName.c_str()); - WIN32_FIND_DATA findData; - HANDLE hFind; - hFind = FindFirstFile ("*.ligozone", &findData); + std::vector files; + NLMISC::CPath::getPathContent(sPathName, false, false, true, files); - while (hFind != INVALID_HANDLE_VALUE) + for (uint i = 0, len = files.size(); i < len; ++i) { - // If the name of the file is not . or .. then its a valid entry in the DataBase - if (!((strcmp (findData.cFileName, ".") == 0) || (strcmp (findData.cFileName, "..") == 0))) + std::string ext = NLMISC::CFile::getExtension(files[i]); + + if (ext == "ligozone") { - if (!addElement (findData.cFileName, error)) + if (!addElement(NLMISC::CFile::getFilename(files[i]), error)) return false; } - if (FindNextFile (hFind, &findData) == 0) - break; } - SetCurrentDirectory (sDirBackup); + return true; } -#endif // NL_OS_WINDOWS // --------------------------------------------------------------------------- bool CZoneBank::addElement (const std::string &elementName, std::string &error)