{"action":"created","issue":{"url":"https://api.github.com/repos/manastech/crystal/issues/1549","labels_url":"https://api.github.com/repos/manastech/crystal/issues/1549/labels{/name}","comments_url":"https://api.github.com/repos/manastech/crystal/issues/1549/comments","events_url":"https://api.github.com/repos/manastech/crystal/issues/1549/events","html_url":"https://github.com/manastech/crystal/pull/1549","id":107606156,"number":1549,"title":"File#truncate","user":{"login":"porras","id":3830,"avatar_url":"https://avatars.githubusercontent.com/u/3830?v=3","gravatar_id":"","url":"https://api.github.com/users/porras","html_url":"https://github.com/porras","followers_url":"https://api.github.com/users/porras/followers","following_url":"https://api.github.com/users/porras/following{/other_user}","gists_url":"https://api.github.com/users/porras/gists{/gist_id}","starred_url":"https://api.github.com/users/porras/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/porras/subscriptions","organizations_url":"https://api.github.com/users/porras/orgs","repos_url":"https://api.github.com/users/porras/repos","events_url":"https://api.github.com/users/porras/events{/privacy}","received_events_url":"https://api.github.com/users/porras/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":6,"created_at":"2015-09-21T21:51:01Z","updated_at":"2015-10-01T13:18:28Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/manastech/crystal/pulls/1549","html_url":"https://github.com/manastech/crystal/pull/1549","diff_url":"https://github.com/manastech/crystal/pull/1549.diff","patch_url":"https://github.com/manastech/crystal/pull/1549.patch"},"body":"This PR implements `File#truncate`, a direct mapping to the `ftruncate` system call, and equivalent to [Ruby's method](http://www.rubydoc.info/stdlib/core/File#truncate-instance_method). The spec shows a use case that comes to mind: opening a file with `r+`, reading it complete, and then overwriting it completely (if the new content is shorter than the old, we need to truncate)."},"comment":{"url":"https://api.github.com/repos/manastech/crystal/issues/comments/144723626","html_url":"https://github.com/manastech/crystal/pull/1549#issuecomment-144723626","issue_url":"https://api.github.com/repos/manastech/crystal/issues/1549","id":144723626,"user":{"login":"porras","id":3830,"avatar_url":"https://avatars.githubusercontent.com/u/3830?v=3","gravatar_id":"","url":"https://api.github.com/users/porras","html_url":"https://github.com/porras","followers_url":"https://api.github.com/users/porras/followers","following_url":"https://api.github.com/users/porras/following{/other_user}","gists_url":"https://api.github.com/users/porras/gists{/gist_id}","starred_url":"https://api.github.com/users/porras/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/porras/subscriptions","organizations_url":"https://api.github.com/users/porras/orgs","repos_url":"https://api.github.com/users/porras/repos","events_url":"https://api.github.com/users/porras/events{/privacy}","received_events_url":"https://api.github.com/users/porras/received_events","type":"User","site_admin":false},"created_at":"2015-10-01T13:18:28Z","updated_at":"2015-10-01T13:18:28Z","body":"Hey, sorry for the slow follow up, travel + illness got me away from computers :D\r\n\r\nI've added the suggested default (completely truncate the file). I also added a call to `#flush` to avoid the problem where some write would be pending, we truncate the file and then the pending write is done (there's a test checking exactly that).\r\n\r\nI also rebased all commits into one, on top of current master."}}