🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: borland.public.cppbuilder.nativeapi
2 messages
2 total messages Started by Totte Karlsson Sat, 19 Apr 2008 01:40
Memory mapped file question
#388
Author: Totte Karlsson
Date: Sat, 19 Apr 2008 01:40
15 lines
1396 bytes
Hi,
I'm planning on using memory mapped files to write data to a file. The files can 
be of any size between 0 bytes to to 2GB (not larger).

My "problem" is, when I open the memory mapped file, I don't know how big it 
will be, i.e. h ow many bytes that I will write to it. And it seems that memory 
mapped files can't grow easily. So I thought I would open each file as 2 GB 
large initially and then, when I have written my bytes, say 1.38 GB, I would 
truncate the rest of the file.

Is that possible/feasible? Any simple answer on how to remove x bytes in a file 
from the end of file?

regards
-totte
Re: Memory mapped file question
#389
Author: Bob Gonder
Date: Sat, 19 Apr 2008 18:54
10 lines
1187 bytes
Totte Karlsson wrote:

>Is that possible/feasible? Any simple answer on how to remove x bytes in a file 
>from the end of file?

First set position to cutoff point.
	ret = SetFilePointer( h, offset, NULL, FILE_BEGIN );

Then Truncate it.
	ret = SetEndOfFile(h);
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads