procedure TFileMapStream_San.SetSize(NewSize: Integer);
var
n:pchar;
p1,p:cardinal;
begin
if (not autosize)and(not FInitializing) then
raise exception.Create(format(c_msg_cannotsetsize,[classname,'AutoSize']));
if newsize<0 then newsize:=0;
if (newsize=size) and (newsize<>0) then exit;
if fmapname='' then
n:=nil
else
n:=pchar(fmapname);
p:=0;
p1:=0;
if fprotection=pread then
begin
p:=page_readonly;
p1:=FILE_MAP_READ;
end;
if preadwrite = fprotection then
begin
p:=page_readwrite;
p1:= FILE_MAP_WRITE ;
end;
if pcopy = fprotection then
begin
p:= page_writecopy;
p1:= FILE_MAP_COPY;
end;
if apCommit in fadditionalprotections then p:=p or sec_commit;
if apImage in fadditionalprotections then p:=p or sec_image;
if apNocache in fadditionalprotections then p:=p or sec_nocache;
if apReserve in fadditionalprotections then p:=p or sec_reserve;
destructor TFileMapStream_San.Destroy;
begin
unmapviewoffile(fstartpointer);
closehandle(fmaphandle);
//msg;
inherited;
end;
class function TFileMapStream_San.FileMapExists(AMapName: string): boolean;
var
n:pchar;
h:cardinal;
begin
if amapname='' then
n:=nil
else
n:=pchar(amapname);
h:=createfilemapping(c_memhandle,nil,page_readonly,0,1,n);
result:=(h<>0)and(getlasterror=ERROR_ALREADY_EXISTS);
closehandle(h);
end;
function TFileMapStream_San.StartPointer(): pointer;
begin
result:=fstartpointer;
end;
function TFileMapStream_San.Read(var Buffer; Count: Integer): Longint;
var
c:cardinal;
begin
c:=size-position;
if c>count then
result:=count
else
result:=c;
function TFileMapStream_San.Seek(Offset: Integer; Origin: Word): Longint;
begin
case origin of
soFromBeginning:
begin
result:=offset;
end;
soFromEnd:
begin
result:=fsize+offset;
end;
soFromCurrent:
begin
result:=cardinal(fcurrentpointer)-cardinal(fstartpointer)+offset;
end;
end;
fcurrentpointer:=pointer(cardinal(fstartpointer)+result);
if result<0 then
result:=0
else if result>fsize then result:=fsize;
end;
function TFileMapStream_San.CurrentPointer(): pointer;
begin
result:=fcurrentpointer;
end;
function TFileMapStream_San.ToString: string;
begin
setlength(result,size);
copymemory(@result[1],fstartpointer,size);
end;