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@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;
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