🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.nativeapi
Article #1241

Truncate a file from the beginning to the current position

#1241
From: Mehmet Caner
Date: Wed, 17 Oct 2007 09:16
12 lines
1473 bytes
Using the code (Remy's code in the archive) below, I can truncate a file 
from the beginning to the current position. Can I do the same operation 
using Windows API?

TFileStream *OldFile = new TFileStream("c:\\oldfile.ext", fmOpenReadWrite | 
fmShareDenyWrite);
OldFile->Position = 100;

TFileStream *NewFile = new TFileStream("c:\\newfile.ext", fmCreate);
NewFile->CopyFrom(OldFile, OldFile->Size - OldFile->Position);

OldFile->Size = 100; // uses SetEndOfFile() internally
Technical Details
Message-ID: <4715d331@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news2.google.com!news2.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!nx02.iad01.newshosting.com!newshosting.com!203.109.252.33.MISMATCH!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,92368457f5454c39,start
X-Google-Attributes: gid10cc67,public,usenet
X-Google-Language: ENGLISH,ASCII-7-bit
Reply-To: "Mehmet Caner" <mcaner40@hotmail.com>
From: "Mehmet Caner" <mcaner40@hotmail.com>
Newsgroups: borland.public.cppbuilder.nativeapi
Subject: Truncate a file from the beginning to the current position
Date: Wed, 17 Oct 2007 12:16:32 +0300
Lines: 14
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2900.3028
X-RFC2646: Format=Flowed; Original
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.3028
NNTP-Posting-Host: 88.232.218.24
Message-ID: <4715d331@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1192612657 88.232.218.24 (17 Oct 2007 02:17:37 -0700)
Path: arc1-ca.pugleaf.net!g2news2.google.com!news2.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!nx02.iad01.newshosting.com!newshosting.com!203.109.252.33.MISMATCH!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail