The map file is successfully created, you have to implement the parallel access from other thread/process.
Yes, it works fine, so what I understood is that:
hFile := fpOpen(FileName, O_RDWR OR O_SYNC);
:opens a local file.
mMap := fpmmap(nil, Ms.Size, PROT_READ or PROT_WRITE, MAP_SHARED, hFile, 0);
:creates the map file.
well, thats is what the principal thread is supposed to do, in windows it's something like:
FHandle := CreateFile(PChar(FileName), FILE_READ_DATA or FILE_WRITE_DATA, 0, nil, CREATE_ALWAYS, 0, 0);
hMap := CreateFileMapping(FHandle, nil, PAGE_READWRITE, 0, 0, nil);
, where FHandle type is: hFile, and hMap type is THandle.
So you showed me how to create a map file using a local file. And know I have to implement this in Linux:
Http.Request.Range := Format('%d-%d',[View.Offset, View.Offset +View.Size -1]);
Data := MapViewOfFile(MapFile, FILE_MAP_WRITE, View.HiOffset, View.LoOffset, View.Size);
Http.Get(URL, Stream);
CopyMemory(Data, Stream.Memory, View.Size);
UnmapViewOfFile(Data);
And it's all about:
Data := MapViewOfFile(MapFile, FILE_MAP_WRITE, View.HiOffset, View.LoOffset, View.Size);
Now, it's getting clearer, about SIGSEG exception, I guess I figured things out, this exception is raised when DATA is not assigned, and it wasn't because of the value of 'fp'.
And, now I'm getting the same error when trying the code above on Windows.Of course the exception is relevant to:
Data := MapViewOfFile(MapFile, FILE_MAP_WRITE, View.HiOffset, View.LoOffset, View.Size);
But I can't figure things out. If you'd like to help, I'll post the code.