ext_etc_etc.c.diff   [plain text]


--- ext/etc/etc.c~	2013-10-29 16:23:03.000000000 -0700
+++ ext/etc/etc.c	2013-10-29 16:27:08.000000000 -0700
@@ -622,7 +622,18 @@ etc_systmpdir(void)
     if (!len) return Qnil;
     tmpdir = rb_w32_conv_from_wchar(path, rb_filesystem_encoding());
 #else
-    tmpdir = rb_filesystem_str_new_cstr("/tmp");
+    #ifndef MAXPATHLEN
+    #define MAXPATHLEN 1024
+    #endif
+    char path[MAXPATHLEN];
+    size_t len = 0;
+
+    len = confstr(_CS_DARWIN_USER_TEMP_DIR, path, sizeof(path));
+    if (len > 0) {
+	    tmpdir = rb_filesystem_str_new_cstr(path);
+    } else {
+	    tmpdir = rb_filesystem_str_new_cstr("/tmp");
+    }
 #endif
     FL_UNSET(tmpdir, FL_TAINT|FL_UNTRUSTED);
     return tmpdir;