FIXE: replace the WIN32 API for directories manipulation by the the POSIX API to compile with linux.
This commit is contained in:
parent
a88a4ad992
commit
4caa7fba89
2 changed files with 62 additions and 35 deletions
|
@ -3,6 +3,7 @@ SUBDIRS(
|
||||||
build_far_bank
|
build_far_bank
|
||||||
build_smallbank
|
build_smallbank
|
||||||
ig_lighter
|
ig_lighter
|
||||||
|
ig_elevation
|
||||||
zone_dependencies
|
zone_dependencies
|
||||||
zone_ig_lighter
|
zone_ig_lighter
|
||||||
zone_lighter
|
zone_lighter
|
||||||
|
@ -26,7 +27,7 @@ SUBDIRS(
|
||||||
zviewer)
|
zviewer)
|
||||||
|
|
||||||
IF(WIN32)
|
IF(WIN32)
|
||||||
ADD_SUBDIRECTORY(ig_elevation)
|
# ADD_SUBDIRECTORY(ig_elevation)
|
||||||
ADD_SUBDIRECTORY(lightmap_optimizer)
|
ADD_SUBDIRECTORY(lightmap_optimizer)
|
||||||
|
|
||||||
IF(MFC_FOUND)
|
IF(MFC_FOUND)
|
||||||
|
|
|
@ -35,7 +35,14 @@
|
||||||
|
|
||||||
#include "nel/3d/scene_group.h"
|
#include "nel/3d/scene_group.h"
|
||||||
|
|
||||||
#include <windows.h>
|
// #include <windows.h>
|
||||||
|
|
||||||
|
#include <dirent.h> /* Pour l'utilisation des dossiers */
|
||||||
|
#ifndef WIN32
|
||||||
|
#include <sys/types.h>
|
||||||
|
#endif
|
||||||
|
#include <unistd.h> /* getcwd,chdir -- replacement for getCurDiretory & setCurDirectory on windows */
|
||||||
|
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
@ -126,31 +133,43 @@ struct CZoneLimits
|
||||||
};
|
};
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
void dir (const string &sFilter, vector<string> &sAllFiles, bool bFullPath)
|
void dir (const string &sFilter, vector<string> &sAllFiles, bool bFullPath)
|
||||||
{
|
{
|
||||||
WIN32_FIND_DATA findData;
|
|
||||||
HANDLE hFind;
|
|
||||||
char sCurDir[MAX_PATH];
|
char sCurDir[MAX_PATH];
|
||||||
|
DIR* dp = NULL;
|
||||||
|
struct dirent *dirp= NULL;
|
||||||
|
|
||||||
|
getcwd ( sCurDir, MAX_PATH ) ;
|
||||||
sAllFiles.clear ();
|
sAllFiles.clear ();
|
||||||
GetCurrentDirectory (MAX_PATH, sCurDir);
|
if ( (dp = opendir( sCurDir )) == NULL) {
|
||||||
hFind = FindFirstFile (sFilter.c_str(), &findData);
|
string sTmp = string("ERROR : Can't open the dir : \"")+string(sCurDir)+string("\"") ;
|
||||||
while (hFind != INVALID_HANDLE_VALUE)
|
outString ( sTmp ) ;
|
||||||
{
|
return ;
|
||||||
DWORD res = GetFileAttributes(findData.cFileName);
|
}
|
||||||
if (res != INVALID_FILE_ATTRIBUTES && !(res&FILE_ATTRIBUTE_DIRECTORY))
|
|
||||||
|
while ( (dirp = readdir(dp)) != NULL) {
|
||||||
|
|
||||||
|
|
||||||
|
std:string sFileName = std::string(dirp->d_name) ;
|
||||||
|
if ( sFileName.substr((sFileName.length()-sFilter.length()),sFilter.length()).
|
||||||
|
find(sFilter)!= std::string::npos )
|
||||||
{
|
{
|
||||||
if (bFullPath)
|
if (bFullPath)
|
||||||
sAllFiles.push_back(string(sCurDir) + "\\" + findData.cFileName);
|
// on windows should we use "\\"
|
||||||
|
sAllFiles.push_back(string(sCurDir) + "/" + sFileName);
|
||||||
else
|
else
|
||||||
sAllFiles.push_back(findData.cFileName);
|
sAllFiles.push_back(sFileName);
|
||||||
|
|
||||||
}
|
}
|
||||||
if (FindNextFile (hFind, &findData) == 0)
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
FindClose (hFind);
|
closedir(dp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
CZoneRegion *loadLand (const string &filename)
|
CZoneRegion *loadLand (const string &filename)
|
||||||
{
|
{
|
||||||
|
@ -222,12 +241,14 @@ void SaveInstanceGroup (const char* sFilename, CInstanceGroup *pIG)
|
||||||
}
|
}
|
||||||
catch (const Exception &e)
|
catch (const Exception &e)
|
||||||
{
|
{
|
||||||
outString(string(e.what()));
|
string stTmp = string(e.what()) ;
|
||||||
|
outString( stTmp );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
outString(string("Couldn't create ") + sFilename);
|
string stTemp = string("Couldn't create ") + string(sFilename) ;
|
||||||
|
outString( stTemp );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -274,7 +295,7 @@ int main(int nNbArg, char**ppArgs)
|
||||||
|
|
||||||
NL3D_BlockMemoryAssertOnPurge = false;
|
NL3D_BlockMemoryAssertOnPurge = false;
|
||||||
char sCurDir[MAX_PATH];
|
char sCurDir[MAX_PATH];
|
||||||
GetCurrentDirectory (MAX_PATH, sCurDir);
|
getcwd (sCurDir,MAX_PATH);
|
||||||
|
|
||||||
if (nNbArg != 2)
|
if (nNbArg != 2)
|
||||||
{
|
{
|
||||||
|
@ -334,7 +355,9 @@ int main(int nNbArg, char**ppArgs)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
outString(string("Couldn't not open " + options.HeightMapFile1 + " : heightmap 1 map ignored"));
|
string sTmp = string("Couldn't not open ")+string(options.HeightMapFile1)
|
||||||
|
+string(" : heightmap 1 map ignored");
|
||||||
|
outString(sTmp);
|
||||||
delete HeightMap1;
|
delete HeightMap1;
|
||||||
HeightMap1 = NULL;
|
HeightMap1 = NULL;
|
||||||
}
|
}
|
||||||
|
@ -360,7 +383,9 @@ int main(int nNbArg, char**ppArgs)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
outString(string("Couldn't not open " + options.HeightMapFile2 + " : heightmap 2 map ignored\n"));
|
string sTmp = string("Couldn't not open ")+string(options.HeightMapFile2)
|
||||||
|
+string(" : heightmap 2 map ignored\n");
|
||||||
|
outString(sTmp);
|
||||||
delete HeightMap2;
|
delete HeightMap2;
|
||||||
HeightMap2 = NULL;
|
HeightMap2 = NULL;
|
||||||
}
|
}
|
||||||
|
@ -376,15 +401,15 @@ int main(int nNbArg, char**ppArgs)
|
||||||
|
|
||||||
// Get all files
|
// Get all files
|
||||||
vector<string> vAllFiles;
|
vector<string> vAllFiles;
|
||||||
SetCurrentDirectory (options.InputIGDir.c_str());
|
chdir (options.InputIGDir.c_str());
|
||||||
dir ("*.ig", vAllFiles, false);
|
dir (".ig", vAllFiles, false);
|
||||||
SetCurrentDirectory (sCurDir);
|
chdir (sCurDir);
|
||||||
|
|
||||||
for (uint32 i = 0; i < vAllFiles.size(); ++i)
|
for (uint32 i = 0; i < vAllFiles.size(); ++i)
|
||||||
{
|
{
|
||||||
SetCurrentDirectory (options.InputIGDir.c_str());
|
chdir (options.InputIGDir.c_str());
|
||||||
CInstanceGroup *pIG = LoadInstanceGroup (vAllFiles[i].c_str());
|
CInstanceGroup *pIG = LoadInstanceGroup (vAllFiles[i].c_str());
|
||||||
SetCurrentDirectory (sCurDir);
|
chdir (sCurDir);
|
||||||
if (pIG != NULL)
|
if (pIG != NULL)
|
||||||
{
|
{
|
||||||
bool realTimeSunContribution = pIG->getRealTimeSunContribution();
|
bool realTimeSunContribution = pIG->getRealTimeSunContribution();
|
||||||
|
@ -459,12 +484,13 @@ int main(int nNbArg, char**ppArgs)
|
||||||
pIGout->enableRealTimeSunContribution(realTimeSunContribution);
|
pIGout->enableRealTimeSunContribution(realTimeSunContribution);
|
||||||
|
|
||||||
|
|
||||||
SetCurrentDirectory (options.OutputIGDir.c_str());
|
chdir (options.OutputIGDir.c_str());
|
||||||
SaveInstanceGroup (vAllFiles[i].c_str(), pIGout);
|
SaveInstanceGroup (vAllFiles[i].c_str(), pIGout);
|
||||||
SetCurrentDirectory (sCurDir);
|
chdir (sCurDir);
|
||||||
delete pIG;
|
delete pIG;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue