X-Git-Url: http://winboard.nl/cgi-bin?a=blobdiff_plain;f=util.c;h=a5af1173347ebdb6e4876aa73308250057b7e010;hb=cd81270f2b1723e0798f4d6dcaee134f0b4aca7f;hp=0d75adfa88939dfcb2edc7f07c53ebaace3d24b5;hpb=a0f731f21d6aa26dbf7246039a1c66c2ade0533f;p=polyglot.git diff --git a/util.c b/util.c index 0d75adf..a5af117 100644 --- a/util.c +++ b/util.c @@ -18,11 +18,17 @@ #include #include #include +#ifndef _MSC_VER #include +#endif #include "main.h" #include "util.h" +// macros + +#define StringSize 4096 + // variables static bool Error; @@ -187,8 +193,8 @@ void my_fatal(const char format[], ...) { CONSTRUCT_ARG_STRING(format,string); - fprintf(stderr,format,string); - if (LogFile != NULL) fprintf(LogFile,format,&string); + fprintf(stderr,"%s",string); + my_log("POLYGLOT %s",string); if (Error) { // recursive error my_log("POLYGLOT *** RECURSIVE ERROR ***\n"); @@ -233,6 +239,32 @@ bool my_file_read_line(FILE * file, char string[], int size) { return TRUE; } +// my_file_join() + +void my_path_join(char *join_path, const char *path, const char *file){ + char separator; +#ifdef _WIN32 + separator='\\'; +#else + separator='/'; +#endif + snprintf(join_path,StringSize,"%s%c%s",path,separator,file); + join_path[StringSize-1]='\0'; +} + +// my_mkdir() + +int my_mkdir(const char *path){ + int ret; +#ifdef _WIN32 + ret=_mkdir(path); +#else + ret=mkdir(path,S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH); +#endif + return ret; +} + + // my_string_empty() bool my_string_empty(const char string[]) { @@ -337,7 +369,10 @@ double now_real() { return tv->tv_sec + tv->tv_usec * 1E-6; #else - return (double) GetTickCount() / 1000.0; // we can do better here:-) + struct _timeb timeptr; + _ftime(&timeptr); + return(timeptr.time+((double)timeptr.millitm)/1000.0); +// return (double) GetTickCount() / 1000.0; // we can do better here:-) #endif }