• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

DeleteFile and unlink failing

glugglug

Diamond Member
I have a sort which creates some temp files if you're sorting too much to fit in RAM.

The temp files are managed with the following API sequence:

_hFile = CreateFile(filename.c_str(),GENERIC_READ|GENERIC_WRITE,FILE_SHARE_READ|FILE_SHARE_WRITE,NULL,CREATE_NEW,0,NULL);
_hMapping = CreateFileMapping(_hFile,NULL,PAGE_READWRITE|SEC_COMMIT,0,_filesize,NULL);
_currentView = (char *)MapViewOfFile(_hMapping,FILE_MAP_ALL_ACCESS,0,0,_desiredViewSize);

UnmapViewOfFile and MapViewOfFile are then called a number of times (always paired) when moving the view through the file or resizing it so that all views fit in memory and the process doesn't run into the 2GB limit.

Then when the file is done with:

UnmapViewOfFile(_currentView);
CloseHandle(_hMapping);
CloseHandle(_hFile);

DeleteFile and unlink are not working after the file is closed. How is the file being left open here?
 
Back
Top