Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » U++ Core » Latest change on FileMapping::Map() wrong for win32
Re: Latest change on FileMapping::Map() wrong for win32 [message #23423 is a reply to message #23384] Sun, 18 October 2009 21:25 Go to previous messageGo to previous message
mirek is currently offline  mirek
Messages: 14256
Registered: November 2005
Ultimate Member
Thank you. I have changed to code, please check:

bool FileMapping::Map(int64 mapoffset, dword maplen)
{
	ASSERT(IsOpen());
	if(maplen == 0)
		return Unmap();
	mapoffset = minmax<int64>(mapoffset, 0, filesize);
	int gran = sMappingGranularity_();
	int64 rawoff = mapoffset & -gran;
	maplen = (dword)min<int64>(maplen, filesize - mapoffset);
	dword rawsz = (dword)min<int64>((maplen + (dword)(mapoffset - rawoff) + gran - 1) & -gran, filesize - rawoff);
	if(rawbase && (mapoffset < rawoffset || mapoffset + maplen > rawoffset + rawsize))
		Unmap();
	if(!rawbase) {
		rawoffset = rawoff;
		rawsize = rawsz;
#ifdef PLATFORM_WIN32
		rawbase = (byte *)MapViewOfFile(hmap, /*write ? FILE_MAP_WRITE :*/ FILE_MAP_READ,
			(dword)(rawoffset >> 32), (dword)(rawoffset >> 0), rawsize);
#else
		rawbase = (byte *)mmap(0, rawsize,
			PROT_READ | (write ? PROT_WRITE : 0),
#ifdef PLATFORM_FREEBSD
			MAP_NOSYNC,
#else
			MAP_SHARED,
#endif
			hfile, (dword)rawoffset);
#endif
#ifdef PLATFORM_POSIX
		if(rawbase == (byte *)~0)
#else
		if(!rawbase)
#endif
			return false;
	}
	offset = mapoffset;
	size = maplen;
	base = rawbase + (int)(offset - rawoffset);
	return true;
}
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Deepcopying One container
Next Topic: FtpClient use with Progress FIX
Goto Forum:
  


Current Time: Wed Apr 30 14:50:22 CEST 2025

Total time taken to generate the page: 0.03550 seconds