{"action":"created","comment":{"url":"https://api.github.com/repos/libuv/libuv/pulls/comments/48823033","id":48823033,"diff_hunk":"@@ -1102,3 +1102,53 @@ int uv_os_homedir(char* buffer, size_t* size) {\n \n   return 0;\n }\n+\n+\n+int uv_os_tmpdir(char* buffer, size_t* size) {\n+  char* buf;\n+  size_t len;\n+\n+  if (buffer == NULL || size == NULL || *size == 0)\n+    return -EINVAL;\n+\n+  /* Check the TMPDIR, TMP, TEMP, and TEMPDIR environment variables in order */\n+  buf = getenv(\"TMPDIR\");\n+\n+  if (buf != NULL)\n+    goto return_buffer;\n+\n+  buf = getenv(\"TMP\");\n+\n+  if (buf != NULL)\n+    goto return_buffer;\n+\n+  buf = getenv(\"TEMP\");\n+\n+  if (buf != NULL)\n+    goto return_buffer;\n+\n+  buf = getenv(\"TEMPDIR\");\n+\n+  if (buf != NULL)\n+    goto return_buffer;\n+\n+  /* No temp environment variables defined */\n+  #if defined(__ANDROID__)\n+    buf = \"/data/local/tmp\";\n+  #else\n+    buf = \"/tmp\";\n+  #endif\n+\n+return_buffer:\n+  len = strlen(buf);\n+\n+  if (len >= *size) {\n+    *size = len;\n+    return -ENOBUFS;\n+  }\n+\n+  memcpy(buffer, buf, len + 1);","path":"src/unix/core.c","position":49,"original_position":49,"commit_id":"cd5d309506f86fee174fa4a9f49961e739772ca2","original_commit_id":"cd5d309506f86fee174fa4a9f49961e739772ca2","user":{"login":"saghul","id":317464,"avatar_url":"https://avatars.githubusercontent.com/u/317464?v=3","gravatar_id":"","url":"https://api.github.com/users/saghul","html_url":"https://github.com/saghul","followers_url":"https://api.github.com/users/saghul/followers","following_url":"https://api.github.com/users/saghul/following{/other_user}","gists_url":"https://api.github.com/users/saghul/gists{/gist_id}","starred_url":"https://api.github.com/users/saghul/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/saghul/subscriptions","organizations_url":"https://api.github.com/users/saghul/orgs","repos_url":"https://api.github.com/users/saghul/repos","events_url":"https://api.github.com/users/saghul/events{/privacy}","received_events_url":"https://api.github.com/users/saghul/received_events","type":"User","site_admin":false},"body":"Other functions returning path and size don't NULL terminate, let's be consistent.","created_at":"2016-01-05T08:49:48Z","updated_at":"2016-01-05T08:49:48Z","html_url":"https://github.com/libuv/libuv/pull/672#discussion_r48823033","pull_request_url":"https://api.github.com/repos/libuv/libuv/pulls/672","_links":{"self":{"href":"https://api.github.com/repos/libuv/libuv/pulls/comments/48823033"},"html":{"href":"https://github.com/libuv/libuv/pull/672#discussion_r48823033"},"pull_request":{"href":"https://api.github.com/repos/libuv/libuv/pulls/672"}}},"pull_request":{"url":"https://api.github.com/repos/libuv/libuv/pulls/672","id":55030267,"html_url":"https://github.com/libuv/libuv/pull/672","diff_url":"https://github.com/libuv/libuv/pull/672.diff","patch_url":"https://github.com/libuv/libuv/pull/672.patch","issue_url":"https://api.github.com/repos/libuv/libuv/issues/672","number":672,"state":"open","locked":false,"title":"WIP unix,win: add uv_os_tmpdir()","user":{"login":"cjihrig","id":2512748,"avatar_url":"https://avatars.githubusercontent.com/u/2512748?v=3","gravatar_id":"","url":"https://api.github.com/users/cjihrig","html_url":"https://github.com/cjihrig","followers_url":"https://api.github.com/users/cjihrig/followers","following_url":"https://api.github.com/users/cjihrig/following{/other_user}","gists_url":"https://api.github.com/users/cjihrig/gists{/gist_id}","starred_url":"https://api.github.com/users/cjihrig/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cjihrig/subscriptions","organizations_url":"https://api.github.com/users/cjihrig/orgs","repos_url":"https://api.github.com/users/cjihrig/repos","events_url":"https://api.github.com/users/cjihrig/events{/privacy}","received_events_url":"https://api.github.com/users/cjihrig/received_events","type":"User","site_admin":false},"body":"This is an initial attempt at a `uv_os_tmpdir()` function (see https://github.com/nodejs/node/issues/4239 for background). I borrowed the approach from [Boost](http://www.boost.org/doc/libs/1_60_0/libs/filesystem/doc/reference.html#temp_directory_path).\r\n\r\nStill outstanding:\r\n- Needs docs\r\n- Needs Windows implementation (plan on using [`GetTempPathW()`](https://msdn.microsoft.com/en-us/library/windows/desktop/aa364992(v=vs.85).aspx))","created_at":"2016-01-04T22:21:46Z","updated_at":"2016-01-05T08:49:48Z","closed_at":null,"merged_at":null,"merge_commit_sha":"5ea696cb7ae58cd3ec99a2311713a14eb78a4b28","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/libuv/libuv/pulls/672/commits","review_comments_url":"https://api.github.com/repos/libuv/libuv/pulls/672/comments","review_comment_url":"https://api.github.com/repos/libuv/libuv/pulls/comments{/number}","comments_url":"https://api.github.com/repos/libuv/libuv/issues/672/comments","statuses_url":"https://api.github.com/repos/libuv/libuv/statuses/cd5d309506f86fee174fa4a9f49961e739772ca2","head":{"label":"cjihrig:tmpdir","ref":"tmpdir","sha":"cd5d309506f86fee174fa4a9f49961e739772ca2","user":{"login":"cjihrig","id":2512748,"avatar_url":"https://avatars.githubusercontent.com/u/2512748?v=3","gravatar_id":"","url":"https://api.github.com/users/cjihrig","html_url":"https://github.com/cjihrig","followers_url":"https://api.github.com/users/cjihrig/followers","following_url":"https://api.github.com/users/cjihrig/following{/other_user}","gists_url":"https://api.github.com/users/cjihrig/gists{/gist_id}","starred_url":"https://api.github.com/users/cjihrig/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cjihrig/subscriptions","organizations_url":"https://api.github.com/users/cjihrig/orgs","repos_url":"https://api.github.com/users/cjihrig/repos","events_url":"https://api.github.com/users/cjihrig/events{/privacy}","received_events_url":"https://api.github.com/users/cjihrig/received_events","type":"User","site_admin":false},"repo":{"id":30379631,"name":"libuv","full_name":"cjihrig/libuv","owner":{"login":"cjihrig","id":2512748,"avatar_url":"https://avatars.githubusercontent.com/u/2512748?v=3","gravatar_id":"","url":"https://api.github.com/users/cjihrig","html_url":"https://github.com/cjihrig","followers_url":"https://api.github.com/users/cjihrig/followers","following_url":"https://api.github.com/users/cjihrig/following{/other_user}","gists_url":"https://api.github.com/users/cjihrig/gists{/gist_id}","starred_url":"https://api.github.com/users/cjihrig/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cjihrig/subscriptions","organizations_url":"https://api.github.com/users/cjihrig/orgs","repos_url":"https://api.github.com/users/cjihrig/repos","events_url":"https://api.github.com/users/cjihrig/events{/privacy}","received_events_url":"https://api.github.com/users/cjihrig/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/cjihrig/libuv","description":"Cross-platform asychronous I/O","fork":true,"url":"https://api.github.com/repos/cjihrig/libuv","forks_url":"https://api.github.com/repos/cjihrig/libuv/forks","keys_url":"https://api.github.com/repos/cjihrig/libuv/keys{/key_id}","collaborators_url":"https://api.github.com/repos/cjihrig/libuv/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/cjihrig/libuv/teams","hooks_url":"https://api.github.com/repos/cjihrig/libuv/hooks","issue_events_url":"https://api.github.com/repos/cjihrig/libuv/issues/events{/number}","events_url":"https://api.github.com/repos/cjihrig/libuv/events","assignees_url":"https://api.github.com/repos/cjihrig/libuv/assignees{/user}","branches_url":"https://api.github.com/repos/cjihrig/libuv/branches{/branch}","tags_url":"https://api.github.com/repos/cjihrig/libuv/tags","blobs_url":"https://api.github.com/repos/cjihrig/libuv/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/cjihrig/libuv/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/cjihrig/libuv/git/refs{/sha}","trees_url":"https://api.github.com/repos/cjihrig/libuv/git/trees{/sha}","statuses_url":"https://api.github.com/repos/cjihrig/libuv/statuses/{sha}","languages_url":"https://api.github.com/repos/cjihrig/libuv/languages","stargazers_url":"https://api.github.com/repos/cjihrig/libuv/stargazers","contributors_url":"https://api.github.com/repos/cjihrig/libuv/contributors","subscribers_url":"https://api.github.com/repos/cjihrig/libuv/subscribers","subscription_url":"https://api.github.com/repos/cjihrig/libuv/subscription","commits_url":"https://api.github.com/repos/cjihrig/libuv/commits{/sha}","git_commits_url":"https://api.github.com/repos/cjihrig/libuv/git/commits{/sha}","comments_url":"https://api.github.com/repos/cjihrig/libuv/comments{/number}","issue_comment_url":"https://api.github.com/repos/cjihrig/libuv/issues/comments{/number}","contents_url":"https://api.github.com/repos/cjihrig/libuv/contents/{+path}","compare_url":"https://api.github.com/repos/cjihrig/libuv/compare/{base}...{head}","merges_url":"https://api.github.com/repos/cjihrig/libuv/merges","archive_url":"https://api.github.com/repos/cjihrig/libuv/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/cjihrig/libuv/downloads","issues_url":"https://api.github.com/repos/cjihrig/libuv/issues{/number}","pulls_url":"https://api.github.com/repos/cjihrig/libuv/pulls{/number}","milestones_url":"https://api.github.com/repos/cjihrig/libuv/milestones{/number}","notifications_url":"https://api.github.com/repos/cjihrig/libuv/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/cjihrig/libuv/labels{/name}","releases_url":"https://api.github.com/repos/cjihrig/libuv/releases{/id}","created_at":"2015-02-05T21:34:22Z","updated_at":"2015-02-05T21:34:23Z","pushed_at":"2016-01-04T22:00:08Z","git_url":"git://github.com/cjihrig/libuv.git","ssh_url":"git@github.com:cjihrig/libuv.git","clone_url":"https://github.com/cjihrig/libuv.git","svn_url":"https://github.com/cjihrig/libuv","homepage":"http://libuv.org/","size":12105,"stargazers_count":0,"watchers_count":0,"language":"C","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"v1.x"}},"base":{"label":"libuv:v1.x","ref":"v1.x","sha":"a564ef09dc260240b001131b627b8bfc9b895b37","user":{"login":"libuv","id":4030929,"avatar_url":"https://avatars.githubusercontent.com/u/4030929?v=3","gravatar_id":"","url":"https://api.github.com/users/libuv","html_url":"https://github.com/libuv","followers_url":"https://api.github.com/users/libuv/followers","following_url":"https://api.github.com/users/libuv/following{/other_user}","gists_url":"https://api.github.com/users/libuv/gists{/gist_id}","starred_url":"https://api.github.com/users/libuv/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/libuv/subscriptions","organizations_url":"https://api.github.com/users/libuv/orgs","repos_url":"https://api.github.com/users/libuv/repos","events_url":"https://api.github.com/users/libuv/events{/privacy}","received_events_url":"https://api.github.com/users/libuv/received_events","type":"Organization","site_admin":false},"repo":{"id":14812739,"name":"libuv","full_name":"libuv/libuv","owner":{"login":"libuv","id":4030929,"avatar_url":"https://avatars.githubusercontent.com/u/4030929?v=3","gravatar_id":"","url":"https://api.github.com/users/libuv","html_url":"https://github.com/libuv","followers_url":"https://api.github.com/users/libuv/followers","following_url":"https://api.github.com/users/libuv/following{/other_user}","gists_url":"https://api.github.com/users/libuv/gists{/gist_id}","starred_url":"https://api.github.com/users/libuv/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/libuv/subscriptions","organizations_url":"https://api.github.com/users/libuv/orgs","repos_url":"https://api.github.com/users/libuv/repos","events_url":"https://api.github.com/users/libuv/events{/privacy}","received_events_url":"https://api.github.com/users/libuv/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/libuv/libuv","description":"Cross-platform asynchronous I/O","fork":false,"url":"https://api.github.com/repos/libuv/libuv","forks_url":"https://api.github.com/repos/libuv/libuv/forks","keys_url":"https://api.github.com/repos/libuv/libuv/keys{/key_id}","collaborators_url":"https://api.github.com/repos/libuv/libuv/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/libuv/libuv/teams","hooks_url":"https://api.github.com/repos/libuv/libuv/hooks","issue_events_url":"https://api.github.com/repos/libuv/libuv/issues/events{/number}","events_url":"https://api.github.com/repos/libuv/libuv/events","assignees_url":"https://api.github.com/repos/libuv/libuv/assignees{/user}","branches_url":"https://api.github.com/repos/libuv/libuv/branches{/branch}","tags_url":"https://api.github.com/repos/libuv/libuv/tags","blobs_url":"https://api.github.com/repos/libuv/libuv/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/libuv/libuv/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/libuv/libuv/git/refs{/sha}","trees_url":"https://api.github.com/repos/libuv/libuv/git/trees{/sha}","statuses_url":"https://api.github.com/repos/libuv/libuv/statuses/{sha}","languages_url":"https://api.github.com/repos/libuv/libuv/languages","stargazers_url":"https://api.github.com/repos/libuv/libuv/stargazers","contributors_url":"https://api.github.com/repos/libuv/libuv/contributors","subscribers_url":"https://api.github.com/repos/libuv/libuv/subscribers","subscription_url":"https://api.github.com/repos/libuv/libuv/subscription","commits_url":"https://api.github.com/repos/libuv/libuv/commits{/sha}","git_commits_url":"https://api.github.com/repos/libuv/libuv/git/commits{/sha}","comments_url":"https://api.github.com/repos/libuv/libuv/comments{/number}","issue_comment_url":"https://api.github.com/repos/libuv/libuv/issues/comments{/number}","contents_url":"https://api.github.com/repos/libuv/libuv/contents/{+path}","compare_url":"https://api.github.com/repos/libuv/libuv/compare/{base}...{head}","merges_url":"https://api.github.com/repos/libuv/libuv/merges","archive_url":"https://api.github.com/repos/libuv/libuv/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/libuv/libuv/downloads","issues_url":"https://api.github.com/repos/libuv/libuv/issues{/number}","pulls_url":"https://api.github.com/repos/libuv/libuv/pulls{/number}","milestones_url":"https://api.github.com/repos/libuv/libuv/milestones{/number}","notifications_url":"https://api.github.com/repos/libuv/libuv/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/libuv/libuv/labels{/name}","releases_url":"https://api.github.com/repos/libuv/libuv/releases{/id}","created_at":"2013-11-30T00:29:56Z","updated_at":"2016-01-05T08:26:35Z","pushed_at":"2016-01-05T08:15:35Z","git_url":"git://github.com/libuv/libuv.git","ssh_url":"git@github.com:libuv/libuv.git","clone_url":"https://github.com/libuv/libuv.git","svn_url":"https://github.com/libuv/libuv","homepage":"http://libuv.org/","size":13274,"stargazers_count":2997,"watchers_count":2997,"language":"C","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":445,"mirror_url":null,"open_issues_count":90,"forks":445,"open_issues":90,"watchers":2997,"default_branch":"v1.x"}},"_links":{"self":{"href":"https://api.github.com/repos/libuv/libuv/pulls/672"},"html":{"href":"https://github.com/libuv/libuv/pull/672"},"issue":{"href":"https://api.github.com/repos/libuv/libuv/issues/672"},"comments":{"href":"https://api.github.com/repos/libuv/libuv/issues/672/comments"},"review_comments":{"href":"https://api.github.com/repos/libuv/libuv/pulls/672/comments"},"review_comment":{"href":"https://api.github.com/repos/libuv/libuv/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/libuv/libuv/pulls/672/commits"},"statuses":{"href":"https://api.github.com/repos/libuv/libuv/statuses/cd5d309506f86fee174fa4a9f49961e739772ca2"}}}}