mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-12 00:46:02 +02:00
* hopefully final fix to unix locking: specifying no locking mode again
means "exclusive lock" where supported (not on Solaris when opening a file in read-only mode) git-svn-id: trunk@12675 -
This commit is contained in:
parent
adaae268ae
commit
6581c8dec5
@ -185,12 +185,26 @@ begin
|
||||
{$ifndef beos}
|
||||
if (Handle>=0) then
|
||||
begin
|
||||
case (mode and (fmShareCompat or fmShareExclusive or fmShareDenyWrite or fmShareDenyRead)) of
|
||||
{$ifdef solaris}
|
||||
{ Solaris' flock is based on top of fcntl, which does not allow
|
||||
exclusive locks for files only opened for reading nor shared
|
||||
locks for files opened only for writing
|
||||
}
|
||||
if ((mode and (fmShareCompat or fmShareExclusive or fmShareDenyWrite or fmShareDenyRead)) = 0) then
|
||||
begin
|
||||
mode := mode and not(fmShareCompat);
|
||||
if ((mode and (fmOpenRead or fmOpenWrite or fmOpenReadWrite)) = fmOpenWrite) then
|
||||
mode := mode or fmShareExclusive
|
||||
else
|
||||
mode := mode or fmShareDenyWrite;
|
||||
end;
|
||||
{$endif solaris}
|
||||
case (mode and (fmShareCompat or fmShareExclusive or fmShareDenyWrite or fmShareDenyRead or fmShareDenyNone)) of
|
||||
fmShareCompat,
|
||||
fmShareExclusive:
|
||||
lockop:=LOCK_EX or LOCK_NB;
|
||||
fmShareDenyWrite:
|
||||
lockop:=LOCK_SH or LOCK_NB;
|
||||
fmShareCompat,
|
||||
fmShareDenyNone:
|
||||
exit;
|
||||
else
|
||||
|
Loading…
Reference in New Issue
Block a user