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