]> git.cworth.org Git - apitrace/blobdiff - common/os_posix.cpp
cli: Fix typo in earlier commit.
[apitrace] / common / os_posix.cpp
index 0d93b31bcafa6e56604fa639a7656d20128835ca..7ddd89530f4883fda0efc85fdac69e4e4df67c4d 100644 (file)
@@ -111,6 +111,12 @@ getCurrentDir(void)
     return path;
 }
 
+bool
+createDirectory(const String &path)
+{
+    return mkdir(path, 0777) == 0;
+}
+
 bool
 String::exists(void) const
 {
@@ -122,9 +128,6 @@ String::exists(void) const
         return false;
     }
 
-    if (!S_ISREG(st.st_mode))
-        return false;
-
     return true;
 }
 
@@ -173,7 +176,16 @@ log(const char *format, ...)
 #ifdef ANDROID
     __android_log_vprint(ANDROID_LOG_DEBUG, "apitrace", format, ap);
 #else
-    vfprintf(stderr, format, ap);
+    static FILE *log = NULL;
+    if (!log) {
+        // Duplicate stderr file descriptor, to prevent applications from
+        // redirecting our debug messages to somewhere else.
+        //
+        // Another alternative would be to log to /dev/tty when available.
+        log = fdopen(dup(STDERR_FILENO), "at");
+    }
+    vfprintf(log, format, ap);
+    fflush(log);
 #endif
     va_end(ap);
     logging = false;
@@ -186,7 +198,7 @@ long long timeFrequency = 0LL;
 void
 abort(void)
 {
-    exit(0);
+    _exit(1);
 }