[GRASS-dev] access()/fopen() was: Re: [GRASS-CVS] brad: grass6/lib/gis error.c,1.9,1.10

Brad Douglas rez at touchofmadness.com
Mon Jun 19 04:07:01 EDT 2006


On Mon, 2006-06-19 at 02:27 -0500, Huidae Cho wrote:
> 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.

Correct.  That's why I use fopen(, "r") and check the return value when
checking file existence.  Did I forget to replace access() with that?
Oops.  I did.  Thanks for catching and correcting that.

> 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.

Removing calls to access() is one of those ongoing, low priority
projects.  There's nothing specifically wrong with it, but why use
POSIX.1 when ANSI C will do?  ANSI C is more portable than POSIX.1, but
POSIX.1 unavoidable in certain situations (eg. >2G files).

It isn't a "dirty hack".  It's minimalism.


-- 
Brad Douglas <rez touchofmadness com>                      KB8UYR
Address: 37.493,-121.924 / WGS84    National Map Corps #TNMC-3785




More information about the grass-dev mailing list