fpc/tests/webtbs/tw27998.pp
Jonas Maebe be6dc49aa5 * fixed test for Windows (the fact that it worked for Unix was due to a bug
in the Unix file locking implementation)

git-svn-id: trunk@30876 -
2015-05-17 11:08:05 +00:00

26 lines
540 B
ObjectPascal

program a;
{$mode delphi}
uses
SysUtils, Classes;
const
LockFile = 'lock.txt';
var
H : TStream;
begin
try
H := TFileStream.Create(lockFile, fmCreate);
h.Write(H, 4);
{ should fail with an exception due to exclusion }
H := TFileStream.Create(lockFile, fmCreate);
Halt(1);
except
{ check the size of the file, to ensure that the second
create didn't overwrite the file }
H.free;
H := TFileStream.create(LockFile, fmOpenRead or fmShareDenyNone);
if H.Size<>4 then
halt(2);
end
end.