Talk:Truncate a file: Difference between revisions

→‎Assumes unix: truncation and Win32.
(Why is a rename required in Microsoft Windows?)
(→‎Assumes unix: truncation and Win32.)
Line 23:
:::Yeah, I would have expected a beforehand check here. However, for the purpose of this task, the truncation is the bit that I hoping to see demonstrated here, rather than determining the filesize. I don't have any objection to extending the file, if that is easier than bailing out. It would be nice to get a warning message that the file has been padded, or maybe we could just place a note against a the solution that the file gets padded, if the provided length is greater than the current length of the file. [[User:Markhobley|Markhobley]] 19:20, 19 July 2011 (UTC)
:::I don't know Microsoft Windows. If it supports truncation, then why is a rename required? Does the truncated file become disassociated with the original filename or something? Presumably, it is not just a simple open,truncate,close sequence involved here. [[User:Markhobley|Markhobley]] 19:38, 19 July 2011 (UTC)
::::Yes, truncation is supported in the Win32 API. At issue, I thought, was the general compatibility of the rename step. I'd probably recommend leaving the temp-and-rename workaround out of it, if it's strictly truncation that's of interest. Or leave off the requirement of atomicity. Or assume that an delete step on the original file is allowed, if necessary. --[[User:Short Circuit|Michael Mol]] 20:44, 19 July 2011 (UTC)