[BUG] MapSplitter doesn't complain if OutDirectory invalid

Samir

13-11-2005 14:33:30

Hi,

If you run MapSplitter with an invalid OutDirectory parameter in *.gen.cfg, no error is output on the screen nor in the log file. For example, if MapSplitter was run from C:\ and OutDirectory=../media/map, the MapSplitter runs to completion and doesn't indicate any error so the outputted maps are simply lost. This is really annyoing since you won't find out that the maps are not there till you run the app and don't find the files you should have generated.

I think the problem is in file filutils.cpp in function ChangeToDir.

char * ChangeToDir (const char *Dirname)
{
STRUCT_STAT st;

if (STAT(Dirname, &st))
{
// doen't exist; must create it
MKDIR (Dirname);
}
if (S_ISDIR(st.st_mode) == 0)
{
// it's not a dir, must create a dir
MKDIR (Dirname);
}
char *oldDirname = GetCurrDir ();
CHDIR(Dirname);
return oldDirname;
}

MKDIR (or the function that the macro MKDIR maps to) returns and error code in case the path in not valid and I think you should check that value and return an error code (or throw an exeption) from ChangeToDir in such a case.

And then see where ChangeToDir is used (for example in file MapUtil.cpp in function MapUtil::processOneMap() ) and check for a zero pointer for example in case using error codes instead of exceptions.


char *olddir = ChangeToDir (const_cast< char * > (OutDirectory.c_str ()));
if(!olddir)
//Tell the user something is wrong.


It would even be better if in case of an invalid path, the program asks the user to enter another one. So you would change the value of OutDirectory and check it again. This way, we don't have to wait for the MapSplitter all over again.

tuan kuranes

14-11-2005 07:49:42

Agree, path existance should be checked.
I'll look after that.

User input isn't planned as mapsplitter code is also used in MapEditor gui which has it's own input.
You can make a specific Gui if you need this.

tuan kuranes

14-11-2005 10:32:49

fixed in CVS.
Shoud exit if directory cannot be created.

Samir

14-11-2005 13:28:01

cool...thanks :D ... I'll try it out when I have the chance.