Thread overview | |||||
---|---|---|---|---|---|
|
June 12, 2011 How do I truncate a file, delete bytes, or set the end of file from a stream? | ||||
---|---|---|---|---|
| ||||
How do I truncate a file, delete bytes, or set the end of file from a stream? For example, what would be the easiest way to delete the last 4 bytes from a file? |
June 15, 2011 Re: How do I truncate a file, delete bytes, or set the end of file from a stream? | ||||
---|---|---|---|---|
| ||||
Posted in reply to XP1 | On Sun, 12 Jun 2011 02:47:01 -0400, XP1 <nospam@nospam.com> wrote:
>
> How do I truncate a file, delete bytes, or set the end of file from a stream?
>
> For example, what would be the easiest way to delete the last 4 bytes from a file?
Anyone?
|
June 15, 2011 Re: How do I truncate a file, delete bytes, or set the end of file from a stream? | ||||
---|---|---|---|---|
| ||||
Posted in reply to XP1 | On Wed, 15 Jun 2011 13:30:25 -0400, XP1 <nospam@nospam.com> wrote: > On Sun, 12 Jun 2011 02:47:01 -0400, XP1 <nospam@nospam.com> wrote: > >> >> How do I truncate a file, delete bytes, or set the end of file from a stream? >> >> For example, what would be the easiest way to delete the last 4 bytes from a file? > > Anyone? If you are on linux, ftruncate(int fd, size_t size); http://linux.die.net/man/2/truncate If you are on Windows, _chsize(int handle, int size); http://www.digitalmars.com/rtl/io.html#_chsize Don't know about MacOS or BSD, they probably follow the linux function. -Steve |
Copyright © 1999-2021 by the D Language Foundation