Talk:Truncate a file: Difference between revisions

The task is not limited to Unix
(→‎Assumes unix: Transactions)
(The task is not limited to Unix)
Line 10:
::: I see, you are talking about the rename part. Truncating a file on windows works not very differently from unix. But it's true that unlike on unix where filename is just a link pointing to some inode, windows files are closely tied to the names, fair point. --[[User:Ledrug|Ledrug]] 14:55, 19 July 2011 (UTC)
::: Just an observation...I think the 'rename' bit is to guarantee an atomic replacement in the namespace. NTFS supports transactions which would accomplish this, although it'd be necessary to catch a transaction failure and retry. Other Windows-supported filesystems may or may not support transactions or suitable semantics. (FAT certainly doesn't. I don't know what other filesystems Windows may have native support for.) --[[User:Short Circuit|Michael Mol]] 15:43, 19 July 2011 (UTC)
::::I wrote a DOS extension service that could truncate files by deleting the entries from the file allocation table and updating the directory entry with the new file size once. This was before Microsoft Windows '95 came along and broke everything. The restrictions on semantics are within Microsoft Windows itself, rather than with the filesystem, There may be an interface somewhere that allows truncation, because disk repair tools need to be able to do such things, although I know Microsoft like to retain a monopoly on such tools, so maybe they forgot to document the interface. [[User:Markhobley|Markhobley]] 17:11, 19 July 2011 (UTC)
 
:The task is not limited to Unix. It should be possible to truncate a file on most systems that utilize disks and other storage media type devices. [[User:Markhobley|Markhobley]] 17:11, 19 July 2011 (UTC)