[GRASS-dev] Re: [GRASS-CVS] brad: grass6/lib/gis error.c,1.9,1.10

Huidae Cho grass4u at gmail.com
Mon Jun 19 03:27:14 EDT 2006


Since fopen(, "a") creates a file when it does not exist, we need to check if
the log file exists.  Otherwise, ($HOME|$GISBASE)/GIS_ERROR_LOG file will be
created whether the user wants or not.

I don't know much about portability, but can we really avoid using access()
function?  I replaced access() with freopen/fopen calls, which is a dirty hack.
Actually, I found many access() calls here and there, so I'd like to ask
experts in code portability what's wrong with access() call here.

Thanks.
Huidae Cho


On Tue, Jun 06, 2006 at 03:17:53AM +0200, grass at intevation.de wrote:
> Author: brad
> 
> Update of /grassrepository/grass6/lib/gis
> In directory doto:/tmp/cvs-serv1322
> 
> Modified Files:
> 	error.c 
> Log Message:
> - proper usage of time()
> - removed access() call - portability reasons (fopen() is sufficient)
> - made local function params 'const' where applicable
> 
> 

...

>  
> -/* logfile must exist and be writeable */
> -    if (access (logfile, 0) != 0)
> -	return 1;
> -
>      log = fopen (logfile,"a");
>      if (!log)
>  	return 1;




More information about the grass-dev mailing list