Locking under OS X and Linux

Under Unix-based operating systems unfortunately there is no defined system for mandatory file locks available. Instead various implementations of advisory locks are offered, all varying and partially incompatible. If another application doesn't support the exact same advisory lock concept that we're using then there is e.g. no protection against file content changes while you're reading it. Also certain protocols like SMB may not support advisory locks at all.

Within the MAXON API files are protected using advisory locks. However there are a couple situations not covered due to the limits of Unix:

  • An input stream that is opened with OPENSTREAMFLAGS::NONE can still be opened for writing if ALLOW_SHARED_READ_WRITE_ACCESS is specified (which it shouldn't).
  • An output stream that is opened with OPENSTREAMFLAGS::ALLOW_SHARED_READ_WRITE_ACCESS can still be opened for reading even when the reader does not specify ALLOW_SHARED_READ_WRITE_ACCESS.

So be extra careful when you use ALLOW_SHARED_READ_WRITE_ACCESS as other code may be able to access your stream even if you never intended it to work that way.