{"action":"created","issue":{"url":"https://api.github.com/repos/nodejs/node/issues/3163","labels_url":"https://api.github.com/repos/nodejs/node/issues/3163/labels{/name}","comments_url":"https://api.github.com/repos/nodejs/node/issues/3163/comments","events_url":"https://api.github.com/repos/nodejs/node/issues/3163/events","html_url":"https://github.com/nodejs/node/pull/3163","id":109593436,"number":3163,"title":"fs: Add file descriptor support to *File() funcs","user":{"login":"jwueller","id":388308,"avatar_url":"https://avatars.githubusercontent.com/u/388308?v=3","gravatar_id":"","url":"https://api.github.com/users/jwueller","html_url":"https://github.com/jwueller","followers_url":"https://api.github.com/users/jwueller/followers","following_url":"https://api.github.com/users/jwueller/following{/other_user}","gists_url":"https://api.github.com/users/jwueller/gists{/gist_id}","starred_url":"https://api.github.com/users/jwueller/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jwueller/subscriptions","organizations_url":"https://api.github.com/users/jwueller/orgs","repos_url":"https://api.github.com/users/jwueller/repos","events_url":"https://api.github.com/users/jwueller/events{/privacy}","received_events_url":"https://api.github.com/users/jwueller/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/nodejs/node/labels/fs","name":"fs","color":"0052cc"},{"url":"https://api.github.com/repos/nodejs/node/labels/semver-minor","name":"semver-minor","color":"fef2c0"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-10-03T00:28:43Z","updated_at":"2015-10-04T06:58:54Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/nodejs/node/pulls/3163","html_url":"https://github.com/nodejs/node/pull/3163","diff_url":"https://github.com/nodejs/node/pull/3163.diff","patch_url":"https://github.com/nodejs/node/pull/3163.patch"},"body":"This is a re-targeted submission of [the archived PR #8522](/nodejs/node-v0.x-archive/pull/8522), implementing [the archived issue #8471](/nodejs/node-v0.x-archive/issues/8471).\r\n\r\nThe original description follows.\r\n\r\n---\r\n\r\nThese changes affect the following functions and their synchronous counterparts:\r\n\r\n * `fs.readFile()`\r\n * `fs.writeFile()`\r\n * `fs.appendFile()`\r\n\r\nIf the first parameter is a uint >= 0, it is treated as a file descriptor. In all other cases, the original implementation is used to ensure backwards compatibility. File descriptor ownership is never taken from the user.\r\n\r\nThe documentation was adjusted to reflect these API changes. A note was added to make the user aware of file descriptor ownership and the conditions under which a file descriptor can be used by each of these functions.\r\n\r\nTests were extended to test for file descriptor parameters under the conditions noted in the relevant documentation."},"comment":{"url":"https://api.github.com/repos/nodejs/node/issues/comments/145323530","html_url":"https://github.com/nodejs/node/pull/3163#issuecomment-145323530","issue_url":"https://api.github.com/repos/nodejs/node/issues/3163","id":145323530,"user":{"login":"ChALkeR","id":291301,"avatar_url":"https://avatars.githubusercontent.com/u/291301?v=3","gravatar_id":"","url":"https://api.github.com/users/ChALkeR","html_url":"https://github.com/ChALkeR","followers_url":"https://api.github.com/users/ChALkeR/followers","following_url":"https://api.github.com/users/ChALkeR/following{/other_user}","gists_url":"https://api.github.com/users/ChALkeR/gists{/gist_id}","starred_url":"https://api.github.com/users/ChALkeR/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ChALkeR/subscriptions","organizations_url":"https://api.github.com/users/ChALkeR/orgs","repos_url":"https://api.github.com/users/ChALkeR/repos","events_url":"https://api.github.com/users/ChALkeR/events{/privacy}","received_events_url":"https://api.github.com/users/ChALkeR/received_events","type":"User","site_admin":false},"created_at":"2015-10-04T06:58:54Z","updated_at":"2015-10-04T06:58:54Z","body":"This is at least `semver-minor`, but actually looks more like a `semver-major` to me.\r\nWhat if someone has done something like\r\n```javascript\r\nvar num = 1;\r\n…\r\nfs.writeFile(num++, …);\r\n```\r\n\r\nAlso, the logic is not very clear:\r\n 1. `fs.writeFile(1,…)` tries to write to file descriptor `1`.\r\n 2. `fs.writeFile(-1,…)` tries to write to file name `'-1'`.\r\n 3. `fs.writeFile(4294967295,…)` tries to write to file descriptor `4294967295`.\r\n 4. `fs.writeFile(4294967296,…)` tries to write to file name `'4294967296'`.\r\n\r\nUnderstandable behavior IMO would be to check if the file name is a string, and if it's not a string nor a valid file descriptor — throw an `Error`. But that change would be clearly a `semver-major`.\r\n\r\nNot sure what the others think."}}