Get the latest tech news

Strange File Resizing on DOS


meone recently asked an interesting question: Why do Microsoft C and compatible DOS compilers have no truncate() and/or ftruncate() library functions? And how does one resize files on DOS? OK, that’s actually two questions. The first one is easy enough to answer: Because XENIX had no truncate() or ftruncate() either.

Someone recently asked an interesting question: Why do Microsoft C and compatible DOS compilers have no truncate() and/or ftruncate() library functions? Now, this mechanism is rather curious, because the handle-based file API in DOS 2.0 was modeled on XENIX, yet on UNIX systems, the write() function asked to transfer zero bytes simply does nothing. It is thus clear that the DOS method of resizing files through zero-length writes originated in 86-DOS in 1980, and it is more or less guaranteed to be Tim Paterson’s invention.

Get the Android app

Or read this on Hacker News

Read more on:

Photo of DOS

DOS

Related news:

News photo

DOS game “F-15 Strike Eagle II” reverse engineering/reconstruction war stories

News photo

Microsoft Open-Sources MS-DOS 4.0 Under MIT License

News photo

German Railway Company Is Looking For MS-DOS and Windows 3.11 Admin