From 5e3ebfab4d9d7f206001e13fae1d2d24502f70c9 Mon Sep 17 00:00:00 2001 From: Tomas Hajny Date: Thu, 26 May 2011 21:19:20 +0000 Subject: [PATCH] * real implementation for FileCreate with ShareMode (plus fix for ShareMode in FileOpen) git-svn-id: trunk@17565 - --- rtl/emx/sysutils.pp | 60 ++++++++++++++++++++++++++++----------------- 1 file changed, 38 insertions(+), 22 deletions(-) diff --git a/rtl/emx/sysutils.pp b/rtl/emx/sysutils.pp index 33a5eaaffa..bc86e94a34 100644 --- a/rtl/emx/sysutils.pp +++ b/rtl/emx/sysutils.pp @@ -403,10 +403,14 @@ asm mov ecx, Mode mov edx, FileName {$ENDIF REGCALL} -(* DenyAll if sharing not specified. *) - test ecx, 112 - jnz @FOpen1 - or ecx, 16 +(* DenyNone if sharing not specified. *) + mov eax, ecx + xor eax, 112 + jz @FOpenDefSharing + cmp eax, 64 + jbe FOpen1 +@FOpenDefSharing: + or ecx, 64 @FOpen1: mov eax, 7F2Bh call syscall @@ -415,30 +419,42 @@ asm end {['eax', 'ebx', 'ecx', 'edx']}; -function FileCreate (const FileName: string): longint; assembler; -asm - push ebx -{$IFDEF REGCALL} - mov edx, eax -{$ELSE REGCALL} - mov edx, FileName -{$ENDIF REGCALL} - mov eax, 7F2Bh - mov ecx, ofReadWrite or faCreate or doDenyRW (* Sharing to DenyAll *) - call syscall - pop ebx -end {['eax', 'ebx', 'ecx', 'edx']}; +function FileCreate (const FileName: string): longint; +begin + FileCreate := FileCreate (FileName, ofReadWrite or faCreate or doDenyRW, 777); + (* Sharing to DenyAll *) +end; function FileCreate (const FileName: string; Rights: integer): longint; begin - FileCreate:=FileCreate(FileName); + FileCreate := FileCreate (FileName, ofReadWrite or faCreate or doDenyRW, + Rights); (* Sharing to DenyAll *) end; -function FileCreate (const FileName: string; ShareMode : integer; Rights: integer): longint; -begin - FileCreate:=FileCreate(FileName); -end; +function FileCreate (const FileName: string; ShareMode: integer; Rights: integer): longint; assembler; +asm + push ebx +{$IFDEF REGCALL} + mov ecx, edx + mov edx, eax +{$ELSE REGCALL} + mov ecx, ShareMode + mov edx, FileName +{$ENDIF REGCALL} + and ecx, 112 + or ecx, ecx + jz @FCDefSharing + cmp ecx, 64 + jbe @FCSharingOK +@FCDefSharing: + mov ecx, doDenyRW (* Sharing to DenyAll *) +@FCSharingOK: + or ecx, ofReadWrite or faCreate + mov eax, 7F2Bh + call syscall + pop ebx +end {['eax', 'ebx', 'ecx', 'edx']}; function FileRead (Handle: longint; Out Buffer; Count: longint): longint;