From 46d99e4a6d96add6e649619895e343619875ad3e Mon Sep 17 00:00:00 2001 From: liria Date: Sat, 8 Jun 2013 15:38:04 +0200 Subject: [PATCH] FIXE: Linux/Windows compilation : revert the code of the 'void dir(...)' function for windows with using conditional compilation. --HG-- branch : ig_elevaton_port_to_linux --- code/nel/tools/3d/ig_elevation/main.cpp | 44 ++++++++++++++++++++----- 1 file changed, 35 insertions(+), 9 deletions(-) diff --git a/code/nel/tools/3d/ig_elevation/main.cpp b/code/nel/tools/3d/ig_elevation/main.cpp index 5b7d90fff..b66c4ecfc 100644 --- a/code/nel/tools/3d/ig_elevation/main.cpp +++ b/code/nel/tools/3d/ig_elevation/main.cpp @@ -35,10 +35,11 @@ #include "nel/3d/scene_group.h" -// #include -#include /* Pour l'utilisation des dossiers */ -#ifndef WIN32 +#include +#ifdef NL_OS_WINDOWS + #include +#else #include #endif #include /* getcwd,chdir -- replacement for getCurDiretory & setCurDirectory on windows */ @@ -133,8 +134,31 @@ struct CZoneLimits }; // --------------------------------------------------------------------------- - - +#ifdef NL_OS_WINDOWS // win32 code +void dir (const string &sFilter, vector &sAllFiles, bool bFullPath) +{ + WIN32_FIND_DATA findData; + HANDLE hFind; + char sCurDir[MAX_PATH]; + sAllFiles.clear (); + GetCurrentDirectory (MAX_PATH, sCurDir); + hFind = FindFirstFile (sFilter.c_str(), &findData); + while (hFind != INVALID_HANDLE_VALUE) + { + DWORD res = GetFileAttributes(findData.cFileName); + if (res != INVALID_FILE_ATTRIBUTES && !(res&FILE_ATTRIBUTE_DIRECTORY)) + { + if (bFullPath) + sAllFiles.push_back(string(sCurDir) + "\\" + findData.cFileName); + else + sAllFiles.push_back(findData.cFileName); + } + if (FindNextFile (hFind, &findData) == 0) + break; + } + FindClose (hFind); +} +#else // posix version of the void dir(...) function. void dir (const string &sFilter, vector &sAllFiles, bool bFullPath) { char sCurDir[MAX_PATH]; @@ -157,7 +181,6 @@ void dir (const string &sFilter, vector &sAllFiles, bool bFullPath) find(sFilter)!= std::string::npos ) { if (bFullPath) - // on windows should we use "\\" sAllFiles.push_back(string(sCurDir) + "/" + sFileName); else sAllFiles.push_back(sFileName); @@ -167,8 +190,7 @@ void dir (const string &sFilter, vector &sAllFiles, bool bFullPath) } closedir(dp); } - - +#endif // endif posix version of "void dir(...)" // --------------------------------------------------------------------------- CZoneRegion *loadLand (const string &filename) @@ -402,7 +424,11 @@ int main(int nNbArg, char**ppArgs) // Get all files vector vAllFiles; chdir (options.InputIGDir.c_str()); - dir (".ig", vAllFiles, false); +#ifdef NL_OS_WINDOWS + dir ("*.ig", vAllFiles, false); +#else // posix version + dir (".ig", vAllFiles, false); +#endif chdir (sCurDir); for (uint32 i = 0; i < vAllFiles.size(); ++i)