dmitry boyarintsev schrieb:
On Mon, Jul 19, 2010 at 4:23 AM, Marc Weustink <[email protected]> wrote:
You need to make sure a file exists. IIRC it is not possible to create a
file for sharing, you can only open a file sharable

It's possible. at least the following example did work on Windows.

begin
  filemode:=fmShareDenyNone;
  assign(f, 'c:\test.txt'); rewrite(f);
  writeln(f,'test');

Did you try to stop at this point, or even before WriteLn, and check
whether the file is accessible from other applications?

  writeln('press enter to unlock file');
  readln;
  close(f);
end.

The newly created c:\test.txt was sharable.

AFAIK, it's "impossible" for TFileStream using fmCreate flag. fmCreate
flag causes a file to be re-created without sharing (at Windows).

I can not remember any file attribute "shareable" on Windows. At least
FAT filesystems have no such file attribute.


It might be another issue, though, that new files become *visible* to
other processes only after they have been closed at least once. Same
considerations apply to the file size, that is updated (on disk) only
when a file is closed. I dunno whether it's possible to read added
content, before the file has been closed. That would mean that *all* log
files have to be closed and reopened frequently (after every write), to
give other processes a chance to also read the added text. Kind of a
Flush or Sync procedure would be nice to have, for that purpose...

DoDi


--
_______________________________________________
Lazarus mailing list
[email protected]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

Reply via email to