Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2017-01

Does the system unit allow file locking/sharing?

3 messages · 2 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Lars

The oldschool way of opening files using the system unit (no sysutils) has the filemode variable..

system.FileMode := fmOpenRead;
...
Assign(...
Rewrite(...

Can this be used with file locking/sharing OR-ed options like: fmShareCompat
fmShareDenyNone
fmShareDenyRead
fmShareDenyWrite
fmShareExclusive

Or does file locking/sharing require using sysutils unit with fileopen: http://www.freepascal.org/docs-html/rtl/sysutils/fileopen.html

Thanx!

Lars
to Lars
I previously wrote 16 lines
The oldschool way of opening files using the system unit (no sysutils) has the filemode variable.. system.FileMode := fmOpenRead; ... Assign(... Rewrite(... Can this be used with file locking/sharing OR-ed options like: fmShareCompat fmShareDenyNone fmShareDenyRead fmShareDenyWrite fmShareExclusive Or does file locking/sharing require using sysutils unit with fileopen: http://www.freepascal.org/docs-html/rtl/sysutils/fileopen.html

To answer my own question... Looking into the fpc rtl sources I found that DoFileLocking is inside sysutils, so likely system unit (old school handling of files) cannot be used with locking at this stage.

Mark Morgan Lloyd
to Lars
Lars wrote 21 lines
On Mon, January 16, 2017 2:34 pm, I previously wrote: > The oldschool way of opening files using the system unit (no sysutils) > has the filemode variable.. > > system.FileMode := fmOpenRead; ... > Assign(... > Rewrite(... > > > > Can this be used with file locking/sharing OR-ed options like: > fmShareCompat fmShareDenyNone fmShareDenyRead fmShareDenyWrite > fmShareExclusive > > Or does file locking/sharing require using sysutils unit with fileopen: > http://www.freepascal.org/docs-html/rtl/sysutils/fileopen.html > To answer my own question... Looking into the fpc rtl sources I found that DoFileLocking is inside sysutils, so likely system unit (old school handling of files) cannot be used with locking at this stage.

This is likely to be platform-specific once you start looking at locking as distinct from open mode.

Mark Morgan Lloyd markMLl .AT. telemetry.co .DOT. uk [Opinions above are the author's, not those of his employers or colleagues]